blob: ec4c871acb110c3035e096795f2a6bb5dd4e3eb8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#!/bin/sh
#
# $FreeBSD: /tmp/pcvs/ports/net/phpldapadmin/files/pkg-install.in,v 1.2 2008-03-09 04:45:38 rafan Exp $
#
PATH=/usr/sbin:/usr/bin:/bin ; export PATH
pla_dir=%%WWWDIR%%
pla_usr=%%PLA_USR%%
pla_uid=%%PLA_UID%%
pla_grp=%%PLA_GRP%%
pla_gid=%%PLA_GID%%
pla_gcos="%%PLA_GCOS%%"
pla_home=%%PLA_HOME%%
pla_shell=%%PLA_SHELL%%
create_group() {
local user uid group gid gcos home shell
user=$1
uid=$2
group=$3
gid=$4
gcos=$5
home=$6
shell=$7
if pw group show -n $group >/dev/null 2>&1 ; then
echo "===> Using pre-existing group $group"
else
if pw groupadd -n $group -g $gid ; then
echo "===> Group $group created"
else
cat <<-EOERRORMSG
*** Failed to create the $group group.
Please add the $user user and $group group
manually with the commands:
pw groupadd -n $group -g $gid
pw useradd -n $user -u $uid -g $group -c "$gcos" \\
-d $home -s $shell -h -
and retry installing this package.
EOERRORMSG
exit 1
fi
fi
}
create_user() {
local user uid group gid gcos home shell
user=$1
uid=$2
group=$3
gid=$4
gcos=$5
home=$6
shell=$7
if pw user show -n $user >/dev/null 2>&1 ; then
echo "===> Using pre-existing user $user"
else
if pw useradd -n $user -u $uid -g $group -c "$gcos" \
-d $home -s $shell -h - ; then
echo "===> Created $user user"
else
cat <<-EOERRORMSG
*** Failed to create the $user user.
Please add the $user user manually with the command:
pw useradd -n $user -u $uid -g $group -c "$gcos" \\
-d $home -s $shell -h -
and retry installing this package.
EOERRORMSG
exit 1
fi
fi
}
case $2 in
PRE-INSTALL)
# Create the pla user and group if they do not already exist
create_group $pla_usr $pla_uid $pla_grp $pla_gid \
"$pla_gcos" $pla_home $pla_shell
create_user $pla_usr $pla_uid $pla_grp $pla_gid \
"$pla_gcos" $pla_home $pla_shell
;;
POST-INSTALL)
# Change ownership of the phpMyAdm directory
echo "===> Adjusting file ownership in $pla_dir"
chown -R $pla_usr:$pla_grp $pla_dir || exit 1
;;
esac
#
# That's All Folks!
#
|