2 ############################################################################
4 # This file is part of the IPFire Firewall. #
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. #
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. #
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 #
20 # Copyright (C) 2013 IPFire-Team <info@ipfire.org>. #
22 ############################################################################
24 .
/opt
/pakfire
/lib
/functions.sh
25 /usr
/local
/bin
/backupctrl exclude
>/dev
/null
2>&1
27 function add_to_backup
()
29 # Add path to ROOTFILES but remove old entries to prevent double
31 grep -v "^$1" /opt
/pakfire
/tmp
/ROOTFILES
> /opt
/pakfire
/tmp
/ROOTFILES.tmp
32 mv /opt
/pakfire
/tmp
/ROOTFILES.tmp
/opt
/pakfire
/tmp
/ROOTFILES
33 echo $1 >> /opt
/pakfire
/tmp
/ROOTFILES
37 # Remove old core updates from pakfire cache to save space...
39 for (( i
=1; i
<=$core; i
++ ))
41 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
45 # Do some sanity checks.
48 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
49 "core-update-$core: ERROR cannot update. versatile support is dropped."
50 # Report no error to pakfire. So it does not try to install it again.
54 BOOTSIZE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f2 | tail -n 1`
55 if [ $BOOTSIZE -lt 28000 ]; then
56 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
57 "core-update-$core: ERROR cannot update because not enough space on boot."
65 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
66 "core-update-$core: ERROR cannot update. No IPFire Kernel."
75 MOUNT
=`grep "kernel" /boot/grub/grub.conf 2>/dev/null | tail -n 1 `
76 # Nur den letzten Parameter verwenden
77 echo $MOUNT > /dev
/null
79 if [ ! $MOUNT == "rw" ]; then
84 # check if we the backup file already exist
85 if [ -e /var
/ipfire
/backup
/core-upgrade
$core_$KVER.
tar.xz
]; then
86 echo Moving backup to backup-old ...
87 mv -f /var
/ipfire
/backup
/core-upgrade
$core_$KVER.
tar.xz \
88 /var
/ipfire
/backup
/core-upgrade
$core_$KVER-old.
tar.xz
90 echo First we made a backup of all files that was inside of the
91 echo update archive. This may take a
while ...
92 # Add some files that are not in the package to backup
93 add_to_backup lib
/modules
94 add_to_backup etc
/udev
95 add_to_backup lib
/udev
97 add_to_backup etc
/sysconfig
/lm_sensors
98 add_to_backup etc
/sysconfig
/rc.
local
99 add_to_backup srv
/web
/ipfire
/html
/themes
/ipfire
100 add_to_backup usr
/lib
/engines
101 add_to_backup etc
/rc.d
/init.d
/networking
/red.up
/22-outgoingfwctrl
102 add_to_backup etc
/rc.d
/init.d
/networking
/red.up
/25-portfw
103 add_to_backup etc
/rc.d
/init.d
/networking
/red.up
/26-xtaccess
104 add_to_backup usr
/local
/bin
/setportfw
105 add_to_backup usr
/local
/bin
/setdmzholes
106 add_to_backup usr
/local
/bin
/setxtaccess
107 add_to_backup usr
/local
/bin
/outgoingfwctrl
108 add_to_backup srv
/web
/ipfire
/cgi-bin
/{dmzholes
,outgoingfw
,portfw
,xtaccess
}.cgi
109 add_to_backup var
/ipfire
/{dmzholes
,portfw
,outgoing
,xtaccess
}
112 tar cJvf
/var
/ipfire
/backup
/core-upgrade
$core_$KVER.
tar.xz \
113 -C / -T /opt
/pakfire
/tmp
/ROOTFILES
--exclude='#*' --exclude='/var/cache' > /dev
/null
2>&1
115 # Check diskspace on root
116 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
118 if [ $ROOTSPACE -lt 70000 ]; then
119 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
120 "core-update-$core: ERROR cannot update because not enough free space on root."
126 echo Update Kernel to
$KVER ...
128 # Remove old kernel, configs, initrd, modules ...
130 rm -rf /boot
/System.map-
*
131 rm -rf /boot
/config-
*
132 rm -rf /boot
/ipfirerd-
*
133 rm -rf /boot
/vmlinuz-
*
134 rm -rf /boot
/uImage-ipfire-
*
135 rm -rf /boot
/uInit-ipfire-
*
139 # Remove old udev rules.
141 if [ -e /etc
/udev
/rules.d
/29-ct-server-network.rules
]; then
142 cp /etc
/udev
/rules.d
/29-ct-server-network.rules
/tmp
/
144 cp /etc
/udev
/rules.d
/30-persistent-network.rules
/tmp
/
147 mkdir
-p /etc
/udev
/rules.d
148 if [ -e /tmp
/rules.d
/29-ct-server-network.rules
]; then
149 mv /tmp
/29-ct-server-network.rules
/etc
/udev
/rules.d
/
151 mv /tmp
/30-persistent-network.rules
/etc
/udev
/rules.d
/
158 cp -vf /boot
/grub
/grub.conf
/boot
/grub
/grub.conf.org
163 /etc
/init.d
/snort stop
164 /etc
/init.d
/squid stop
165 /etc
/init.d
/ipsec stop
166 /etc
/init.d
/apache stop
168 # Remove the old default theme
169 rm -rf /srv
/web
/ipfire
/html
/themes
/ipfire
173 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p --numeric-owner -C /
175 # Check diskspace on boot
176 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
178 if [ $BOOTSPACE -lt 1000 ]; then
181 # Special handling for old kirkwood images.
182 # (install only kirkwood kernel)
184 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p \
185 --numeric-owner -C / --wildcards 'boot/*-kirkwood*'
188 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
189 "core-update-$core: FATAL-ERROR space run out on boot. System is not bootable..."
190 /etc
/init.d
/apache start
197 #Reload init to close old linker/glibc
200 # Regenerate ipsec configuration files.
201 /srv
/web
/ipfire
/cgi-bin
/vpnmain.cgi
203 # Update Language cache
204 perl
-e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
206 # Remove old openssl engines
207 rm -rf /usr
/lib
/engines
209 # Remove old initscripts
210 rm -f /etc
/rc.d
/init.d
/networking
/red.up
/22-outgoingfwctrl
211 rm -f /etc
/rc.d
/init.d
/networking
/red.up
/25-portfw
212 rm -f /etc
/rc.d
/init.d
/networking
/red.up
/26-xtaccess
214 # Remove old firewallscripts
215 rm -f /usr
/local
/bin
/setportfw
216 rm -f /usr
/local
/bin
/setdmzholes
217 rm -f /usr
/local
/bin
/setxtaccess
218 rm -f /usr
/local
/bin
/outgoingfwctrl
220 # Remove old CGI files
221 rm -f /srv
/web
/ipfire
/cgi-bin
/{dmzholes
,outgoingfw
,portfw
,xtaccess
}.cgi
223 # Generate chains for new firewall
224 /sbin
/iptables
-N INPUTFW
225 /sbin
/iptables
-N FORWARDFW
226 /sbin
/iptables
-N POLICYFWD
227 /sbin
/iptables
-N POLICYIN
228 /sbin
/iptables
-N POLICYOUT
229 /sbin
/iptables
-t nat
-N NAT_SOURCE
230 /sbin
/iptables
-t nat
-N NAT_DESTINATION
232 # Convert firewall configuration
233 /usr
/sbin
/convert-xtaccess
234 /usr
/sbin
/convert-outgoingfw
235 /usr
/sbin
/convert-portfw
236 /usr
/sbin
/convert-dmz
238 # Remove old firewall configuration files
239 rm -rf /var
/ipfire
/{dmzholes
,portfw
,outgoing
,xtaccess
}
244 /etc
/init.d
/apache start
245 /etc
/init.d
/squid start
246 /etc
/init.d
/snort start
247 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
248 /etc
/init.d
/ipsec start
252 # Rebuild qosscript if enabled
254 if [ -e /var
/ipfire
/qos
/enable ]; then
255 /usr
/local
/bin
/qosctrl stop
256 /usr
/local
/bin
/qosctrl generate
257 /usr
/local
/bin
/qosctrl start
267 echo Update grub configuration ...
268 ROOT
=`mount | grep " / " | cut -d" " -f1`
270 if [ ! -z $ROOT ]; then
271 ROOTUUID
=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
274 if [ ! -z $ROOTUUID ]; then
275 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot
/grub
/grub.conf
277 sed -i "s|ROOT|$ROOT|g" /boot
/grub
/grub.conf
279 sed -i "s|KVER|$KVER|g" /boot
/grub
/grub.conf
280 sed -i "s|MOUNT|$MOUNT|g" /boot
/grub
/grub.conf
282 if [ "$(grep "^serial
" /boot/grub/grub.conf.org)" == "" ]; then
283 echo "grub use default console ..."
285 echo "grub use serial console ..."
286 sed -i -e "s|splashimage|#splashimage|g" /boot
/grub
/grub.conf
287 sed -i -e "s|#serial|serial|g" /boot
/grub
/grub.conf
288 sed -i -e "s|#terminal|terminal|g" /boot
/grub
/grub.conf
289 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" /boot
/grub
/grub.conf
295 echo "(hd0) ${ROOT::`expr length $ROOT`-1}" > /boot
/grub
/device.map
296 grub-install
--no-floppy ${ROOT::`expr length $ROOT`-1}
300 # Delete old lm-sensor modullist to force search at next boot
302 rm -rf /etc
/sysconfig
/lm_sensors
305 # Force (re)install pae kernel if pae is supported
306 rm -rf /opt
/pakfire
/db
/*/meta-linux-pae
307 if [ ! "$(grep "^flags.
* pae
" /proc/cpuinfo)" == "" ]; then
308 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
309 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
310 if [ $BOOTSPACE -lt 8000 -o $ROOTSPACE -lt 70000 ]; then
311 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
312 "core-update-$core: WARNING not enough space for pae kernel."
314 echo "Name: linux-pae" > /opt
/pakfire
/db
/installed
/meta-linux-pae
315 echo "ProgVersion: 3.10.24" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
316 echo "Release: 30" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
320 # Force reinstall xen kernel if it was installed
321 if [ -e "/opt/pakfire/db/installed/meta-linux-xen" ]; then
322 echo "Name: linux-xen" > /opt
/pakfire
/db
/installed
/meta-linux-xen
323 echo "ProgVersion: 2.6.32.60" >> /opt
/pakfire
/db
/installed
/meta-linux-xen
324 echo "Release: 24" >> /opt
/pakfire
/db
/installed
/meta-linux-xen
325 # Add xvc0 to /etc/securetty
326 echo "xvc0" >> /etc
/securetty
330 # After pakfire has ended run it again and update the lists and do upgrade
332 echo '#!/bin/bash' > /tmp
/pak_update
333 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp
/pak_update
334 echo ' sleep 1' >> /tmp
/pak_update
335 echo 'done' >> /tmp
/pak_update
336 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp
/pak_update
337 echo ' sleep 1' >> /tmp
/pak_update
338 echo 'done' >> /tmp
/pak_update
339 echo '/opt/pakfire/pakfire update -y --force' >> /tmp
/pak_update
340 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
341 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
342 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
343 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub.cfg"' >> /tmp
/pak_update
344 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp
/pak_update
345 echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp
/pak_update
346 echo 'touch /var/run/need_reboot ' >> /tmp
/pak_update
348 chmod +x
/tmp
/pak_update
356 /etc
/init.d
/fireinfo start
361 echo Please
wait until pakfire has ended...
363 #Don't report the exitcode last command