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 for (( i
=1; i
<=$core; i
++ ))
41 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
45 # Do some sanity checks.
47 if [ "$(grep " xavf
" /opt/pakfire/lib/functions.sh)" == "" ]; then
48 /usr
/bin
/logger
-p syslog.emerg
-t core-upgrade-
$core \
49 "ERROR: this update need a newer pakfire version (core64)."
52 if [ ! "$(mount | grep " reiser4
(")" == "" ]; then
53 /usr
/bin
/logger
-p syslog.emerg
-t core-upgrade-
$core \
54 "ERROR: cannot update because there is a reiser4 fs mounted."
61 MOUNT
=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
62 # Nur den letzten Parameter verwenden
63 echo $MOUNT > /dev
/null
65 if [ ! $MOUNT == "rw" ]; then
70 # check if we the backup file already exist
71 if [ -e /var
/ipfire
/backup
/core-upgrade_
$KVER.
tar.xz
]; then
72 echo Moving backup to backup-old ...
73 mv -f /var
/ipfire
/backup
/core-upgrade_
$KVER.
tar.xz \
74 /var
/ipfire
/backup
/core-upgrade_
$KVER-old.
tar.xz
76 echo First we made a backup of all files that was inside of the
77 echo update archive. This may take a
while ...
78 # Add some files that are not in the package to backup
79 add_to_backup lib
/modules
80 add_to_backup etc
/udev
81 add_to_backup lib
/udev
83 add_to_backup etc
/snort
84 add_to_backup usr
/lib
/snort_
*
85 add_to_backup usr
/share
/zoneinfo
86 add_to_backup lib
/libncurses
*
87 add_to_backup etc
/dircolors
88 add_to_backup etc
/profile.d
89 add_to_backup usr
/share
/terminfo
93 tar cJvf
/var
/ipfire
/backup
/core-upgrade_
$KVER.
tar.xz \
94 -C / -T /opt
/pakfire
/tmp
/ROOTFILES
--exclude='#*' --exclude='/var/cache' > /dev
/null
2>&1
97 echo Update Kernel to
$KVER ...
99 # Remove old kernel, configs, initrd, modules ...
101 rm -rf /boot
/System.map-
*
102 rm -rf /boot
/config-
*
103 rm -rf /boot
/ipfirerd-
*
104 rm -rf /boot
/vmlinuz-
*
105 rm -rf /boot
/uImage-ipfire-
*
106 rm -rf /boot
/uInit-ipfire-
*
108 rm -rf /etc
/dircolors
109 rm -rf /etc
/profile.d
110 rm -rf /usr
/share
/terminfo
113 # Remove old udev rules.
115 if [ -e /etc
/udev
/rules.d
/29-ct-server-network.rules
]; then
116 cp /etc
/udev
/rules.d
/29-ct-server-network.rules
/tmp
/
118 cp /etc
/udev
/rules.d
/30-persistent-network.rules
/tmp
/
121 mkdir
-p /etc
/udev
/rules.d
122 if [ -e /tmp
/rules.d
/29-ct-server-network.rules
]; then
123 mv /tmp
/29-ct-server-network.rules
/etc
/udev
/rules.d
/
125 mv /tmp
/30-persistent-network.rules
/etc
/udev
/rules.d
/
130 cp -vf /boot
/grub
/grub.conf
/boot
/grub
/grub.conf.org
134 /etc
/init.d
/snort stop
135 /etc
/init.d
/squid stop
136 /etc
/init.d
/ipsec stop
138 #Remove old snort, zoneinfo and ncurses-libs(wrong path).
140 rm -rf /usr
/lib
/snort_
*
141 rm -rf /usr
/share
/zoneinfo
142 rm -rf /lib
/libncurses
*
151 /etc
/init.d
/squid start
152 /etc
/init.d
/snort start
153 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
154 /etc
/init.d
/ipsec start
158 # Rebuild qosscript if enabled
160 if [ -e /var
/ipfire
/qos
/enable ]; then
161 /usr
/local
/bin
/qosctrl stop
162 /usr
/local
/bin
/qosctrl generate
163 /usr
/local
/bin
/qosctrl start
170 echo Update grub configuration ...
171 ROOT
=`mount | grep " / " | cut -d" " -f1`
173 if [ ! -z $ROOT ]; then
174 ROOTUUID
=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
177 if [ ! -z $ROOTUUID ]; then
178 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot
/grub
/grub.conf
180 sed -i "s|ROOT|$ROOT|g" /boot
/grub
/grub.conf
182 sed -i "s|KVER|$KVER|g" /boot
/grub
/grub.conf
183 sed -i "s|MOUNT|$MOUNT|g" /boot
/grub
/grub.conf
185 if [ "$(grep "^serial
" /boot/grub/grub.conf.org)" == "" ]; then
186 echo "grub use default console ..."
188 echo "grub use serial console ..."
189 sed -i -e "s|splashimage|#splashimage|g" /boot
/grub
/grub.conf
190 sed -i -e "s|#serial|serial|g" /boot
/grub
/grub.conf
191 sed -i -e "s|#terminal|terminal|g" /boot
/grub
/grub.conf
192 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" /boot
/grub
/grub.conf
195 # Delete old lm-sensor modullist to force search at next boot
197 rm -rf /etc
/sysconfig
/lm_sensors
200 #Update Language cache
201 perl
-e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
204 # Remove meta's of packages that are now common...
206 rm -rf /opt
/pakfire
/db
/*/meta-fontconfig
207 rm -rf /opt
/pakfire
/db
/*/meta-glib
210 # After pakfire has ended run it again and update the lists and do upgrade
212 echo '#!/bin/bash' > /tmp
/pak_update
213 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp
/pak_update
214 echo ' sleep 1' >> /tmp
/pak_update
215 echo 'done' >> /tmp
/pak_update
216 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp
/pak_update
217 echo ' sleep 1' >> /tmp
/pak_update
218 echo 'done' >> /tmp
/pak_update
219 echo '/opt/pakfire/pakfire update -y --force' >> /tmp
/pak_update
220 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
221 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
222 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
223 echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-$core "Upgrade finished. If you use a customized grub.cfg"' >> /tmp
/pak_update
224 echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-$core "Check it before reboot !!!"' >> /tmp
/pak_update
225 echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-$core " *** Please reboot... *** "' >> /tmp
/pak_update
226 echo 'touch /var/run/need_reboot ' >> /tmp
/pak_update
228 chmod +x
/tmp
/pak_update
235 /etc
/init.d
/fireinfo start
239 echo Please
wait until pakfire has ended...
241 #Don't report the exitcode last command