Lines 41-96
Link Here
|
41 |
done |
41 |
done |
42 |
} |
42 |
} |
43 |
|
43 |
|
|
|
44 |
check_db() { |
45 |
DB=/var/db/spamd |
46 |
if [ -f ${DB} ]; then |
47 |
OWN=`ls -l ${DB} | awk '{print $3}'` |
48 |
GRP=`ls -l ${DB} | awk '{print $4}'` |
49 |
if [ "x${OWN}" != "x${SPAMDUSER}" ]; then |
50 |
echo "change ${DB} owner to ${SPAMDUSER}" |
51 |
/usr/sbin/chown ${SPAMDUSER} ${DB} |
52 |
fi |
53 |
if [ "x${GRP}" != "x${SPAMDGROUP}" ]; then |
54 |
echo "change ${DB} group to ${SPAMDGROUP}" |
55 |
/usr/sbin/chown :${SPAMDGROUP} ${DB} |
56 |
fi |
57 |
fi |
58 |
} |
59 |
|
44 |
check_service() { |
60 |
check_service() { |
45 |
local name number type comment |
61 |
local name number type comment |
46 |
|
62 |
|
47 |
name=$1 |
63 |
name=$1 |
48 |
number=$2 |
64 |
number=$2 |
49 |
type=$3 |
65 |
type=$3 |
50 |
comment=$4 |
66 |
comment=$4 |
51 |
|
67 |
|
52 |
FILE="/etc/services" |
68 |
FILE="/etc/services" |
53 |
# check |
69 |
# check |
54 |
OK=no |
70 |
OK=no |
55 |
HAS_SERVICE=no |
71 |
HAS_SERVICE=no |
56 |
COUNT=1 |
72 |
COUNT=1 |
57 |
for i in `grep $name $FILE `; do |
73 |
for i in `grep $name $FILE `; do |
58 |
if [ $COUNT = 1 ] && [ X"$i" = X"$name" ]; then |
74 |
if [ $COUNT = 1 ] && [ X"$i" = X"$name" ]; then |
59 |
HAS_SERVICE=yes |
75 |
HAS_SERVICE=yes |
60 |
elif [ $COUNT = 2 ] && [ $HAS_SERVICE = yes ] && \ |
76 |
elif [ $COUNT = 2 ] && [ $HAS_SERVICE = yes ] && \ |
61 |
[ X"$i" = X"$number/$type" ]; then |
77 |
[ X"$i" = X"$number/$type" ]; then |
62 |
OK=yes |
78 |
OK=yes |
63 |
break |
79 |
break |
64 |
fi |
80 |
fi |
65 |
COUNT=`expr ${COUNT} + 1` |
81 |
COUNT=`expr ${COUNT} + 1` |
66 |
done |
82 |
done |
67 |
# add an entry for SERVICE to /etc/services |
83 |
# add an entry for SERVICE to /etc/services |
68 |
if [ $OK = no ]; then |
84 |
if [ $OK = no ]; then |
69 |
echo "This system has no entry for $name in ${FILE}" |
85 |
echo "This system has no entry for $name in ${FILE}" |
70 |
if yesno "Would you like to add it automatically?" y; then |
86 |
if yesno "Would you like to add it automatically?" y; then |
71 |
mv ${FILE} ${FILE}.bak |
87 |
mv ${FILE} ${FILE}.bak |
72 |
(grep -v $name ${FILE}.bak ; \ |
88 |
(grep -v $name ${FILE}.bak ; \ |
73 |
echo "$name $number/$type # $comment") \ |
89 |
echo "$name $number/$type # $comment") \ |
74 |
>> ${FILE} |
90 |
>> ${FILE} |
75 |
rm ${FILE}.bak |
91 |
rm ${FILE}.bak |
76 |
else |
92 |
else |
77 |
echo "Please add '$name $number/$type' into ${FILE}, and try again." |
93 |
echo "Please add '$name $number/$type' into ${FILE}, and try again." |
78 |
return 1 |
94 |
return 1 |
79 |
fi |
95 |
fi |
80 |
fi |
96 |
fi |
81 |
return 0 |
97 |
return 0 |
82 |
} |
98 |
} |
83 |
|
99 |
|
84 |
|
100 |
|
|
|
101 |
# this msg is for users installing not from source, |
102 |
# - show msg about changed sync protocol |
85 |
if [ "$2" = "PRE-INSTALL" ]; then |
103 |
if [ "$2" = "PRE-INSTALL" ]; then |
|
|
104 |
echo " |
105 |
|
106 |
**** UPGRADE WARNING: SYNC PROTOCOL CHANGED **** |
107 |
|
108 |
If you have spamd in distributed environment stop |
109 |
sync between old (4.1.x) and this new version |
110 |
until every node is updated |
111 |
|
112 |
read UPDATING in your PORTSDIR |
113 |
|
114 |
**** UPGRADE WARNING: SYNC PROTOCOL CHANGED **** |
115 |
" |
116 |
read -p "Hit ^c now to stop, any key to continue: " -t 5 a || true |
117 |
echo "" |
118 |
echo "" |
119 |
fi |
120 |
|
121 |
if [ "$2" = "PRE-INSTALL" ]; then |
122 |
check_dbown=0 |
86 |
if /usr/sbin/pw group show "${SPAMDGROUP}" 2>&1 >/dev/null; then |
123 |
if /usr/sbin/pw group show "${SPAMDGROUP}" 2>&1 >/dev/null; then |
87 |
echo "You already have a \"${SPAMDGROUP}\" group, so I will use it." |
124 |
echo "You already have a \"${SPAMDGROUP}\" group, so I will use it." |
|
|
125 |
check_dbown=1 |
88 |
else |
126 |
else |
89 |
echo "You need a \"${SPAMDGROUP}\" group." |
127 |
echo "You need a \"${SPAMDGROUP}\" group." |
90 |
if yesno "Would you like me to create it" "YES"; then |
128 |
if yesno "Would you like me to create it" "YES"; then |
91 |
/usr/sbin/pw groupadd "${SPAMDGROUP}" -g "${SPAMDGID}" -h - || \ |
129 |
/usr/sbin/pw groupadd "${SPAMDGROUP}" -g "${SPAMDGID}" -h - || \ |
92 |
/usr/sbin/pw groupadd "${SPAMDGROUP}" -h - || exit |
130 |
/usr/sbin/pw groupadd "${SPAMDGROUP}" -h - || exit |
93 |
echo "Done." |
131 |
echo "Done." |
|
|
132 |
check_dbown=1 |
94 |
else |
133 |
else |
95 |
echo "Please create the \"${SPAMDGROUP}\" group manually and try again." |
134 |
echo "Please create the \"${SPAMDGROUP}\" group manually and try again." |
96 |
exit 1 |
135 |
exit 1 |
Lines 99-104
Link Here
|
99 |
|
138 |
|
100 |
if /usr/sbin/pw user show "${SPAMDUSER}" 2>&1 >/dev/null; then |
139 |
if /usr/sbin/pw user show "${SPAMDUSER}" 2>&1 >/dev/null; then |
101 |
echo "You already have a \"${SPAMDUSER}\" user, so I will use it." |
140 |
echo "You already have a \"${SPAMDUSER}\" user, so I will use it." |
|
|
141 |
check_dbown=1 |
102 |
else |
142 |
else |
103 |
echo "You need a \"${SPAMDUSER}\" user." |
143 |
echo "You need a \"${SPAMDUSER}\" user." |
104 |
if yesno "Would you like me to create it" "YES"; then |
144 |
if yesno "Would you like me to create it" "YES"; then |
Lines 106-117
Link Here
|
106 |
-s /sbin/nologin -c "spamd pseudo-user" || \ |
146 |
-s /sbin/nologin -c "spamd pseudo-user" || \ |
107 |
/usr/sbin/pw useradd "${SPAMDUSER}" -g "${SPAMDGROUP}" -h - -d "${SPAMDDIR}" \ |
147 |
/usr/sbin/pw useradd "${SPAMDUSER}" -g "${SPAMDGROUP}" -h - -d "${SPAMDDIR}" \ |
108 |
-s /sbin/nologin -c "spamd pseudo-user" || exit |
148 |
-s /sbin/nologin -c "spamd pseudo-user" || exit |
|
|
149 |
check_dbown=1 |
109 |
else |
150 |
else |
110 |
echo "Please create the \"${SPAMDUSER}\" user manually and try again." |
151 |
echo "Please create the \"${SPAMDUSER}\" user manually and try again." |
111 |
exit 1 |
152 |
exit 1 |
112 |
fi |
153 |
fi |
113 |
fi |
154 |
fi |
114 |
|
155 |
|
|
|
156 |
if [ ${check_dbown} -eq 1 ]; then |
157 |
check_db |
158 |
fi |
159 |
|
115 |
if ! check_service spamd 8025 tcp "spamd(8)"; then |
160 |
if ! check_service spamd 8025 tcp "spamd(8)"; then |
116 |
exit 1 |
161 |
exit 1 |
117 |
fi |
162 |
fi |