]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - config/rootfiles/core/86/update.sh
core87: remove linux-xen code from updater.
[people/pmueller/ipfire-2.x.git] / config / rootfiles / core / 86 / update.sh
CommitLineData
c172d453
MT
1#!/bin/bash
2############################################################################
3# #
4# This file is part of the IPFire Firewall. #
5# #
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. #
10# #
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. #
15# #
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 #
19# #
20# Copyright (C) 2014 IPFire-Team <info@ipfire.org>. #
21# #
22############################################################################
23#
24. /opt/pakfire/lib/functions.sh
25/usr/local/bin/backupctrl exclude >/dev/null 2>&1
26
77642396 27#
c172d453
MT
28# Remove old core updates from pakfire cache to save space...
29core=86
77642396 30for (( i=1; i<=${core}; i++ ))
c172d453
MT
31do
32 rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire
33done
34
77642396
MT
35#
36# Do some sanity checks.
37case $(uname -r) in
38 *-ipfire-versatile )
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.
42 exit 0
43 ;;
44 *-ipfire* )
45 # Ok.
46 ;;
47 * )
48 /usr/bin/logger -p syslog.emerg -t ipfire \
49 "core-update-${core}: ERROR cannot update. No IPFire Kernel."
50 exit 1
51 ;;
52esac
c172d453 53
c172d453 54
77642396
MT
55#
56#
57KVER="xxxKVERxxx"
c172d453 58
77642396
MT
59# Check diskspace on root
60ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
61
62if [ $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."
65 exit 2
66fi
67
68
69echo
70echo Update Kernel to $KVER ...
71#
40a8ea81 72# Remove old kernel, configs, initrd, modules, dtb's ...
77642396
MT
73#
74rm -rf /boot/System.map-*
75rm -rf /boot/config-*
76rm -rf /boot/ipfirerd-*
2b94001c 77rm -rf /boot/initramfs-*
77642396
MT
78rm -rf /boot/vmlinuz-*
79rm -rf /boot/uImage-ipfire-*
80rm -rf /boot/uInit-ipfire-*
40a8ea81 81rm -rf /boot/dtb-*-ipfire-*
77642396
MT
82rm -rf /lib/modules
83
84case "$(uname -m)" in
85 i?86)
86 # Backup grub.conf
87 cp -vf /boot/grub/grub.conf /boot/grub-legacy.conf
88
89 # Remove all files that belong to GRUB-legacy
90 rm -rfv /boot/grub
91 ;;
92esac
40a8ea81
AF
93# Backup uEnv.txt if exist
94if [ -e /boot/uEnv.txt ]; then
95 cp -vf /boot/uEnv.txt /boot/uEnv.txt.org
96fi
97
77642396
MT
98#
99#Stop services
100/etc/init.d/snort stop
101/etc/init.d/squid stop
102/etc/init.d/ipsec stop
103/etc/init.d/apache stop
104
105#
106#Extract files
107tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p --numeric-owner -C /
108
bbdd37b1
AF
109#
110#restart init because glibc was updated.
75f3abe2 111telinit u
bbdd37b1 112
77642396
MT
113# Check diskspace on boot
114BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
115
116if [ $BOOTSPACE -lt 1000 ]; then
117 case $(uname -r) in
118 *-ipfire-kirkwood )
119 # Special handling for old kirkwood images.
120 # (install only kirkwood kernel)
121 rm -rf /boot/*
122 tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p \
123 --numeric-owner -C / --wildcards 'boot/*-kirkwood*'
124 ;;
125 * )
126 /usr/bin/logger -p syslog.emerg -t ipfire \
127 "core-update-${core}: FATAL-ERROR space run out on boot. System is not bootable..."
128 /etc/init.d/apache start
129 exit 4
130 ;;
131 esac
132fi
c172d453
MT
133
134# Update Language cache
135perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
136
77642396
MT
137# Add nobody to group dialout
138usermod -a -G dialout nobody
139
140#
141# Start services
142#
143/etc/init.d/apache start
144/etc/init.d/squid start
145/etc/init.d/snort start
146if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
147 /etc/init.d/ipsec start
148fi
149
150case "$(uname -m)" in
151 i?86)
152 #
153 # Update to GRUB2
154 #
155 echo
156 echo Update grub configuration ...
157 if grep -qE "^serial" /boot/grub-legacy.conf; then
158 sed -i /etc/default/grub \
159 -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g"
160 echo "GRUB_TERMINAL=\"serial\"" >> /etc/default/grub
161 echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub
162 fi
77642396 163
ff3bae7b
MT
164 if ! /usr/local/bin/update-bootloader; then
165 logger -p syslog.emerg -t ipfire \
166 "Could not update the bootloader!"
77642396
MT
167 fi
168 ;;
169esac
170
171# Force (re)install pae kernel if pae is supported
172rm -rf /opt/pakfire/db/*/meta-linux-pae
173if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then
174 ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
175 BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
176 if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then
177 /usr/bin/logger -p syslog.emerg -t ipfire \
178 "core-update-${core}: WARNING not enough space for pae kernel."
179 else
180 echo "Name: linux-pae" > /opt/pakfire/db/installed/meta-linux-pae
181 echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-pae
182 echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-pae
183 echo "Name: linux-pae" > /opt/pakfire/db/meta/meta-linux-pae
184 echo "ProgVersion: 0" >> /opt/pakfire/db/meta/meta-linux-pae
185 echo "Release: 0" >> /opt/pakfire/db/meta/meta-linux-pae
c172d453
MT
186 fi
187fi
188
77642396
MT
189#
190# After pakfire has ended run it again and update the lists and do upgrade
191#
192echo '#!/bin/bash' > /tmp/pak_update
193echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update
194echo ' sleep 1' >> /tmp/pak_update
195echo 'done' >> /tmp/pak_update
196echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update
197echo ' sleep 1' >> /tmp/pak_update
198echo 'done' >> /tmp/pak_update
199echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update
200echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
201echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
202echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
a5b2c823 203echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub/uboot config"' >> /tmp/pak_update
77642396
MT
204echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp/pak_update
205echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp/pak_update
206echo 'touch /var/run/need_reboot ' >> /tmp/pak_update
207#
208killall -KILL pak_update
209chmod +x /tmp/pak_update
210/tmp/pak_update &
211
c172d453
MT
212sync
213
77642396
MT
214#
215#Finish
216(
217 /etc/init.d/fireinfo start
218 sendprofile
219) >/dev/null 2>&1 &
220
221# Update Package list for addon installation
222/opt/pakfire/pakfire update -y --force
c172d453 223
77642396
MT
224echo
225echo Please wait until pakfire has ended...
226echo
c172d453
MT
227
228# Don't report the exitcode last command
229exit 0