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