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) 2012 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 # TODO: need to be corrected before release
41 for (( i
=1; i
<=$core; i
++ ))
43 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
47 # Do some sanity checks.
48 if [ ! "$(mount | grep " reiser4
(")" == "" ]; then
49 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
50 "core-update-$core: ERROR cannot update because there is a reiser4 fs mounted."
57 MOUNT
=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
58 # Nur den letzten Parameter verwenden
59 echo $MOUNT > /dev
/null
61 if [ ! $MOUNT == "rw" ]; then
66 # check if we the backup file already exist
67 if [ -e /var
/ipfire
/backup
/core-upgrade_
$KVER.
tar.xz
]; then
68 echo Moving backup to backup-old ...
69 mv -f /var
/ipfire
/backup
/core-upgrade_
$KVER.
tar.xz \
70 /var
/ipfire
/backup
/core-upgrade_
$KVER-old.
tar.xz
72 echo First we made a backup of all files that was inside of the
73 echo update archive. This may take a
while ...
74 # Add some files that are not in the package to backup
75 add_to_backup lib
/modules
76 add_to_backup etc
/udev
77 add_to_backup lib
/udev
79 add_to_backup etc
/snort
80 add_to_backup usr
/lib
/snort_
*
81 add_to_backup usr
/share
/zoneinfo
82 add_to_backup lib
/libncurses
*
83 add_to_backup etc
/dircolors
84 add_to_backup etc
/profile.d
85 add_to_backup usr
/share
/terminfo
86 add_to_backup etc
/sysconfig
/lm_sensors
87 add_to_backup etc
/sysconfig
/rc.
local
90 tar cJvf
/var
/ipfire
/backup
/core-upgrade_
$KVER.
tar.xz \
91 -C / -T /opt
/pakfire
/tmp
/ROOTFILES
--exclude='#*' --exclude='/var/cache' > /dev
/null
2>&1
93 # Check diskspace on root
94 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
96 if [ $ROOTSPACE -lt 70000 ]; then
97 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
98 "core-update-$core: ERROR cannot update because not enough free space on root."
103 echo Update Kernel to
$KVER ...
105 # Remove old kernel, configs, initrd, modules ...
107 rm -rf /boot
/System.map-
*
108 rm -rf /boot
/config-
*
109 rm -rf /boot
/ipfirerd-
*
110 rm -rf /boot
/vmlinuz-
*
111 rm -rf /boot
/uImage-ipfire-
*
112 rm -rf /boot
/uInit-ipfire-
*
114 rm -rf /etc
/dircolors
115 rm -rf /etc
/profile.d
116 rm -rf /usr
/share
/terminfo
119 # Remove old udev rules.
121 if [ -e /etc
/udev
/rules.d
/29-ct-server-network.rules
]; then
122 cp /etc
/udev
/rules.d
/29-ct-server-network.rules
/tmp
/
124 cp /etc
/udev
/rules.d
/30-persistent-network.rules
/tmp
/
127 mkdir
-p /etc
/udev
/rules.d
128 if [ -e /tmp
/rules.d
/29-ct-server-network.rules
]; then
129 mv /tmp
/29-ct-server-network.rules
/etc
/udev
/rules.d
/
131 mv /tmp
/30-persistent-network.rules
/etc
/udev
/rules.d
/
136 cp -vf /boot
/grub
/grub.conf
/boot
/grub
/grub.conf.org
140 /etc
/init.d
/snort stop
141 /etc
/init.d
/squid stop
142 /etc
/init.d
/ipsec stop
144 #Remove old snort, zoneinfo and ncurses-libs(wrong path).
146 rm -rf /usr
/lib
/snort_
*
147 rm -rf /usr
/share
/zoneinfo
148 rm -rf /lib
/libncurses
*
152 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p --numeric-owner -C /
157 /etc
/init.d
/squid start
158 /etc
/init.d
/snort start
159 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
160 /etc
/init.d
/ipsec start
164 # Rebuild qosscript if enabled
166 if [ -e /var
/ipfire
/qos
/enable ]; then
167 /usr
/local
/bin
/qosctrl stop
168 /usr
/local
/bin
/qosctrl generate
169 /usr
/local
/bin
/qosctrl start
172 # Remove preloading libsafe.
173 rm -f /etc
/ld.so.preload
179 echo Update grub configuration ...
180 ROOT
=`mount | grep " / " | cut -d" " -f1`
182 if [ ! -z $ROOT ]; then
183 ROOTUUID
=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
186 if [ ! -z $ROOTUUID ]; then
187 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot
/grub
/grub.conf
189 sed -i "s|ROOT|$ROOT|g" /boot
/grub
/grub.conf
191 sed -i "s|KVER|$KVER|g" /boot
/grub
/grub.conf
192 sed -i "s|MOUNT|$MOUNT|g" /boot
/grub
/grub.conf
194 if [ "$(grep "^serial
" /boot/grub/grub.conf.org)" == "" ]; then
195 echo "grub use default console ..."
197 echo "grub use serial console ..."
198 sed -i -e "s|splashimage|#splashimage|g" /boot
/grub
/grub.conf
199 sed -i -e "s|#serial|serial|g" /boot
/grub
/grub.conf
200 sed -i -e "s|#terminal|terminal|g" /boot
/grub
/grub.conf
201 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" /boot
/grub
/grub.conf
207 grub-install
--no-floppy ${ROOT::`expr length $ROOT`-1} --recheck
210 # Delete old lm-sensor modullist to force search at next boot
212 rm -rf /etc
/sysconfig
/lm_sensors
215 # Remove powerbutton loop from rc local.
217 sed -i "/# power button shutdown/,+3d" /etc
/sysconfig
/rc.
local
220 #Update Language cache
221 perl
-e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
224 # Remove meta's of packages that are now common...
226 rm -rf /opt
/pakfire
/db
/*/meta-fontconfig
227 rm -rf /opt
/pakfire
/db
/*/meta-glib
229 # Force (re)install pae kernel if pae is supported
230 rm -rf /opt
/pakfire
/db
/*/meta-linux-pae
231 if [ ! "$(grep "^flags.
* pae
" /proc/cpuinfo)" == "" ]; then
232 echo "Name: linux-pae" > /opt
/pakfire
/db
/installed
/meta-linux-pae
233 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
234 echo "Release: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
237 # Force reinstall xen kernel if it was installed
238 if [ -e "/opt/pakfire/db/installed/meta-linux-xen" ]; then
239 echo "Name: linux-xen" > /opt
/pakfire
/db
/installed
/meta-linux-xen
240 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-xen
241 echo "Release: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-xen
245 # After pakfire has ended run it again and update the lists and do upgrade
247 echo '#!/bin/bash' > /tmp
/pak_update
248 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp
/pak_update
249 echo ' sleep 1' >> /tmp
/pak_update
250 echo 'done' >> /tmp
/pak_update
251 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp
/pak_update
252 echo ' sleep 1' >> /tmp
/pak_update
253 echo 'done' >> /tmp
/pak_update
254 echo '/opt/pakfire/pakfire update -y --force' >> /tmp
/pak_update
255 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
256 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
257 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
258 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub.cfg"' >> /tmp
/pak_update
259 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp
/pak_update
260 echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp
/pak_update
261 echo 'touch /var/run/need_reboot ' >> /tmp
/pak_update
263 chmod +x
/tmp
/pak_update
270 /etc
/init.d
/fireinfo start
274 echo Please
wait until pakfire has ended...
276 #Don't report the exitcode last command