🢀︎ tools :: 1c9303e


commit 1c9303ef3ef3a225a5c3a9e4cd7766cc5b3905b9
Author: acidvegas <acid.vegas@acid.vegas>
Date:   Thu Aug 1 23:58:41 2019 -0400

    Initial commit

diff --git a/altdns.py b/altdns.py
new file mode 100644
index 0000000..48e5afd
--- /dev/null
+++ b/altdns.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+import socket
+
+dns = (
+	'chat.mirccloud.com',
+	'irc.fagz.net',
+	'irc.hardchats.net',
+	'irc.j3ws.biz',
+	'irc.j3ws.org',
+	'irc.k0de.org',
+	'irc.ngr.bz',
+	'irc.wepump.in',
+	'serious.fuckin.business'
+)
+
+servers = set([i[4][0] for i in socket.getaddrinfo('irc.supernets.org', 6667)])
+for hostname in dns:
+	try:
+		if socket.gethostbyname(hostname) in servers:
+			print('OK\t\t' + hostname)
+		else:
+			print('FAIL\t' + hostname)
+	except:
+		print('ERROR\t' + hostname)
\ No newline at end of file
diff --git a/deploy-anope b/deploy-anope
new file mode 100755
index 0000000..7c1e606
--- /dev/null
+++ b/deploy-anope
@@ -0,0 +1,45 @@
+#!/bin/sh
+set -xev
+
+ANOPE=$HOME/services
+BACKUP=$HOME/services.backup
+SOURCE=$HOME/services.source
+
+setup() {
+	git clone --depth 1 https://github.com/supernets/anope.git $SOURCE
+	cd $SOURCE && $SOURCE/Config -nointro -quick && make && make install
+	cd $HOME && rm -rf $SOURCE
+}
+
+deploy() {
+	setup
+	#todo: edit services.conf here
+}
+
+update() {
+	#todo: check & kill abduco watchdog process
+	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit
+	mkdir $BACKUP
+	cp $NAOPE/conf/services.conf $BACKUP && cp $ANOPE/data/anope.db $BACKUP
+	pkill -9 services
+	rm -rf $ANOPE
+	setup
+	mv $BACKUP/services.conf $ANOPE/conf/
+	mv $BACKUP/anope.db $ANOPE/data
+	$ANOPE/bin/services
+	watchdog
+}
+
+watchdog() {
+	if command -v abduco >/dev/null 2>&1; then
+		abduco -fnr ircdwatchdog     bash -c "while true; do [ ! -f $HOME/services/data/services.pid ] && $HOME/services/bin/services; sleep 15; done"
+	elif command -v screen >/dev/null 2>&1; then
+		screen -S   ircdwatchdog -dm bash -c "while true; do [ ! -f $HOME/services/data/services.pid ] && $HOME/services/bin/services; sleep 15; done"
+	else
+		echo "[!] - install abduco or screen"
+	fi
+}
+
+[ $1 = "deploy"   ] && deploy   && exit 1
+[ $1 = "update"   ] && update   && exit 1
+[ $1 = "watchdog" ] && watchdog && exit 1
\ No newline at end of file
diff --git a/deploy-nginx b/deploy-nginx
new file mode 100755
index 0000000..26b437d
--- /dev/null
+++ b/deploy-nginx
@@ -0,0 +1,39 @@
+#!/bin/sh
+set -xev
+
+pacman -S certbot nginx-mainline
+echo "worker_processes auto;"
+echo "worker_cpu_affinity auto;"
+echo "error_log logs/error.log;"
+echo -e "\nevents {"
+echo -e "\tworker_connections 1024;"
+echo "}"
+echo "\nhttp {"
+echo -e "\tinclude mime.types;"
+echo -e "\tdefault_type application/octet-stream;"
+echo -e "\taccess_log off;"
+echo -e "\tsendfile on;"
+echo -e "\tserver_tokens off;"
+echo -e "\tserver {"
+echo -e "\t\tlisten PORT;"      #note: change port
+echo -e "\t\tlisten [::]:PORT;" #note: change port
+echo -e "\t\troot /home/supernets/www;"
+echo -e "\t\tserver_name localhost;"
+echo -e "\t\tcharset UTF-8;"
+echo -e "\t\t#satisfy all;"
+echo -e "\t\tallow 1.2.3.4; # Link 1" #note: add all ipv4/ipv6 links
+echo -e "\t\tallow 1.2.3.4; # Link 2"
+echo -e "\t\tallow 1.2.3.4; # Link 3"
+echo -e "\t\tallow 1.2.3.4; # Link 4"
+echo -e "\t\tallow 1.2.3.4; # Link 5"
+echo -e "\t\tdeny all;"
+echo -e "\t\tauth_basic \"Restricted\";"
+echo -e "\t\tauth_basic_user_file /home/supernets/www/.htpasswd;"
+echo -e "\t}"
+echo "}"
+git clone --depth 1 https://github.com/supernets/www $HOME/www
+certbot certonly --email admin@supernets.org --rsa-key-size 4096 --webroot -w $HOME/www/ -d supernets.org -d webchat.supernets.org -d www.supernets.org
+echo -e "[Unit]\nDescription=Lets Encrypt renewal\n\n[Service]\nType=oneshot\nExecStart=/usr/bin/certbot renew -n -q --agree-tos --post-hook=\"systemctl reload nginx\"" > /etc/systemd/system/certbot.service
+echo -e "[Unit]\nDescription=Twice daily renewal of Let's Encrypts certificates\n\n[Timer]\nOnCalendar=0/12:00:00\nRandomizedDelaySec=1h\nPersistent=true\n\n[Install]\nWantedBy=timers.target" > /etc/systemd/system/certbot.timer
+systemctl enable certbot.timer && systemctl start certbot.timer
+systemctl enable nginx         && systemctl start nginx
diff --git a/deploy-unrealircd b/deploy-unrealircd
new file mode 100755
index 0000000..271cf1d
--- /dev/null
+++ b/deploy-unrealircd
@@ -0,0 +1,52 @@
+#!/bin/sh
+set -xev
+
+BACKUP=$HOME/unrealircd.backup
+SOURCE=$HOME/unrealircd.source
+UNREAL=$HOME/unrealircd
+
+setup() {
+	git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE
+	cd $SOURCE && echo -e "\n" | ./Config -nointro && make && make install
+	cd $HOME && rm -rf $SOURCE && rm $UNREAL/conf/*.conf
+}
+
+deploy() {
+	setup
+	read -p "Link Name: " NAME
+	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)
+	echo "[NOTE] - Your remote include should be in https://USERNAME:PASSWORD@HOSTNAME:PORT format"
+	read -p "Remote Include: " REMOTE
+	for item in aliases badwords except help ircd modules opers spamfilter; do echo $REMOTE/$item.conf >> $UNREAL/conf/unrealircd.conf; done
+	echo "me { name \"$NAME.supernets.org\"; info \"SuperNETs IRC Network\"; sid $SID; }" >> $UNREAL/conf/unrealircd.conf
+	SPKI=$($UNREAL/unrealircd spkifp | sed -n 5p)
+	echo -e "\nAdd the following line into the hub\'s links.conf file for this link:\n$SPKI"
+}
+
+update() {
+	#todo: check & kill abduco watchdog process
+	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit
+	mkdir $BACKUP
+	cp $UNREAL/conf/unrealircd.conf $BACKUP && cp $UNREAL/conf/ssl/server.*.pem $BACKUP
+	$UNREAL/unrealircd stop
+	rm -rf $UNREAL
+	setup
+	mv $BACKUP/unrealircd.conf $UNREAL/conf/ && mv $BACKUP/server.*.pem $UNREAL/conf/ssl
+	rm -r $BACKUP
+	$UNREAL/unrealircd start
+	watchdog
+}
+
+watchdog() {
+	if command -v abduco >/dev/null 2>&1; then
+		abduco -fnr ircdwatchdog     bash -c "while true; do [ ! -f $HOME/unrealircd/data/unrealircd.pid ] && $HOME/unrealircd/unrealircd start; sleep 15; done"
+	elif command -v screen >/dev/null 2>&1; then
+		screen -S   ircdwatchdog -dm bash -c "while true; do [ ! -f $HOME/unrealircd/data/unrealircd.pid ] && $HOME/unrealircd/unrealircd start; sleep 15; done"
+	else
+		echo "[!] - install abduco or screen"
+	fi
+}
+
+[ $1 = "deploy"   ] && deploy   && exit 1
+[ $1 = "update"   ] && update   && exit 1
+[ $1 = "watchdog" ] && watchdog && exit 1
\ No newline at end of file
diff --git a/startbots b/startbots
new file mode 100755
index 0000000..26248a4
--- /dev/null
+++ b/startbots
@@ -0,0 +1,11 @@
+#!/bin/sh
+pkill -9 abduco && pkill -9 python
+cd $HOME/bots              && abduco -fnr FUCKYOU      python 5000.py         && sleep 1
+cd $HOME/bots/anythinggoes && abduco -fnr anythinggoes python anythinggoes.py && sleep 1
+cd $HOME/bots              && abduco -fnr cancer       python cancer.py       && sleep 1
+cd $HOME/bots/dickserv     && abduco -fnr dickserv     python dickserv.py     && sleep 1
+cd $HOME/bots/irccex/efnet && abduco -fnr irccex-efnet python irccex.py       && sleep 1
+cd $HOME/bots/irccex/super && abduco -fnr irccex-super python irccex.py       && sleep 1
+cd $HOME/bots              && abduco -fnr limitserv    python limitserv.py    && sleep 1
+cd $HOME/bots/scroll       && abduco -fnr scroll       python scroll.py       && sleep 1
+cd $HOME/bots              && abduco -fnr spiderweb    python spiderweb.py
\ No newline at end of file
diff --git a/updates.py b/updates.py
new file mode 100644
index 0000000..d12ec05
--- /dev/null
+++ b/updates.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+import re, urllib.request
+
+anope_version      = '2.0.6'
+bootstrap_version  = '4.0.0'
+jquery_version     = '3.3.1'
+unrealircd_version = '4.0.17'
+
+def between(source, start, stop):
+	data = re.compile(start + '(.*?)' + stop, re.IGNORECASE|re.MULTILINE).search(source)
+	return data.group(1) if data else False
+
+def get_source(url):
+	req = urllib.request.Request(url)
+	req.add_header('User-Agent', 'DickServ/1.0')
+	source = urllib.request.urlopen(req, timeout=10)
+	charset = source.headers.get_content_charset()
+	return source.read().decode(charset) if charset else source.read().decode()
+
+def update_anope()      : return between(get_source('http://www.anope.org/'), '<span>Latest Stable Release:</span> Anope ', '\n')
+def update_bootstrap()  : return between(get_source('http://getbootstrap.com/'), '<p>Currently v', '. Code licensed')
+def update_jquery()     : return between(get_source('http://jquery.com/'), '<span>v', '</span>')
+def update_unrealircd() : return between(get_source('http://www.unrealircd.org/docs/FAQ'), '<p>The latest <b>Stable</b> version is <b>', '</b>')
+
+latest_anope = update_anope()
+if latest_anope:
+	if latest_anope != anope_version:
+		print(f'Anope version {latest_anope} has been released!')
+	else:
+		print('Anope is up to date.')
+else:
+	print('[!] - Can not retrieve latest Anope version.')
+latest_bootstrap = update_bootstrap()
+if latest_bootstrap:
+	if latest_bootstrap != bootstrap_version:
+		print(f'Bootstrap version {latest_bootstrap} has been released!')
+	else:
+		print('Bootstrap is up to date.')
+else:
+	print('[!] - Can not retrieve latest Bootstrap version.')
+latest_jquery = update_jquery()
+if latest_jquery:
+	if latest_jquery != jquery_version:
+		print(f'jQuery version {latest_jquery} has been released!')
+	else:
+		print('jQuery is up to date.')
+else:
+	print('[!] - Can not retrieve latest jQuery version.')
+latest_unrealircd = update_unrealircd()
+if latest_unrealircd:
+	if latest_unrealircd != unrealircd_version:
+		print(f'UnrealIRCd version {latest_unrealircd} has been released!')
+	else:
+		print('UnrealIRCd is up to date.')
+else:
+	print('[!] - Can not retrieve latest UnrealIRCd version.')
\ No newline at end of file