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) 2014 IPFire-Team <info@ipfire.org>. #
22 ############################################################################
24 .
/opt
/pakfire
/lib
/functions.sh
25 /usr
/local
/bin
/backupctrl exclude
>/dev
/null
2>&1
28 # Remove old core updates from pakfire cache to save space...
30 for (( i
=1; i
<=${core}; i
++ ))
32 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
36 # Do some sanity checks.
39 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
40 "core-update-${core}: ERROR cannot update. versatile support is dropped."
41 # Report no error to pakfire. So it does not try to install it again.
48 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
49 "core-update-${core}: ERROR cannot update. No IPFire Kernel."
59 # Check diskspace on root
60 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
62 if [ $ROOTSPACE -lt 100000 ]; then
63 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
64 "core-update-${core}: ERROR cannot update because not enough free space on root."
70 echo Update Kernel to
$KVER ...
72 # Remove old kernel, configs, initrd, modules, dtb's ...
74 rm -rf /boot
/System.map-
*
76 rm -rf /boot
/ipfirerd-
*
77 rm -rf /boot
/initramfs-
*
78 rm -rf /boot
/vmlinuz-
*
79 rm -rf /boot
/uImage-ipfire-
*
80 rm -rf /boot
/uInit-ipfire-
*
81 rm -rf /boot
/dtb-
*-ipfire-*
86 # Backup old grub config
87 if [ -f /boot
/grub
/grub.conf
]; then
88 cp -vf /boot
/grub
/grub.conf
/boot
/old-grub-config
90 if [ -f /boot
/grub
/menu.lst
]; then
91 cp -vf /boot
/grub
/menu.lst
/boot
/old-grub-config
93 if [ -f /boot
/grub
/grub.cfg
]; then
94 cp -vf /boot
/grub
/grub.cfg
/boot
/old-grub-config
97 # Remove all files that belong to GRUB-legacy
101 # Backup uEnv.txt if exist
102 if [ -e /boot
/uEnv.txt
]; then
103 cp -vf /boot
/uEnv.txt
/boot
/uEnv.txt.org
106 # work around the u-boot folder detection bug
107 mkdir
-pv /boot
/dtb-
$KVER-ipfire-kirkwood
108 mkdir
-pv /boot
/dtb-
$KVER-ipfire-multi
114 /etc
/init.d
/snort stop
115 /etc
/init.d
/squid stop
116 /etc
/init.d
/ipsec stop
117 /etc
/init.d
/apache stop
121 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p --numeric-owner -C /
124 #restart init because glibc was updated.
127 # Check diskspace on boot
128 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
130 if [ $BOOTSPACE -lt 1000 ]; then
133 # Special handling for old kirkwood images.
134 # (install only kirkwood kernel)
136 # work around the u-boot folder detection bug
137 mkdir
-pv /boot
/dtb-
$KVER-ipfire-kirkwood
138 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p \
139 --numeric-owner -C / --wildcards 'boot/*-kirkwood*'
142 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
143 "core-update-${core}: FATAL-ERROR space run out on boot. System is not bootable..."
144 /etc
/init.d
/apache start
150 # Update Language cache
151 perl
-e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
153 # Add nobody to group dialout
154 usermod
-a -G dialout nobody
159 /etc
/init.d
/apache start
160 /etc
/init.d
/squid start
161 /etc
/init.d
/snort start
162 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
163 /etc
/init.d
/ipsec start
166 case "$(uname -m)" in
172 echo Update grub configuration ...
173 if grep -qE "^serial" /boot
/old-grub-config
; then
174 sed -i /etc
/default
/grub \
175 -e "s|panic=10|& console=ttyS0,115200n8|g"
176 echo "GRUB_TERMINAL=\"serial\"" >> /etc
/default
/grub
177 echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc
/default
/grub
180 if ! /usr
/local
/bin
/update-bootloader
; then
181 logger
-p syslog.emerg
-t ipfire \
182 "Could not update the bootloader!"
187 # Force (re)install pae kernel if pae is supported
188 rm -rf /opt
/pakfire
/db
/*/meta-linux-pae
189 if [ ! "$(grep "^flags.
* pae
" /proc/cpuinfo)" == "" ]; then
190 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
191 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
192 if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then
193 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
194 "core-update-${core}: WARNING not enough space for pae kernel."
196 echo "Name: linux-pae" > /opt
/pakfire
/db
/installed
/meta-linux-pae
197 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
198 echo "Release: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
199 echo "Name: linux-pae" > /opt
/pakfire
/db
/meta
/meta-linux-pae
200 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/meta
/meta-linux-pae
201 echo "Release: 0" >> /opt
/pakfire
/db
/meta
/meta-linux-pae
206 # After pakfire has ended run it again and update the lists and do upgrade
208 echo '#!/bin/bash' > /tmp
/pak_update
209 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp
/pak_update
210 echo ' sleep 1' >> /tmp
/pak_update
211 echo 'done' >> /tmp
/pak_update
212 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp
/pak_update
213 echo ' sleep 1' >> /tmp
/pak_update
214 echo 'done' >> /tmp
/pak_update
215 echo '/opt/pakfire/pakfire update -y --force' >> /tmp
/pak_update
216 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
217 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
218 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
219 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub/uboot config"' >> /tmp
/pak_update
220 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp
/pak_update
221 echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp
/pak_update
222 echo 'touch /var/run/need_reboot ' >> /tmp
/pak_update
224 killall
-KILL pak_update
225 chmod +x
/tmp
/pak_update
233 /etc
/init.d
/fireinfo start
237 # Update Package list for addon installation
238 /opt
/pakfire
/pakfire update
-y --force
241 echo Please
wait until pakfire has ended...
244 # Don't report the exitcode last command