blob: 7b187884455435ee84f85da0fe8bdb36f5eb1512 (
plain)
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
|
#!/bin/sh
shout() { echo "$0: $@" >&2; }
barf() { shout "fatal: $@"; exit 111; }
safe() { "$@" || barf "cannot $@"; }
here=`env - PATH=$PATH pwd`
mypwd=${here%package}
mypwd=${mypwd%/}
home=`head -1 $mypwd/conf-home`
if [ -f $mypwd/conf-ids ]
then
sqmailids=`grep -v "^#" $mypwd/conf-ids | grep ":" | tr ' ' '_'`
else
barf "Can't open file '$mypwd/conf-ids' with sqmail ids!"
fi
unix=`uname -a | cut -d' ' -f1 | tr [a-z] [A-Z]`
if [ "$unix" = "LINUX" ]
then
qshl="/bin/false"
shout "Linux (Shell: $qshl):"
for line in $sqmailids
do
if [ `echo $line | grep "group"` ]
then
qgid=`echo "$line" | cut -d":" -f1`
qgrp=`echo "$line" | cut -d":" -f2`
if [ `grep -c ^$qgrp /etc/group` -eq 0 ]
then
safe groupadd -g $qgid $qgrp
else
shout "Group '$qgrp' already existing!"
fi
fi
if [ `echo $line | grep "user"` ]
then
quid=`echo "$line" | cut -d":" -f1`
qusr=`echo "$line" | cut -d":" -f2`
qcom=`echo "$line" | cut -d":" -f3 | tr "_" " "`
qgrp=`echo "$line" | cut -d":" -f4`
qdir="$home/`echo "$line" | cut -d":" -f5`"
if [ `grep -c $qusr /etc/passwd` -eq 0 ]
then
shout "Generating user: $qusr:$quid - $qgr - $qdir - $qshl - $qcom"
safe useradd -u $quid -g $qgrp -d $qdir $qusr -s $qshl -c "$qcom"
else
shout "User '$qusr' already existing!"
fi
fi
done
elif [ `echo "$unix" | grep "BSD"` ]
then
qshl="/sbin/nologin"
shout "BSD ($unix) (Shell: $qshl):"
for line in $sqmailids
do
if [ `echo $line | grep "group"` ]
then
qgid=`echo "$line" | cut -d":" -f1`
qgrp=`echo "$line" | cut -d":" -f2`
if [ `grep -c ^$qgrp /etc/group` -eq 0 ]
then
if [ `echo "$unix" | grep "OPENBSD"` ]
then
safe groupadd -g $qgid $qgrp
else
safe pw groupadd $qgrp -g $qgid $qgrp
fi
else
shout "Group '$qgrp' already existing!"
fi
fi
if [ `echo $line | grep "user"` ]
then
quid=`echo "$line" | cut -d":" -f1`
qusr=`echo "$line" | cut -d":" -f2`
qcom=`echo "$line" | cut -d":" -f3 | tr "_" " "`
qgrp=`echo "$line" | cut -d":" -f4`
qdir="$home/`echo "$line" | cut -d":" -f5`"
if [ `grep -c $qusr /etc/passwd` -eq 0 ]
then
shout "Generating user: $qusr:$quid - $qgrp - $qdir - $qshl - $qcom"
if [ `echo "$unix" | grep "OPENBSD"` ]
then
safe useradd -u $quid -g $qgrp -d $qdir -s $qshl -c "$qcom" $qusr
else
safe pw useradd $qusr -u $quid -g $qgrp -d $qdir -s $qshl -c "$qcom"
fi
else
shout "User '$qusr' already existing!"
fi
fi
done
else
shout "Unix OS not recognized; please install s/qmail user/groups manually \\
and continue with installation step-by-step."
fi
exit 0
|