tools- collection of tools for supernets sysadmins |
git clone git://git.acid.vegas/tools.git |
Log | Files | Refs | Archive |
ircd (4313B)
1 #!/bin/sh 2 # SuperNETs tool for UnrealIRCd deployment - Developed by acidvegas (https://git.acid.vegas/supertools) 3 # debian deployment: apt-get install build-essential pkg-config gdb libssl-dev libpcre2-dev libargon2-0-dev libsodium-dev libc-ares-dev libcurl4-openssl-dev 4 5 UNREAL=$HOME/unrealircd 6 SOURCE=$UNREAL.source 7 8 for pkg in curl git jq make; do 9 if ! command -v $pkg > /dev/null; then 10 echo "error: missing required package '$pkg'" 11 exit 1 12 fi 13 done 14 15 case "$1" in 16 check) 17 [ ! $(command -v jq) ] && echo "error: missing required package 'jq'" && exit 1 18 CURRENT=$($UNREAL/unrealircd version | cut -d'-' -f2) 19 LATEST=$(curl -s https://www.unrealircd.org/downloads/list.json | jq '[.[]][1].Stable.version') 20 [ ! $CURRENT = $LATEST ] && echo "new version available: $LATEST" 21 ;; 22 23 distcert) 24 for link in cowboy contra omega omni phish; do # Make this an arguement instead of hardcoded 25 scp irc.* $link:unrealircd/conf/tls 26 ssh $1 unrealircd/unrealircd rehash && unrealircd/unrealircd reloadtls 27 done 28 ;; 29 30 deploy) 31 git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE 32 cd $SOURCE && echo -e "\n" | ./Config -nointro && make && make install && cd $HOME && rm -rf $SOURCE 33 rm $UNREAL/conf/*.conf 34 read -p "Link Name: " NAME 35 SID=$(cat /dev/urandom | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 1)$(cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 2 | head -n 1) 36 read -p "Remote Include: " REMOTE 37 for item in badwords except ircd modules opers snomasks spamfilter; do echo "include \"$REMOTE/$item.conf\";" >> $UNREAL/conf/unrealircd.conf; done 38 echo "me { name \"$NAME.supernets.org\"; info \"SuperNETs IRC Network\"; sid $SID; }" >> $UNREAL/conf/unrealircd.conf 39 $UNREAL/unrealircd start & 40 if [ $(command -v crontab) ]; then 41 crontab -l | { cat; echo "*/5 * * * * $HOME/unrealircd/unrealircd croncheck"; } | crontab - 42 crontab -l | { cat; echo "@reboot $HOME/unrealircd/unrealircd croncheck"; } | crontab - 43 elif [ $(command -v systemctl) ]; then 44 echo -e "[Unit]\nDescription=UnrealIRCd Cron Check Timer\n\n[Timer]\nOnBootSec=1min\nOnUnitActiveSec=5min\n\n[Install]\nWantedBy=timers.target" > $HOME/.config/systemd/user/unreal.timer 45 echo -e "[Unit]\nDescription=UnrealIRCd Cron Check Service\n\n[Service]\nType=oneshot\nExecStart=$HOME/unrealircd/unrealircd croncheck" > $HOME/.config/systemd/user/unreal.service 46 systemctl --user enable unreal.timer && systemctl --user start unreal.timer 47 else 48 echo "warning: cron/systemd not found on system! (reboot/restart timers not set)" 49 fi 50 $UNREAL/unrealircd spkifp | tail -n2 | head -1 51 curl -4 icanhazip.com && curl -6 icanhazip.com 52 ;; 53 54 source) 55 wget -O $SOURCE.tar.gz https://www.unrealircd.org/downloads/unrealircd-latest.tar.gz 56 tar -xvf $SOURCE.tar.gz --one-top-level --strip-components=1 && rm $SOURCE.tar.gz 57 sed -i 's/NICKNAMEHISTORYLENGTH="2000"/NICKNAMEHISTORYLENGTH="100"/g' $SOURCE/Config 58 sed -i 's/REMOTEINC=""/REMOTEINC="1"/g' $SOURCE/Config 59 sed -i 's/*.default.conf/*.conf/g' $SOURCE/Makefile.in 60 sed -i 's/*.optional.conf/*.motd/g' $SOURCE/Makefile.in 61 sed -i '/modules.sources.list/,/doc\/conf\/example/d' $SOURCE/Makefile.in 62 sed -i 's/sendnotice(target, "\*\*\* You were forced to join %s", jbuf);//g' $SOURCE/src/modules/sajoin.c 63 sed -i 's/0.organizationName_default = IRC geeks/0.organizationName_default = SuperNETs/g' $SOURCE/extras/tls.cnf 64 sed -i 's;//#undef FAKELAG_CONFIGURABLE;#define FAKELAG_CONFIGURABLE;g' $SOURCE/include/config.h 65 rm $SOURCE/doc/conf/* && rm $SOURCE/doc/conf/aliases && rm $SOURCE/doc/conf/examples && rm $SOURCE/doc/conf/help 66 cp $HOME/dev/git/supernets/unrealircd/doc/conf/* $SOURCE/doc/conf/ 67 ;; 68 69 update) 70 BACKUP=$UNREAL.backup 71 mkdir $BACKUP && cp $UNREAL/conf/unrealircd.conf $BACKUP && cp $UNREAL/conf/tls/*.pem $BACKUP && cp $UNREAL/data/*.db $BACKUP 72 git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE 73 $UNREAL/unrealircd stop && rm -rf $UNREAL 74 cd $SOURCE && (echo -e "\n" | ./Config -nointro) && make && make install && cd $HOME && rm -rf $SOURCE 75 rm $UNREAL/conf/*.conf && mv $BACKUP/unrealircd.conf $UNREAL/conf && mv $BACKUP/*.pem $UNREAL/conf/tls && mv $BACKUP/*.db $UNREAL/data && rm -r $BACKUP 76 $UNREAL/unrealircd start & 77 ;; 78 esac