]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/rootfiles/core/107/update.sh
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) 2016 IPFire-Team <info@ipfire.org>. #
22 ############################################################################
24 .
/opt
/pakfire
/lib
/functions.sh
25 /usr
/local
/bin
/backupctrl exclude
>/dev
/null
2>&1
27 function find_device
() {
28 local mountpoint
="${1}"
31 local dev mp fs flags rest
32 while read -r dev mp fs flags rest
; do
33 # Skip unwanted entries
34 [ "${dev}" = "rootfs" ] && continue
36 if [ "${mp}" = "${mountpoint}" ] && [ -b "${dev}" ]; then
37 root
="$(basename "${dev}")"
42 # Get the actual device from the partition that holds /
43 while [ -n "${root}" ]; do
44 if [ -e "/sys/block/${root}" ]; then
49 # Remove last character
59 function exit_with_error
() {
60 # Set last succesfull installed core.
61 echo $
(($core-1)) > /opt
/pakfire
/db
/core
/mine
62 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
63 "core-update-${core}: $1"
67 # Remove old core updates from pakfire cache to save space...
68 for (( i
=1; i
<=$core; i
++ ))
70 rm -f /var
/cache
/pakfire
/core-upgrade-
*-$i.ipfire
74 # Do some sanity checks.
80 exit_with_error
"ERROR cannot update. No IPFire Kernel." 1
89 # Check diskspace on root
90 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
92 if [ $ROOTSPACE -lt 100000 ]; then
93 exit_with_error
"ERROR cannot update because not enough free space on root." 2
98 echo Update Kernel to
$KVER ...
100 # Remove old kernel, configs, initrd, modules, dtb's ...
102 rm -rf /boot
/System.map-
*
103 rm -rf /boot
/config-
*
104 rm -rf /boot
/ipfirerd-
*
105 rm -rf /boot
/initramfs-
*
106 rm -rf /boot
/vmlinuz-
*
107 rm -rf /boot
/uImage-ipfire-
*
108 rm -rf /boot
/zImage-ipfire-
*
109 rm -rf /boot
/uInit-ipfire-
*
110 rm -rf /boot
/dtb-
*-ipfire-*
113 case "$(uname -m)" in
115 # Backup uEnv.txt if exist
116 if [ -e /boot
/uEnv.txt
]; then
117 cp -vf /boot
/uEnv.txt
/boot
/uEnv.txt.org
120 # work around the u-boot folder detection bug
121 mkdir
-pv /boot
/dtb-
$KVER-ipfire-kirkwood
122 mkdir
-pv /boot
/dtb-
$KVER-ipfire-multi
123 touch /boot
/uImage-ipfire-kirkwood
124 touch /boot
/zImage-ipfire-multi
125 touch /boot
/uIinit-ipfire-kirkwood
126 touch /boot
/uIinit-ipfire-multi
131 /etc
/init.d
/collectd stop
132 /etc
/init.d
/snort stop
133 /etc
/init.d
/squid stop
134 /etc
/init.d
/ipsec stop
135 /etc
/init.d
/apache stop
138 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p --numeric-owner -C /
140 # Remove some old files
141 rm -f /etc
/unbound
/interfaces.conf
143 # update linker config
146 # Check diskspace on boot
147 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
149 if [ $BOOTSPACE -lt 1000 ]; then
152 # Special handling for old kirkwood images.
153 # (install only kirkwood kernel)
155 # work around the u-boot folder detection bug
156 mkdir
-pv /boot
/dtb-
$KVER-ipfire-kirkwood
157 tar xavf
/opt
/pakfire
/tmp
/files
* --no-overwrite-dir -p \
158 --numeric-owner -C / --wildcards 'boot/*-kirkwood*'
161 /etc
/init.d
/apache start
162 exit_with_error
"FATAL-ERROR space run out on boot. System is not bootable..." 4
167 # Update Language cache
168 /usr
/local
/bin
/update-lang-cache
173 /etc
/init.d
/collectd start
174 /etc
/init.d
/apache start
175 /etc
/init.d
/squid start
176 /etc
/init.d
/snort start
177 if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
178 /etc
/init.d
/ipsec start
181 # Restart unbound to activate configuration changes
182 /etc
/init.d
/unbound restart
184 # Delete old QoS enabled indicator
185 rm -f /var
/ipfire
/qos
/enable
187 # Upadate Kernel version uEnv.txt
188 if [ -e /boot
/uEnv.txt
]; then
189 sed -i -e "s/KVER=.*/KVER=${KVER}/g" /boot
/uEnv.txt
192 # call user update script (needed for some arm boards)
193 if [ -e /boot
/pakfire-kernel-update
]; then
194 /boot
/pakfire-kernel-update
${KVER}
197 case "$(uname -m)" in
199 # Force (re)install pae kernel if pae is supported
200 rm -rf /opt
/pakfire
/db
/installed
/meta-linux-pae
201 if [ ! "$(grep "^flags.
* pae
" /proc/cpuinfo)" == "" ]; then
202 ROOTSPACE
=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
203 BOOTSPACE
=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
204 if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then
205 /usr
/bin
/logger
-p syslog.emerg
-t ipfire \
206 "core-update-${core}: WARNING not enough space for pae kernel."
208 echo "Name: linux-pae" > /opt
/pakfire
/db
/installed
/meta-linux-pae
209 echo "ProgVersion: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
210 echo "Release: 0" >> /opt
/pakfire
/db
/installed
/meta-linux-pae
216 # After pakfire has ended run it again and update the lists and do upgrade
218 echo '#!/bin/bash' > /tmp
/pak_update
219 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp
/pak_update
220 echo ' sleep 1' >> /tmp
/pak_update
221 echo 'done' >> /tmp
/pak_update
222 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp
/pak_update
223 echo ' sleep 1' >> /tmp
/pak_update
224 echo 'done' >> /tmp
/pak_update
225 echo '/opt/pakfire/pakfire update -y --force' >> /tmp
/pak_update
226 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
227 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
228 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp
/pak_update
229 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub/uboot config"' >> /tmp
/pak_update
230 echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp
/pak_update
231 echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp
/pak_update
232 echo 'touch /var/run/need_reboot ' >> /tmp
/pak_update
234 killall
-KILL pak_update
235 chmod +x
/tmp
/pak_update
240 # This update need a reboot...
241 touch /var
/run
/need_reboot
244 /etc
/init.d
/fireinfo start
246 # Update grub config to display new core version
247 if [ -e /boot
/grub
/grub.cfg
]; then
248 grub-mkconfig
-o /boot
/grub
/grub.cfg
252 # Don't report the exitcode last command