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...
40 for (( i
=1; i
<=$core; i
++ ))
42 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
46 # Do some sanity checks.
49 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
50 "core-update-$core: ERROR cannot update. versatile support is dropped."
51 # Report no error to pakfire. So it does not try to install it again.
55 BOOTSIZE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f2 | tail -n 1`
56 if [ $BOOTSIZE -lt 28000 ]; then
57 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
58 "core-update-$core: ERROR cannot update because not enough space on boot."
66 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
67 "core-update-$core: ERROR cannot update. No IPFire Kernel."
68 # Report no error to pakfire. So it does not try to install it again.
73 if [ ! "$(mount | grep " reiser4
(")" == "" ]; then
74 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
75 "core-update-$core: ERROR cannot update because there is a reiser4 fs mounted."
82 MOUNT
=`grep "kernel" /boot/grub/grub.conf 2>/dev/null | tail -n 1 `
83 # Nur den letzten Parameter verwenden
84 echo $MOUNT > /dev
/null
86 if [ ! $MOUNT == "rw" ]; then
91 # check if we the backup file already exist
92 if [ -e /var
/ipfire
/backup
/core-upgrade
$core_$KVER.
tar.xz
]; then
93 echo Moving backup to backup-old ...
94 mv -f /var
/ipfire
/backup
/core-upgrade
$core_$KVER.
tar.xz \
95 /var
/ipfire
/backup
/core-upgrade
$core_$KVER-old.
tar.xz
97 echo First we made a backup of all files that was inside of the
98 echo update archive. This may take a
while ...
99 # Add some files that are not in the package to backup
100 add_to_backup lib
/modules
101 add_to_backup etc
/udev
102 add_to_backup lib
/udev
104 add_to_backup etc
/snort
105 add_to_backup usr
/lib
/snort_
*
106 add_to_backup usr
/share
/zoneinfo
107 add_to_backup lib
/libncurses
*
108 add_to_backup etc
/dircolors
109 add_to_backup etc
/profile.d
110 add_to_backup usr
/share
/terminfo
111 add_to_backup etc
/sysconfig
/lm_sensors
112 add_to_backup etc
/sysconfig
/rc.
local
113 add_to_backup usr
/local
/bin
/vpn-watch
114 add_to_backup usr
/libexec
/ipsec
117 tar cJvf
/var
/ipfire
/backup
/core-upgrade
$core_$KVER.
tar.xz \
118 -C / -T /opt
/pakfire
/tmp
/ROOTFILES
--exclude='#*' --exclude='/var/cache' > /dev
/null
2>&1
120 # Check diskspace on root
121 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
123 if [ $ROOTSPACE -lt 70000 ]; then
124 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
125 "core-update-$core: ERROR cannot update because not enough free space on root."
130 echo Update Kernel to
$KVER ...
132 # Remove old kernel, configs, initrd, modules ...
134 rm -rf /boot
/System.map-
*
135 rm -rf /boot
/config-
*
136 rm -rf /boot
/ipfirerd-
*
137 rm -rf /boot
/vmlinuz-
*
138 rm -rf /boot
/uImage-ipfire-
*
139 rm -rf /boot
/uInit-ipfire-
*
141 rm -rf /etc
/dircolors
142 rm -rf /etc
/profile.d
143 rm -rf /usr
/share
/terminfo
147 # Remove old udev rules.
149 if [ -e /etc
/udev
/rules.d
/29-ct-server-network.rules
]; then
150 cp /etc
/udev
/rules.d
/29-ct-server-network.rules
/tmp
/
152 cp /etc
/udev
/rules.d
/30-persistent-network.rules
/tmp
/
155 mkdir
-p /etc
/udev
/rules.d
156 if [ -e /tmp
/rules.d
/29-ct-server-network.rules
]; then
157 mv /tmp
/29-ct-server-network.rules
/etc
/udev
/rules.d
/
159 mv /tmp
/30-persistent-network.rules
/etc
/udev
/rules.d
/
166 cp -vf /boot
/grub
/grub.conf
/boot
/grub
/grub.conf.org
171 /etc
/init.d
/snort stop
172 /etc
/init.d
/squid stop
173 /etc
/init.d
/ipsec stop
174 /etc
/init.d
/apache stop
177 #Remove old snort, zoneinfo and ncurses-libs(wrong path).
179 rm -rf /usr
/lib
/snort_
*
180 rm -rf /usr
/share
/zoneinfo
181 rm -rf /lib
/libncurses
*
183 # Remove old pluto binaries.
184 rm -f /usr
/libexec
/ipsec
/{pluto
,_pluto_adns
,whack
}
185 rm -f /usr
/local
/bin
/vpn-watch
189 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p --numeric-owner -C /
191 # Check diskspace on boot
192 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
194 if [ $BOOTSPACE -lt 1000 ]; then
197 # Special handling for old kirkwood images.
198 # (install only kirkwood kernel)
200 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p \
201 --numeric-owner -C / --wildcards 'boot/*-kirkwood*'
204 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
205 "core-update-$core: FATAL-ERROR space run out on boot. System is not bootable..."
206 /etc
/init.d
/apache start
213 #Reload init to close old linker/glibc
216 # Regenerate ipsec configuration files.
217 /srv
/web
/ipfire
/cgi-bin
/vpnmain.cgi
219 # Convert OpenVPN RW connections.
220 /usr
/sbin
/ovpn-ccd-convert
222 touch /var
/ipfire
/ovpn
/ccd.conf
223 touch /var
/ipfire
/ovpn
/ccdroute
224 touch /var
/ipfire
/ovpn
/ccdroute2
225 chown nobody
:nobody
/var
/ipfire
/ovpn
/ccd.conf
226 chown nobody
:nobody
/var
/ipfire
/ovpn
/ccdroute
227 chown nobody
:nobody
/var
/ipfire
/ovpn
/ccdroute2
230 sed -i /var
/spool
/cron
/root.orig \
231 -e 's@^.*fcron.weekly.*$@\&nice(10),bootrun 47 2 \* \* 1\ttest -x /usr/local/bin/run-parts \&\& /usr/local/bin/run-parts /etc/fcron.weekly@'
232 fcrontab
-z &>/dev
/null
237 /etc
/init.d
/apache start
238 /etc
/init.d
/squid start
239 /etc
/init.d
/snort start
240 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
241 /etc
/init.d
/ipsec start
245 # Rebuild qosscript if enabled
247 if [ -e /var
/ipfire
/qos
/enable ]; then
248 /usr
/local
/bin
/qosctrl stop
249 /usr
/local
/bin
/qosctrl generate
250 /usr
/local
/bin
/qosctrl start
253 # Remove preloading libsafe.
254 rm -f /etc
/ld.so.preload
262 echo Update grub configuration ...
263 ROOT
=`mount | grep " / " | cut -d" " -f1`
265 if [ ! -z $ROOT ]; then
266 ROOTUUID
=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
269 if [ ! -z $ROOTUUID ]; then
270 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot
/grub
/grub.conf
272 sed -i "s|ROOT|$ROOT|g" /boot
/grub
/grub.conf
274 sed -i "s|KVER|$KVER|g" /boot
/grub
/grub.conf
275 sed -i "s|MOUNT|$MOUNT|g" /boot
/grub
/grub.conf
277 if [ "$(grep "^serial
" /boot/grub/grub.conf.org)" == "" ]; then
278 echo "grub use default console ..."
280 echo "grub use serial console ..."
281 sed -i -e "s|splashimage|#splashimage|g" /boot
/grub
/grub.conf
282 sed -i -e "s|#serial|serial|g" /boot
/grub
/grub.conf
283 sed -i -e "s|#terminal|terminal|g" /boot
/grub
/grub.conf
284 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" /boot
/grub
/grub.conf
290 grub-install
--no-floppy ${ROOT::`expr length $ROOT`-1}
294 # Delete old lm-sensor modullist to force search at next boot
296 rm -rf /etc
/sysconfig
/lm_sensors
299 # Remove powerbutton loop from rc local.
301 sed -i "/# power button shutdown/,+3d" /etc
/sysconfig
/rc.
local
304 #Update Language cache
305 perl
-e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
308 # Remove meta's of packages that are now common...
310 rm -rf /opt
/pakfire
/db
/*/meta-fontconfig
311 rm -rf /opt
/pakfire
/db
/*/meta-glib
313 # Force (re)install pae kernel if pae is supported
314 rm -rf /opt
/pakfire
/db
/*/meta-linux-pae
315 if [ ! "$(grep "^flags.
* pae
" /proc/cpuinfo)" == "" ]; then
316 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
317 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
318 if [ $BOOTSPACE -lt 8000 -o $ROOTSPACE -lt 70000 ]; then
319 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
320 "core-update-$core: WARNING not enough space for pae kernel."
322 echo "Name: linux-pae" > /opt
/pakfire
/db
/installed
/meta-linux-pae
323 echo "ProgVersion: 3.2.37" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
324 echo "Release: 26" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
328 # Force reinstall xen kernel if it was installed
329 if [ -e "/opt/pakfire/db/installed/meta-linux-xen" ]; then
330 echo "Name: linux-xen" > /opt
/pakfire
/db
/installed
/meta-linux-xen
331 echo "ProgVersion: 2.6.32.60" >> /opt
/pakfire
/db
/installed
/meta-linux-xen
332 echo "Release: 24" >> /opt
/pakfire
/db
/installed
/meta-linux-xen
333 # Add xvc0 to /etc/securetty
334 echo "xvc0" >> /etc
/securetty
338 # After pakfire has ended run it again and update the lists and do upgrade
340 echo '#!/bin/bash' > /tmp
/pak_update
341 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp
/pak_update
342 echo ' sleep 1' >> /tmp
/pak_update
343 echo 'done' >> /tmp
/pak_update
344 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp
/pak_update
345 echo ' sleep 1' >> /tmp
/pak_update
346 echo 'done' >> /tmp
/pak_update
347 echo '/opt/pakfire/pakfire update -y --force' >> /tmp
/pak_update
348 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
349 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
350 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
351 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub.cfg"' >> /tmp
/pak_update
352 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp
/pak_update
353 echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp
/pak_update
354 echo 'touch /var/run/need_reboot ' >> /tmp
/pak_update
356 chmod +x
/tmp
/pak_update
363 /etc
/init.d
/fireinfo start
367 echo Please
wait until pakfire has ended...
369 #Don't report the exitcode last command