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 function find_device
() {
29 local mountpoint
="${1}"
32 local dev mp fs flags rest
33 while read -r dev mp fs flags rest
; do
34 # Skip unwanted entries
35 [ "${dev}" = "rootfs" ] && continue
37 if [ "${mp}" = "${mountpoint}" ] && [ -b "${dev}" ]; then
38 root
="$(basename "${dev}")"
43 # Get the actual device from the partition that holds /
44 while [ -n "${root}" ]; do
45 if [ -e "/sys/block/${root}" ]; then
50 # Remove last character
59 # Remove old core updates from pakfire cache to save space...
61 for (( i
=1; i
<=${core}; i
++ ))
63 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
67 # Do some sanity checks.
70 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
71 "core-update-${core}: ERROR cannot update. versatile support is dropped."
72 # Report no error to pakfire. So it does not try to install it again.
79 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
80 "core-update-${core}: ERROR cannot update. No IPFire Kernel."
90 # Check diskspace on root
91 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
93 if [ $ROOTSPACE -lt 100000 ]; then
94 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
95 "core-update-${core}: ERROR cannot update because not enough free space on root."
101 echo Update Kernel to
$KVER ...
103 # Remove old kernel, configs, initrd, modules, dtb's ...
105 rm -rf /boot
/System.map-
*
106 rm -rf /boot
/config-
*
107 rm -rf /boot
/ipfirerd-
*
108 rm -rf /boot
/initramfs-
*
109 rm -rf /boot
/vmlinuz-
*
110 rm -rf /boot
/uImage-ipfire-
*
111 rm -rf /boot
/uInit-ipfire-
*
112 rm -rf /boot
/dtb-
*-ipfire-*
115 case "$(uname -m)" in
117 # Backup old grub config
118 if [ -f /boot
/grub
/grub.conf
]; then
119 cp -vf /boot
/grub
/grub.conf
/boot
/old-grub-config
121 if [ -f /boot
/grub
/menu.lst
]; then
122 cp -vf /boot
/grub
/menu.lst
/boot
/old-grub-config
124 if [ -f /boot
/grub
/grub.cfg
]; then
125 cp -vf /boot
/grub
/grub.cfg
/boot
/old-grub-config
128 # Remove all files that belong to GRUB-legacy
132 # Backup uEnv.txt if exist
133 if [ -e /boot
/uEnv.txt
]; then
134 cp -vf /boot
/uEnv.txt
/boot
/uEnv.txt.org
137 # work around the u-boot folder detection bug
138 mkdir
-pv /boot
/dtb-
$KVER-ipfire-kirkwood
139 mkdir
-pv /boot
/dtb-
$KVER-ipfire-multi
145 /etc
/init.d
/snort stop
146 /etc
/init.d
/squid stop
147 /etc
/init.d
/ipsec stop
148 /etc
/init.d
/apache stop
152 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p --numeric-owner -C /
155 #restart init because glibc was updated.
158 # Check diskspace on boot
159 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
161 if [ $BOOTSPACE -lt 1000 ]; then
164 # Special handling for old kirkwood images.
165 # (install only kirkwood kernel)
167 # work around the u-boot folder detection bug
168 mkdir
-pv /boot
/dtb-
$KVER-ipfire-kirkwood
169 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p \
170 --numeric-owner -C / --wildcards 'boot/*-kirkwood*'
173 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
174 "core-update-${core}: FATAL-ERROR space run out on boot. System is not bootable..."
175 /etc
/init.d
/apache start
181 # Update Language cache
182 perl
-e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
184 # Add nobody to group dialout
185 usermod
-a -G dialout nobody
190 /etc
/init.d
/apache start
191 /etc
/init.d
/squid start
192 /etc
/init.d
/snort start
193 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
194 /etc
/init.d
/ipsec start
197 case "$(uname -m)" in
199 case "$(find_device "/")" in
201 echo Skip remove grub2 files
, because pygrub fail.
203 echo config will recreated by linux-pae
install.
210 echo Update grub configuration ...
211 if grep -qE "^serial" /boot
/old-grub-config
; then
212 sed -i /etc
/default
/grub \
213 -e "s|panic=10|& console=ttyS0,115200n8|g"
214 echo "GRUB_TERMINAL=\"serial\"" >> /etc
/default
/grub
215 echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc
/default
/grub
218 if ! /usr
/local
/bin
/update-bootloader
; then
219 logger
-p syslog.emerg
-t ipfire \
220 "Could not update the bootloader!"
226 # Force (re)install pae kernel if pae is supported
227 rm -rf /opt
/pakfire
/db
/*/meta-linux-pae
228 if [ ! "$(grep "^flags.
* pae
" /proc/cpuinfo)" == "" ]; then
229 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
230 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
231 if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then
232 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
233 "core-update-${core}: WARNING not enough space for pae kernel."
235 echo "Name: linux-pae" > /opt
/pakfire
/db
/installed
/meta-linux-pae
236 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
237 echo "Release: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
238 echo "Name: linux-pae" > /opt
/pakfire
/db
/meta
/meta-linux-pae
239 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/meta
/meta-linux-pae
240 echo "Release: 0" >> /opt
/pakfire
/db
/meta
/meta-linux-pae
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/uboot config"' >> /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 killall
-KILL pak_update
264 chmod +x
/tmp
/pak_update
272 /etc
/init.d
/fireinfo start
276 # Update Package list for addon installation
277 /opt
/pakfire
/pakfire update
-y --force
280 echo Please
wait until pakfire has ended...
283 # Don't report the exitcode last command