diff options
Diffstat (limited to '')
-rwxr-xr-x | skripti/irc_antispam.sh | 44 | ||||
-rwxr-xr-x | skripti/java_package_manager.sh | 46 | ||||
-rw-r--r-- | skripti/on_log_line.sh | 3 | ||||
-rwxr-xr-x | skripti/remove_ipv6_on_disconnect.sh | 10 |
4 files changed, 103 insertions, 0 deletions
diff --git a/skripti/irc_antispam.sh b/skripti/irc_antispam.sh new file mode 100755 index 0000000..4e7a513 --- /dev/null +++ b/skripti/irc_antispam.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -uexo pipefail +p=`rev <<<$0 | cut -d/ -f1 | rev` +umask 0007 +d=`mktemp -p "" -d $p.XXX` +trap "rm -r $d" EXIT +mkfifo $d/s +mkfifo $d/c +tail -f $d/s | nc $1 6667 > $d/c & +u=dont_send_me_msg_ +echo "USER $u `hostname` $1 :IRC Antispam bot. Do not PM, you will get G-Lined." > $d/s +echo "NICK antispam" > $d/s +echo "OPER $OPER" > $d/s +c="antispam_chan_dont_join_youll_get_gline_" +j="$c$RANDOM" +echo "JOIN #$j" > $d/s +while read l +do + echo "$l" + case `cut -d\ -f2 <<<"$l"` in + 433) + echo "NICK bot$RANDOM" > $d/s + echo "OPER $OPER" > $d/s + echo "PART #$j" > $d/s + j="$c$RANDOM" + echo "JOIN #$j" > $d/s + ;; + PRIVMSG|JOIN|PART) + if grep -v $u <<<"$l" + then + i=`cut -d\ -f1 <<<"$l" | cut -d@ -f2` + echo "GLINE *@$i 13376969 :You were G-Lined for spamming. Appeal via email to anton@sijanec.eu" > $d/s + fi + ;; + esac + case `cut -d\ -f1 <<<"$l"` in + PING) + echo "PONG `cut -d\ -f2 <<<$l`" > $d/s + echo "PART #$j" > $d/s + j="$c$RANDOM" + echo "JOIN #$j" > $d/s + ;; + esac +done < $d/c diff --git a/skripti/java_package_manager.sh b/skripti/java_package_manager.sh new file mode 100755 index 0000000..b445abb --- /dev/null +++ b/skripti/java_package_manager.sh @@ -0,0 +1,46 @@ +#!/bin/sh +set -xeuo pipefail +clean () { + sed -n '/^# java_package_manager.begin$/,/^# java_package_manager.end$/{/^# java_package_manager.begin$/!{/^# java_package_manager.end$/!p}}' .gitignore | while read l + do + rd=`rev <<<$l | cut -d/ -f2- | rev` + rm $l + [ `ls $rd | wc -l` -eq 0 ] && rmdir $rd + + done + sed -i '/^# java_package_manager.begin$/,/^# java_package_manager.end$/d' .gitignore +} +case $1 in + i*|I*) + [ -f java_package_manager.txt ] || { echo no java_package_manager.txt, refusing to run; exit 2; } + if grep '^# java_package_manager.begin$' .gitignore > /dev/null + then + echo was already installed. cleaning before reinstalling. + clean + fi + echo '# java_package_manager.begin' >> .gitignore + c=0 + grep -v '^#' java_package_manager.txt | while read l + do + c=$(($c+1)) + [ $c -eq 1 ] && { d=$l; continue; } + find $l -type f | while read line + do + dst=`sed s,$l,$d, <<<$line` + dstd=`rev <<<$dst | cut -d/ -f2- | rev` + [ -d $dstd ] || mkdir -p $dstd + cp --no-clobber $line $dst + echo $dst >> .gitignore + done + + done + echo '# java_package_manager.end' >> .gitignore + ;; + c*|C*) + clean + ;; + *) + echo wrong option + exit 1 + ;; +esac diff --git a/skripti/on_log_line.sh b/skripti/on_log_line.sh new file mode 100644 index 0000000..db57781 --- /dev/null +++ b/skripti/on_log_line.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# ./on_log_line.sh /var/log/syslog +tail -f $1 diff --git a/skripti/remove_ipv6_on_disconnect.sh b/skripti/remove_ipv6_on_disconnect.sh new file mode 100755 index 0000000..a227688 --- /dev/null +++ b/skripti/remove_ipv6_on_disconnect.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -xe +tail --follow=name --retry /var/log/syslog | grep "default route via" | while read l +do + iface=`cut -d\ -f6 <<<"$l" | sed s/://` + ip -6 route | grep $iface | while read line + do + ip route del $line + done +done |