-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalternc_update_squeeze_3.sh
142 lines (113 loc) · 3.91 KB
/
alternc_update_squeeze_3.sh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
echo "== Alternc update to 3"
#Initialization variables
IS_SQUEEZE=false
#Check squeeze status
if [ -f /etc/debian_version ]; then
DEBIAN_VERSION="$(</etc/debian_version)"
DEBIAN_VERSION_MAJOR=${DEBIAN_VERSION:0:1}
if [ $DEBIAN_VERSION_MAJOR == 6 ]; then
IS_SQUEEZE=true
fi
fi
if [[ ${IS_SQUEEZE} == false ]]; then
echo "NOK : Squeeze is required"
exit;
fi
echo "OK : It's squeeze ( ${DEBIAN_VERSION} )"
#Check version alternc
ALTERNC_VERSION="$(dpkg -l alternc|grep alternc|awk '{print $3}')"
ALTERNC_VERSION_MAJOR=${ALTERNC_VERSION:0:1}
if [ $ALTERNC_VERSION_MAJOR != 1 ]; then
echo "NOK : Aternc 1.x required"
exit;
fi
echo "OK : It's alternc ( ${ALTERNC_VERSION} )"
#Check alternc Directory
. /etc/alternc/local.sh
#Check ACL package
if [ -z "`type -f setfacl 2>/dev/null`" ]; then
echo "NOK : acl package required"
echo " apt-get install acl"
exit;
fi
#Check ACL configuration
aclcheckfile="${ALTERNC_LOC}/test-acl"
touch $aclcheckfile
setfacl -m u:root:rwx "$aclcheckfile" 2>/dev/null
if [ "$?" == 1 ]; then
rm "$aclcheckfile"
echo "NOK : ACL is not enabled on ${ALTERNC_LOC}"
echo " According to your configuration, add acl or attr2 or user_attr directive on your /etc/fstab"
echo " mount / -o remount,acl"
exit
fi
rm "$aclcheckfile"
echo "OK : ACL are enabled and configured"
#Check sudo status/configuration
SUDO_VERSION="$(dpkg -l sudo|grep sudo|awk '{print $3}')"
if [ -z ${SUDO_VERSION} ]; then
echo "NOK : sudo is required"
echo " apt-get install sudo"
exit
fi
#Check /etc/sudoers.d enable
grep -Fxq "#includedir /etc/sudoers.d" /etc/sudoers
if [ "$?" == 1 ]; then
echo "#includedir /etc/sudoers.d added in /etc/sudoers"
echo "#includedir /etc/sudoers.d" >> /etc/sudoers
fi
echo "OK : Sudo is enabled and compliant with alternc"
#Update source.list
echo "== source List update"
if [ -f /etc/apt/sources.list.d/alternc.list ]; then
SOURCE_LIST_BKP="/etc/apt/sources.list.d/alternc.list.save".$(date +%s)
mv /etc/apt/sources.list.d/alternc.list $SOURCE_LIST_BKP
echo " Your alternc sources.list has been backuped to $SOURCE_LIST_BKP"
fi
echo "deb http://debian.alternc.org/ squeeze main" > /etc/apt/sources.list.d/alternc.list
wget --quiet http://debian.alternc.org/key.txt -O - | apt-key add - >/dev/null
apt-get update >/dev/null
echo "OK : Alternc repository is added and packages list updated"
#Check and restore courier status
COURIER_STATUS=`dpkg -l courier-imap|grep courier|awk '{print $1}'`
if [[ $COURIER_STATUS == "rF" ]]; then
echo "== Courier status error, restore configuration"
apt-get install courier-base courier-authlib courier-authdaemon courier-authlib-mysql courier-authlib-userdb courier-imap courier-pop courier-ssl -yq
echo "OK : Courier restored"
fi
#Kill Courier
echo "== Kill courier service"
cd /etc/init.d/
./courier-authdaemon stop
./courier-imap stop
./courier-imap-ssl stop
./courier-pop stop
./courier-pop-ssl stop
#Disable Courier
echo "== Disable pre remove Courrier package (Bug Debian)"
sed -i '1s/^/#!\/bin\/sh\nexit 0\n/' /var/lib/dpkg/info/courier-imap-ssl.prerm
sed -i '1s/^/#!\/bin\/sh\nexit 0\n/' /var/lib/dpkg/info/courier-imap.prerm
echo "OK : Courier is disabled"
#Do a awstat generation
if [ -f /usr/lib/alternc/alternc-awstats ] ; then
echo "== Awstats detected"
/bin/bash /usr/lib/alternc/alternc-awstats >/dev/null
echo 'OK : Statistics awstats updated'
fi
# Checks for cron commands executed by 'www-data' user
OLDIFS=$IFS
IFS="
"
for f in /etc/cron.d/* ; do
filelines=$(cat $f);
escaped=$(echo $f|tr "/" "\/")
for line in $filelines ; do
echo $line|sed -n -r "s:^[0-9]\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(www-data).*:#Warning The cron file\
$escaped will be broken as it tries to execute as www-data which is not compatible with apache mpm\
itk:p"
done
done
IFS=$OLDIFS
echo "Perfect : You can execute"
echo " apt-get install alternc "