]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - config/rootfiles/core/65/update.sh
Merge remote-tracking branch 'origin/next' into thirteen
[people/teissler/ipfire-2.x.git] / config / rootfiles / core / 65 / update.sh
1 #!/bin/bash
2 ############################################################################
3 # #
4 # This file is part of the IPFire Firewall. #
5 # #
6 # IPFire is free software; you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation; either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # IPFire is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with IPFire; if not, write to the Free Software #
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
19 # #
20 # Copyright (C) 2012 IPFire-Team <info@ipfire.org>. #
21 # #
22 ############################################################################
23 #
24 . /opt/pakfire/lib/functions.sh
25 /usr/local/bin/backupctrl exclude >/dev/null 2>&1
26
27 #
28 # Remove old core updates from pakfire cache to save space...
29 core=65
30 for (( i=1; i<=$core; i++ ))
31 do
32 rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire
33 done
34
35 #
36 KVER="3.2.33"
37 MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
38 # Nur den letzten Parameter verwenden
39 echo $MOUNT > /dev/null
40 MOUNT=$_
41 if [ ! $MOUNT == "rw" ]; then
42 MOUNT="ro"
43 fi
44
45 #
46 # check if we the backup file already exist
47 if [ -e /var/ipfire/backup/core-upgrade_$KVER.tar.xz ]; then
48 echo Moving backup to backup-old ...
49 mv -f /var/ipfire/backup/core-upgrade_$KVER.tar.xz \
50 /var/ipfire/backup/core-upgrade_$KVER-old.tar.xz
51 fi
52 echo First we made a backup of all files that was inside of the
53 echo update archive. This may take a while ...
54 # Add some files that are not in the package to backup
55 echo lib/modules >> /opt/pakfire/tmp/ROOTFILES
56 echo etc/udev >> /opt/pakfire/tmp/ROOTFILES
57 echo lib/udev >> /opt/pakfire/tmp/ROOTFILES
58 echo boot >> /opt/pakfire/tmp/ROOTFILES
59 echo etc/snort >> /opt/pakfire/tmp/ROOTFILES
60 echo usr/lib/snort_* >> /opt/pakfire/tmp/ROOTFILES
61
62 # Backup the files
63 tar cJvf /var/ipfire/backup/core-upgrade_$KVER.tar.xz \
64 -C / -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' --exclude='/var/cache' > /dev/null 2>&1
65
66 echo
67 echo Update Kernel to $KVER ...
68 #
69 # Remove old kernel, configs, initrd, modules ...
70 #
71 rm -rf /boot/System.map-*
72 rm -rf /boot/config-*
73 rm -rf /boot/ipfirerd-*
74 rm -rf /boot/vmlinuz-*
75 rm -rf /lib/modules/*-ipfire
76 #
77 # Remove old udev rules.
78 #
79 cp /etc/udev/rules.d/29-ct-server-network.rules /tmp/
80 cp /etc/udev/rules.d/30-persistent-network.rules /tmp/
81 rm -rf /etc/udev
82 rm -rf /lib/udev
83 mkdir -p /etc/udev/rules.d
84 mv /tmp/29-ct-server-network.rules /etc/udev/rules.d/
85 mv /tmp/30-persistent-network.rules /etc/udev/rules.d/
86
87 #
88 # Backup grub.conf
89 #
90 cp -vf /boot/grub/grub.conf /boot/grub/grub.conf.org
91
92 #
93 #Stop services
94 /etc/init.d/snort stop
95 /etc/init.d/squid stop
96 /etc/init.d/ipsec stop
97
98 #Remove old snort
99 rm -rf /etc/snort
100 rm -rf /usr/lib/snort_*
101
102 #
103 #Extract files
104 extract_files
105
106 #
107 # Start services
108 #
109 /etc/init.d/squid start
110 /etc/init.d/snort start
111 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
112 /etc/init.d/ipsec start
113 fi
114
115 #
116 # Rebuild qosscript if enabled
117 #
118 if [ -e /var/ipfire/qos/enable ]; then
119 /usr/local/bin/qosctrl stop
120 /usr/local/bin/qosctrl generate
121 /usr/local/bin/qosctrl start
122 fi
123
124 #
125 # Modify grub.conf
126 #
127 echo
128 echo Update grub configuration ...
129 ROOT=`mount | grep " / " | cut -d" " -f1`
130
131 if [ ! -z $ROOT ]; then
132 ROOTUUID=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
133 fi
134
135 if [ ! -z $ROOTUUID ]; then
136 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot/grub/grub.conf
137 else
138 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
139 fi
140 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
141 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
142
143 if [ "$(grep "^serial" /boot/grub/grub.conf.org)" == "" ]; then
144 echo "grub use default console ..."
145 else
146 echo "grub use serial console ..."
147 sed -i -e "s|splashimage|#splashimage|g" /boot/grub/grub.conf
148 sed -i -e "s|#serial|serial|g" /boot/grub/grub.conf
149 sed -i -e "s|#terminal|terminal|g" /boot/grub/grub.conf
150 sed -i -e "s| panic=10 | console=ttyS0,38400n8 panic=10 |g" /boot/grub/grub.conf
151 fi
152 #
153 # Delete old lm-sensor modullist to force search at next boot
154 #
155 rm -rf /etc/sysconfig/lm_sensors
156
157 #
158 #Update Language cache
159 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
160
161 #
162 # Remove meta's of packages that are now common...
163 #
164 rm -rf /opt/pakfire/db/*/meta-fontconfig
165 rm -rf /opt/pakfire/db/*/meta-glib
166
167 #
168 # After pakfire has ended run it again and update the lists and do upgrade
169 #
170 echo '#!/bin/bash' > /tmp/pak_update
171 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update
172 echo ' sleep 1' >> /tmp/pak_update
173 echo 'done' >> /tmp/pak_update
174 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update
175 echo ' sleep 1' >> /tmp/pak_update
176 echo 'done' >> /tmp/pak_update
177 echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update
178 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
179 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
180 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
181 echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-65 "Upgrade finished. If you use a customized grub.cfg"' >> /tmp/pak_update
182 echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-65 "Check it before reboot !!!"' >> /tmp/pak_update
183 echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-65 " *** Please reboot... *** "' >> /tmp/pak_update
184 echo 'touch /var/run/need_reboot ' >> /tmp/pak_update
185 #
186 chmod +x /tmp/pak_update
187 /tmp/pak_update &
188
189 sync
190
191 #
192 #Finish
193 /etc/init.d/fireinfo start
194 sendprofile
195
196 echo
197 echo Please wait until pakfire has ended...
198 echo
199 #Don't report the exitcode last command
200 exit 0
201