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