sed -i will edit the file 'in place'
Since you haven't defined a backup extension none will be created.
Just issue the commands one at a time and cat the file in between.
Code:
bas@lenovo:~$ cat /tmp/S95asiablock | grep 'kr '
ISO_spam="af cn in pk my kh li vn kr ph"
bas@lenovo:~$ sed -ie 's/kr ph/kr ph za co/g' /tmp/S95asiablock
bas@lenovo:~$ cat /tmp/S95asiablock | grep 'kr '
ISO_spam="af cn in pk my kh li vn kr ph za co"
bas@lenovo:~$
Use it like this..
Code:
#!/bin/sh
service asiablock stop
service asiablock off
logger "*-* ASIABLOCK UPDATE *-*"
wget -O /opt/etc/init.d/S95asiablock http://otrw.basmaf.com/S95asiablock_2010
sed -ie 's/kr ph/kr ph za co/g' /opt/etc/init.d/S95asiablock
service asiablock on
service asiablock start
What are you trying to accomplish.
I haven't made any changes to the file other then applying she-bang to the pre-wall script.
I know frater has said it should be updated regularly.
Script works as is and don't see anything I should modify on it.
sed -i will edit the file 'in place'
Since you haven't defined a backup extension none will be created.
Just issue the commands one at a time and cat the file in between.
Code:
bas@lenovo:~$ cat /tmp/S95asiablock | grep 'kr '
ISO_spam="af cn in pk my kh li vn kr ph"
bas@lenovo:~$ sed -ie 's/kr ph/kr ph za co/g' /tmp/S95asiablock
bas@lenovo:~$ cat /tmp/S95asiablock | grep 'kr '
ISO_spam="af cn in pk my kh li vn kr ph za co"
bas@lenovo:~$
Use it like this..
Code:
#!/bin/sh
service asiablock stop
service asiablock off
logger "*-* ASIABLOCK UPDATE *-*"
wget -O /opt/etc/init.d/S95asiablock http://otrw.basmaf.com/S95asiablock_2010
sed -ie 's/kr ph/kr ph za co/g' /opt/etc/init.d/S95asiablock
service asiablock on
service asiablock start
What are you trying to accomplish.
I haven't made any changes to the file other then applying she-bang to the pre-wall script.
I know frater has said it should be updated regularly.
Script works as is and don't see anything I should modify on it.
Im writing this to have a weekly update of the ipdeny.com list(s)
the sed edits the script to add in two additional subnet groups (za & co)
I'm not very good at all w/ scripting in bash...very novice
The output I am getting from my script is:
Quote:
root@ETHEREAL:~# sh -x /mnt/asia_upd.sh
+ wget -O /mnt/S95asiablock http://otrw.basmaf.com/S95asiablock_2010
--2012-06-20 13:58:38-- http://otrw.basmaf.com/S95asiablock_2010%0D
Resolving otrw.basmaf.com... 83.83.79.213
Connecting to otrw.basmaf.com|83.83.79.213|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-06-20 13:58:38 ERROR 404: Not Found.
+
: not foundpd.sh: line 5:
+ sed -ie s/kr ph/kr ph za co/g /mnt/S95asiablock
: No such file or directoryablock
+
: not foundpd.sh: line 7:
+ rm /mnt/S95asiablocke
cannot remove `/mnt/S95asiablocke\r': No such file or directory
+
: not foundpd.sh: line 10:
+
: not foundpd.sh: line 14:
+
: not foundpd.sh: line 16:
+
: not foundpd.sh: line 18:
+
: not foundpd.sh: line 20:
root@ETHEREAL:~#
output directory is changed in the above example as to not affect current service
I cannot figure out why the wget command works when issued by itself, but when initiated through the script it cannot find the file on the download server
EDIT: for some reason a "carriage return" is being inserted after the end of the wget command. I am typing the script in notepad++...so instead i copied & pasted into GUI custom command & all seems to work
Ok your using Winblows
Change the end of line of notepad to unix
For achieving what you want downloading of the script is not needed
Stop asiablock
Rm /opt/etc/iptables.asia*
Start asiablock
This will result in downloading the subnets again
You need to renove asia related iptables file otherwise they will be reused
After using basmaf's scripting idea for some testing, I found that it did not remove all of the files affected by asiablock (i.e. ones in /tmp) & was causing some odd behavior. Rather than add more delete lines, I'm sticking with Frater's recommended update method from the wiki.
First part of script operates as such:
- kill any outside pptp connections (my network setup requires this)
- download new copy of asiablock
- add additional subnets to asiablock script
- remove file added by sed
- restart asiablock
I also found that when asiablock/firewall restart occured my pixelserv was re-downloading the blacks list & overwriting my modified file. The 2nd part of my script acts as follows:
- compare current blacks file to saved modded copy
- only if different, stop pixelserv, remove current blacks & replace with modded copy
- restart pixelserv
Quote:
killall pppd
wget -O /opt/etc/init.d/S95asiablock http://wd.mirmana.com/S95asiablock_2010
if [ $? -gt 0 ];
then
wget -O /opt/etc/init.d/S95asiablock http://otrw.basmaf.com/S95asiablock_2010
fi
sleep 2s
sed -ie 's/kr ph/kr ph ir hk ar br za co id/g' /opt/etc/init.d/S95asiablock
#add: iran, hong kong, argentina, brazil, south africa, columbia & indonesia
sleep 2s
rm /opt/etc/init.d/S95asiablocke
sleep 1s
service asiablock on
sleep 1s
service asiablock start
logger "*-* ASIABLOCK UPDATE COMPLETE *-*"
sleep 90s
cmp -s /opt/etc/pixelserv/blacks /opt/etc/pixelserv/blacks.MODDED_v2 > /dev/null
if [ $? -eq 1 ];
then
service pixelserv stop
sleep 1s
rm /opt/etc/pixelserv/blacks
cp /opt/etc/pixelserv/blacks.MODDED_v2 /opt/etc/pixelserv/blacks
service pixelserv start
logger "*-* PIXELSERV BLACKS UPDATED *-*"
else
logger "*-* PIXELSERV UPDATE NOT NEEDED *-*"
fi
Attached is a copy of my modded blacks file if anyone would like to try it out...put it in /opt/etc/pixelserv/
As I've said before...I'm just looking to automate some functions & have fun while doing so! BASH scripting as a novice is difficult!