-
Notifications
You must be signed in to change notification settings - Fork 0
/
os_post-upgrade
executable file
·86 lines (74 loc) · 1.96 KB
/
os_post-upgrade
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
#!/bin/bash
# Remove pre-upgrade hook
rm -f etc/init/upgrade.conf
# disable all services
if [ -f /sbin/chkconfig ] && [ -f /bin/grep ] && [ -f /bin/sed ] ; then
for i in `LANG=C /sbin/chkconfig --list | grep -v "xinetd based services:" | sed -e "s/\([^ ]*\)[ ]*0.*/\1/" -e "s/[\t]\(.*\):.*/\1/"`; do
[ -x etc/init.d/$i ] && /sbin/chkconfig --level 3 $i off > /dev/null 2>&1
done
fi
# turn services on
list="network httpd iptables sshd xinetd saslauthd sendmail rsyslog crond"
for i in $list; do
/sbin/chkconfig --level 3 $i on > /dev/null 2>&1
done
# Fix /etc/rsyslog.conf
CFG_FILE=etc/rsyslog.conf
if [ -f $CFG_FILE ]; then
echo -e ',s^\([[:space:]]\)\(/var/log/\)^\\1-\\2^\nwq' | ed -s $CFG_FILE
fi
# Create empty modules.dep on container start
echo "#!/bin/bash
# Fix modules.dep for iptables
#
# chkconfig: 2345 08 92
# description: Simple script that fixed modules.dep for iptables
#
### BEGIN INIT INFO
# Provides: modules_dep
# Required-Start: \$local_fs
# Required-Stop: \$local_fs
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Fix modules.dep for iptables
# Description: Simple script that fixed modules.dep for iptables
### END INIT INFO
# source function library
. /etc/init.d/functions
function start() {
if [ ! -d \"/lib/modules/\`uname -r\`\" ]; then
mkdir /lib/modules/\`uname -r\`
fi
depmod -a >/dev/null 2>&1
}
function stop() {
if [ -d \"/lib/modules/\`uname -r\`\" ]; then
rm -rf /lib/modules/\`uname -r\`
fi
}
case \"\$1\" in
start)
start
RETVAL=0
;;
stop)
stop
RETVAL=0
;;
restart|reload|condrestart)
stop
start
;;
try-restart|status)
RETVAL=0
;;
*)
echo \$\"Usage: \$0 {start|stop|status|restart|condrestart|reload}\"
RETVAL=2
esac
exit \$RETVAL" > etc/init.d/modules_dep
chmod 0755 etc/init.d/modules_dep
/sbin/chkconfig --add modules_dep
: