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