]> git.ipfire.org Git - ipfire-2.x.git/blame - config/rootfiles/core/65/update.sh
updater: remove double files from backup.
[ipfire-2.x.git] / config / rootfiles / core / 65 / update.sh
CommitLineData
f0a4269b
AF
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) 2012 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
5e307382
AF
27function add_to_backup ()
28{
29 # Add path to ROOTFILES but remove old entries to prevent double
30 # files in the tar
31 grep -v "^$1" /opt/pakfire/tmp/ROOTFILES > /opt/pakfire/tmp/ROOTFILES.tmp
32 mv /opt/pakfire/tmp/ROOTFILES.tmp /opt/pakfire/tmp/ROOTFILES
33 echo $1 >> /opt/pakfire/tmp/ROOTFILES
34}
35
f0a4269b
AF
36#
37# Remove old core updates from pakfire cache to save space...
38core=65
39for (( i=1; i<=$core; i++ ))
40do
41 rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire
42done
43
44#
45KVER="3.2.33"
46MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
47# Nur den letzten Parameter verwenden
48echo $MOUNT > /dev/null
49MOUNT=$_
50if [ ! $MOUNT == "rw" ]; then
51 MOUNT="ro"
52fi
53
54#
55# check if we the backup file already exist
56if [ -e /var/ipfire/backup/core-upgrade_$KVER.tar.xz ]; then
57 echo Moving backup to backup-old ...
58 mv -f /var/ipfire/backup/core-upgrade_$KVER.tar.xz \
59 /var/ipfire/backup/core-upgrade_$KVER-old.tar.xz
60fi
61echo First we made a backup of all files that was inside of the
62echo update archive. This may take a while ...
63# Add some files that are not in the package to backup
5e307382
AF
64add_to_backup lib/modules
65add_to_backup etc/udev
66add_to_backup lib/udev
67add_to_backup boot
68add_to_backup etc/snort
69add_to_backup usr/lib/snort_*
70add_to_backup usr/share/zoneinfo
f0a4269b
AF
71
72# Backup the files
73tar cJvf /var/ipfire/backup/core-upgrade_$KVER.tar.xz \
74 -C / -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' --exclude='/var/cache' > /dev/null 2>&1
75
76echo
77echo Update Kernel to $KVER ...
78#
79# Remove old kernel, configs, initrd, modules ...
80#
81rm -rf /boot/System.map-*
82rm -rf /boot/config-*
83rm -rf /boot/ipfirerd-*
84rm -rf /boot/vmlinuz-*
85rm -rf /lib/modules/*-ipfire
86#
87# Remove old udev rules.
88#
5e307382
AF
89if [ -e /etc/udev/rules.d/29-ct-server-network.rules ]; then
90 cp /etc/udev/rules.d/29-ct-server-network.rules /tmp/
91fi
f0a4269b
AF
92cp /etc/udev/rules.d/30-persistent-network.rules /tmp/
93rm -rf /etc/udev
94rm -rf /lib/udev
95mkdir -p /etc/udev/rules.d
5e307382
AF
96if [ -e /tmp/rules.d/29-ct-server-network.rules ]; then
97 mv /tmp/29-ct-server-network.rules /etc/udev/rules.d/
98fi
f0a4269b
AF
99mv /tmp/30-persistent-network.rules /etc/udev/rules.d/
100
101#
102# Backup grub.conf
103#
104cp -vf /boot/grub/grub.conf /boot/grub/grub.conf.org
105
106#
107#Stop services
108/etc/init.d/snort stop
109/etc/init.d/squid stop
110/etc/init.d/ipsec stop
111
5e307382 112#Remove old snort and zoneinfo
f0a4269b
AF
113rm -rf /etc/snort
114rm -rf /usr/lib/snort_*
5e307382 115rm -rf /usr/share/zoneinfo
f0a4269b
AF
116
117#
118#Extract files
119extract_files
120
121#
122# Start services
123#
124/etc/init.d/squid start
125/etc/init.d/snort start
126if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
127 /etc/init.d/ipsec start
128fi
129
130#
131# Rebuild qosscript if enabled
132#
133if [ -e /var/ipfire/qos/enable ]; then
134 /usr/local/bin/qosctrl stop
135 /usr/local/bin/qosctrl generate
136 /usr/local/bin/qosctrl start
137fi
138
139#
140# Modify grub.conf
141#
142echo
143echo Update grub configuration ...
144ROOT=`mount | grep " / " | cut -d" " -f1`
145
146if [ ! -z $ROOT ]; then
147 ROOTUUID=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
148fi
149
150if [ ! -z $ROOTUUID ]; then
151 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot/grub/grub.conf
152else
153 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
154fi
155sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
156sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
157
158if [ "$(grep "^serial" /boot/grub/grub.conf.org)" == "" ]; then
159 echo "grub use default console ..."
160else
161 echo "grub use serial console ..."
162 sed -i -e "s|splashimage|#splashimage|g" /boot/grub/grub.conf
163 sed -i -e "s|#serial|serial|g" /boot/grub/grub.conf
164 sed -i -e "s|#terminal|terminal|g" /boot/grub/grub.conf
165 sed -i -e "s| panic=10 | console=ttyS0,38400n8 panic=10 |g" /boot/grub/grub.conf
166fi
167#
168# Delete old lm-sensor modullist to force search at next boot
169#
170rm -rf /etc/sysconfig/lm_sensors
171
172#
173#Update Language cache
174perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
175
176#
177# Remove meta's of packages that are now common...
178#
179rm -rf /opt/pakfire/db/*/meta-fontconfig
180rm -rf /opt/pakfire/db/*/meta-glib
181
182#
183# After pakfire has ended run it again and update the lists and do upgrade
184#
185echo '#!/bin/bash' > /tmp/pak_update
186echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update
187echo ' sleep 1' >> /tmp/pak_update
188echo 'done' >> /tmp/pak_update
189echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update
190echo ' sleep 1' >> /tmp/pak_update
191echo 'done' >> /tmp/pak_update
192echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update
193echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
194echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
195echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
196echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-65 "Upgrade finished. If you use a customized grub.cfg"' >> /tmp/pak_update
197echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-65 "Check it before reboot !!!"' >> /tmp/pak_update
198echo '/usr/bin/logger -p syslog.emerg -t core-upgrade-65 " *** Please reboot... *** "' >> /tmp/pak_update
199echo 'touch /var/run/need_reboot ' >> /tmp/pak_update
200#
201chmod +x /tmp/pak_update
202/tmp/pak_update &
203
204sync
205
206#
207#Finish
208/etc/init.d/fireinfo start
209sendprofile
210
211echo
212echo Please wait until pakfire has ended...
213echo
214#Don't report the exitcode last command
215exit 0
216