]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/bin/bash |
2 | ||
3 | UPGRADEVERSION="1.4.7" | |
4 | PREVIOUSVERSION="1.4.6" | |
5 | echo "This is the $UPGRADEVERSION update patch for IPCop $PREVIOUSVERSION installing." | |
6 | ||
7 | CURRENTVERSION=`perl -e "require '/var/ipcop/general-functions.pl';print \\$General::version;"` | |
8 | if [ "$CURRENTVERSION" != "$PREVIOUSVERSION" ]; then | |
9 | echo "You are not running IPCop v$PREVIOUSVERSION for this patch to install." | |
10 | echo "Aborting installation." | |
11 | exit -1 | |
12 | fi | |
13 | ||
14 | KVER=`uname -r` | |
15 | ||
16 | #we could have supported removing the 'not running' kernel but it will be much harder with each new kernel | |
17 | #so be simple and update only from the last one | |
18 | if [ "$KVER" = "2.4.27" -o "$KVER" = "2.4.27-smp" ]; then | |
19 | echo "Kernel-2.4.29 is required to install this update" | |
20 | echo "Old kernel 2.4.27 need to be removed to make place for kernel 2.4.31" | |
21 | exit 1 | |
22 | fi | |
23 | #cleanup /boot/grub of unused files (necessary for flash with only 5Mb on /boot) | |
24 | rm -f /boot/grub/{fat,ffs,iso9660,jfs,vstafs,minix,reiserfs,ufs2,xfs}_stage1_5 \ | |
25 | /boot/grub/stage2_eltorito \ | |
26 | /boot/grub/{scsigrub.conf,grubbatch} | |
27 | ||
28 | #suppress the kernel not in use to make place for a new kernel | |
29 | rm -rf /lib/modules/2.4.27{,-smp} \ | |
30 | /boot/vmlinuz-2.4.27{,-smp} \ | |
31 | /boot/System.map-2.4.27{,-smp} \ | |
32 | /boot/ipcoprd-2.4.27.img \ | |
33 | /boot/ipcoprd-smp-2.4.27.img | |
34 | ||
35 | #save active crontab | |
36 | mv /var/spool/cron/root.orig /tmp/root.orig | |
37 | ||
38 | # install udpated files | |
39 | /bin/tar -zxpf patch.tar.gz -C / | |
40 | ||
41 | # general-functions might not be overwrited by patch | |
42 | /bin/sed -i -e "s+= '1.4.*$+= '$UPGRADEVERSION';+" /var/ipcop/general-functions.pl | |
43 | ||
44 | # unneeded,updated, unified (old eci driver) | |
45 | /bin/rm -f /lib{libbz2.so.1.0.2,libz.so.1.2.2,libproc.so.3.2.1} /usr/bin/eciadsl-{firmware,synch,pppoeci} | |
46 | ||
47 | # update linker cache | |
48 | /sbin/ldconfig | |
49 | ||
50 | # Adjust limits in traffic RRDs to support 100Mbit uplinks | |
51 | for i in /var/log/rrd/{RED,GREEN,ORANGE,BLUE}.rrd; do | |
52 | if [ -e $i ]; then | |
53 | /usr/bin/perl -e "use RRDs;RRDs::tune('$i','--maximum','incoming:12500000');" | |
54 | /usr/bin/perl -e "use RRDs;RRDs::tune('$i','--maximum','outgoing:12500000');" | |
55 | fi | |
56 | done | |
57 | ||
58 | # optionsfw (ping disable, logging limitation | |
59 | mkdir -p /var/ipcop/optionsfw | |
60 | chmod 550 /var/ipcop/optionsfw | |
61 | touch /var/ipcop/optionsfw/settings | |
62 | chown nobody:nobody /var/ipcop/optionsfw | |
63 | chown nobody:nobody /var/ipcop/optionsfw/settings | |
64 | chmod 644 /var/ipcop/optionsfw/settings | |
65 | ||
66 | #Add a directory for language files installed by addons | |
67 | mkdir -p /var/ipcop/addon-lang | |
68 | chmod 550 /var/ipcop/addon-lang | |
69 | chown nobody:nobody /var/ipcop/addon-lang | |
70 | ||
71 | # Strip colon from end of 'section' string in all language files. | |
72 | for file in /var/ipcop/langs/*.pl | |
73 | do | |
74 | sed -i -e '/section/s/://' $file | |
75 | done | |
76 | ||
77 | # Start of patch update to header.pl | |
78 | # | |
79 | # Use patch -N switch to apply patches only once | |
80 | # | |
81 | # First, upgrade to match v1.4.6 iso, if required | |
82 | patch -N /var/ipcop/header.pl <<\END | |
83 | 105c105,107 | |
84 | < [ $Lang::tr{'blue access'} , '/cgi-bin/wireless.cgi', "IPCop $Lang::tr{'blue access'}" ]] | |
85 | --- | |
86 | > [ $Lang::tr{'blue access'} , '/cgi-bin/wireless.cgi', "IPCop $Lang::tr{'blue access'}" ] | |
87 | > # ,[ $Lang::tr{'options fw'} , '/cgi-bin/optionsfw.cgi', "IPCop $Lang::tr{'options fw'}" ] | |
88 | > ] | |
89 | END | |
90 | ||
91 | # Uncomment firewall options menu item | |
92 | patch -N /var/ipcop/header.pl <<\END | |
93 | 106c106 | |
94 | < # ,[ $Lang::tr{'options fw'} , '/cgi-bin/optionsfw.cgi', "IPCop $Lang::tr{'options fw'}" ] | |
95 | --- | |
96 | > ,[ $Lang::tr{'options fw'} , '/cgi-bin/optionsfw.cgi', "IPCop $Lang::tr{'options fw'}" ] | |
97 | END | |
98 | ||
99 | # Apply 'ends never' patch to PrintActualLeases subroutine | |
100 | patch -N /var/ipcop/header.pl <<\END | |
101 | 752,754c752,754 | |
102 | < } | |
103 | < | |
104 | < if ($line =~ /^\s*ends/) { | |
105 | --- | |
106 | > } elsif ($line =~ /^\s*ends never;/) { | |
107 | > $endtime = 'never'; | |
108 | > } elsif ($line =~ /^\s*ends/) { | |
109 | 757,759c757 | |
110 | < } | |
111 | < | |
112 | < if ($line =~ /^\s*hardware ethernet/) { | |
113 | --- | |
114 | > } elsif ($line =~ /^\s*hardware ethernet/) { | |
115 | 762,766c760,762 | |
116 | < } | |
117 | < | |
118 | < if ($line =~ /^\s*client-hostname/) { | |
119 | < shift (@temp); | |
120 | < $hostname = join (' ',@temp); | |
121 | --- | |
122 | > } elsif ($line =~ /^\s*client-hostname/) { | |
123 | > shift (@temp); | |
124 | > $hostname = join (' ',@temp); | |
125 | 769,771c765 | |
126 | < } | |
127 | < | |
128 | < if ($line eq "}") { | |
129 | --- | |
130 | > } elsif ($line eq "}") { | |
131 | 776c770 | |
132 | < } | |
133 | --- | |
134 | > } #unknown format line... | |
135 | 803,808c797,798 | |
136 | < my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst); | |
137 | < ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime ($entries{$key}->{ENDTIME}); | |
138 | < my $enddate = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); | |
139 | < | |
140 | < if ($entries{$key}->{ENDTIME} < time() ){ | |
141 | < print "<strike>$enddate</strike>"; | |
142 | --- | |
143 | > if ($entries{$key}->{ENDTIME} eq 'never') { | |
144 | > print "$Lang::tr{'no time limit'}"; | |
145 | 810c800,808 | |
146 | < print "$enddate"; | |
147 | --- | |
148 | > my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst); | |
149 | > ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime ($entries{$key}->{ENDTIME}); | |
150 | > my $enddate = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); | |
151 | > | |
152 | > if ($entries{$key}->{ENDTIME} < time() ){ | |
153 | > print "<strike>$enddate</strike>"; | |
154 | > } else { | |
155 | > print "$enddate"; | |
156 | > } | |
157 | END | |
158 | ||
159 | # Clean up any rejects | |
160 | rm -f /var/ipcop/header.pl.rej | |
161 | ||
162 | # End of update to header.pl | |
163 | ||
164 | # removing optionsfw.cgi from the menu because it is not ready | |
165 | /bin/sed -i -e 'optionsfw.cgi/ ,[ /# ,[ /' /var/ipcop/header.pl | |
166 | # | |
167 | # new crontab (supporting minimize ddns updates) | |
168 | # | |
169 | sum=`md5sum /tmp/root.orig | awk '{print $1}' ` | |
170 | # if version 1.9.2.1 or 1.9.2.2 is untouched, just replace it else add the new entry only | |
171 | if [ "$sum" == "918ec891f5436c0e34ce4ba213a9fbe1" ] || | |
172 | [ "$sum" == "b18e7567915e576655815fb409145f1a" ] ; then | |
173 | echo "Upgrade original crontab" | |
174 | #file come from the update | |
175 | else | |
176 | cat<<END>>/var/spool/cron/root.orig | |
177 | ||
178 | # ipcop update 1.4.7 addition to not original crontab | |
179 | # force update (even if name match IP) once a month if minimize option selected | |
180 | ||
181 | 3 2 1 * * [ -f "/var/ipcop/red/active" ] && /usr/local/bin/setddns.pl -f -m | |
182 | END | |
183 | fi | |
184 | /usr/bin/fcrontab -z | |
185 | ||
186 | /bin/rm -f /tmp/root.orig | |
187 | ||
188 | #change in service name to conform to real name | |
189 | sed -i -e 's/freedns-afraid/freedns.afraid/' /var/ipcop/ddns/config | |
190 | chown nobody:nobody /var/ipcop/ddns/config | |
191 | ||
192 | #build cachelang file use this call after all "lang/*.pl" updates ! | |
193 | perl -e "require '/var/ipcop/lang.pl'; &Lang::BuildCacheLang" | |
194 | ||
195 | cd /bin | |
196 | ln -s gzip zcat #logwatch.pl may use it | |
197 | ln -s bzip2 bzcat | |
198 | ||
199 | #fix init update : no more / is busy during shutdown | |
200 | /sbin/telinit u | |
201 | ||
202 | # adjust vpn config for new options DPD_ACTION & PFS | |
203 | # if config is 'host' set dpd_action=clear else set hold. Add always yes for PFS | |
204 | cp /var/ipcop/vpn/config /var/ipcop/vpn/config.old | |
205 | perl -e "while (<>) { chomp; \$V=(/,host,/?'clear':'hold'); print \"\$_,\$V,yes\n\"; }" /var/ipcop/vpn/config.old > /var/ipcop/vpn/config | |
206 | chown nobody:nobody /var/ipcop/vpn/config | |
207 | ||
208 | echo "IPCop v$UPGRADEVERSION - The Bad Packets Stop Here">/etc/issue | |
209 | killall mingetty #redisplay correct version | |
210 | echo "end of $UPGRADEVERSION update" | |
211 | exit 0 |