←︎ tools :: 1c9303e


1
commit 1c9303ef3ef3a225a5c3a9e4cd7766cc5b3905b9
2
Author: acidvegas <acid.vegas@acid.vegas>
3
Date:   Thu Aug 1 23:58:41 2019 -0400
4
5
    Initial commit
6
---
7
 altdns.py         | 24 ++++++++++++++++++++++++
8
 deploy-anope      | 45 ++++++++++++++++++++++++++++++++++++++++++++
9
 deploy-nginx      | 39 ++++++++++++++++++++++++++++++++++++++
10
 deploy-unrealircd | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
11
 startbots         | 11 +++++++++++
12
 updates.py        | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
 6 files changed, 227 insertions(+)
14
15
diff --git a/altdns.py b/altdns.py
16
new file mode 100644
17
index 0000000..48e5afd
18
--- /dev/null
19
+++ b/altdns.py
20
@@ -0,0 +1,24 @@
21
+#!/usr/bin/env python
22
+import socket
23
+
24
+dns = (
25
+	'chat.mirccloud.com',
26
+	'irc.fagz.net',
27
+	'irc.hardchats.net',
28
+	'irc.j3ws.biz',
29
+	'irc.j3ws.org',
30
+	'irc.k0de.org',
31
+	'irc.ngr.bz',
32
+	'irc.wepump.in',
33
+	'serious.fuckin.business'
34
+)
35
+
36
+servers = set([i[4][0] for i in socket.getaddrinfo('irc.supernets.org', 6667)])
37
+for hostname in dns:
38
+	try:
39
+		if socket.gethostbyname(hostname) in servers:
40
+			print('OK\t\t' + hostname)
41
+		else:
42
+			print('FAIL\t' + hostname)
43
+	except:
44
+		print('ERROR\t' + hostname)
45
diff --git a/deploy-anope b/deploy-anope
46
new file mode 100755
47
index 0000000..7c1e606
48
--- /dev/null
49
+++ b/deploy-anope
50
@@ -0,0 +1,45 @@
51
+#!/bin/sh
52
+set -xev
53
+
54
+ANOPE=$HOME/services
55
+BACKUP=$HOME/services.backup
56
+SOURCE=$HOME/services.source
57
+
58
+setup() {
59
+	git clone --depth 1 https://github.com/supernets/anope.git $SOURCE
60
+	cd $SOURCE && $SOURCE/Config -nointro -quick && make && make install
61
+	cd $HOME && rm -rf $SOURCE
62
+}
63
+
64
+deploy() {
65
+	setup
66
+	#todo: edit services.conf here
67
+}
68
+
69
+update() {
70
+	#todo: check & kill abduco watchdog process
71
+	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit
72
+	mkdir $BACKUP
73
+	cp $NAOPE/conf/services.conf $BACKUP && cp $ANOPE/data/anope.db $BACKUP
74
+	pkill -9 services
75
+	rm -rf $ANOPE
76
+	setup
77
+	mv $BACKUP/services.conf $ANOPE/conf/
78
+	mv $BACKUP/anope.db $ANOPE/data
79
+	$ANOPE/bin/services
80
+	watchdog
81
+}
82
+
83
+watchdog() {
84
+	if command -v abduco >/dev/null 2>&1; then
85
+		abduco -fnr ircdwatchdog     bash -c "while true; do [ ! -f $HOME/services/data/services.pid ] && $HOME/services/bin/services; sleep 15; done"
86
+	elif command -v screen >/dev/null 2>&1; then
87
+		screen -S   ircdwatchdog -dm bash -c "while true; do [ ! -f $HOME/services/data/services.pid ] && $HOME/services/bin/services; sleep 15; done"
88
+	else
89
+		echo "[!] - install abduco or screen"
90
+	fi
91
+}
92
+
93
+[ $1 = "deploy"   ] && deploy   && exit 1
94
+[ $1 = "update"   ] && update   && exit 1
95
+[ $1 = "watchdog" ] && watchdog && exit 1
96
diff --git a/deploy-nginx b/deploy-nginx
97
new file mode 100755
98
index 0000000..26b437d
99
--- /dev/null
100
+++ b/deploy-nginx
101
@@ -0,0 +1,39 @@
102
+#!/bin/sh
103
+set -xev
104
+
105
+pacman -S certbot nginx-mainline
106
+echo "worker_processes auto;"
107
+echo "worker_cpu_affinity auto;"
108
+echo "error_log logs/error.log;"
109
+echo -e "\nevents {"
110
+echo -e "\tworker_connections 1024;"
111
+echo "}"
112
+echo "\nhttp {"
113
+echo -e "\tinclude mime.types;"
114
+echo -e "\tdefault_type application/octet-stream;"
115
+echo -e "\taccess_log off;"
116
+echo -e "\tsendfile on;"
117
+echo -e "\tserver_tokens off;"
118
+echo -e "\tserver {"
119
+echo -e "\t\tlisten PORT;"      #note: change port
120
+echo -e "\t\tlisten [::]:PORT;" #note: change port
121
+echo -e "\t\troot /home/supernets/www;"
122
+echo -e "\t\tserver_name localhost;"
123
+echo -e "\t\tcharset UTF-8;"
124
+echo -e "\t\t#satisfy all;"
125
+echo -e "\t\tallow 1.2.3.4; # Link 1" #note: add all ipv4/ipv6 links
126
+echo -e "\t\tallow 1.2.3.4; # Link 2"
127
+echo -e "\t\tallow 1.2.3.4; # Link 3"
128
+echo -e "\t\tallow 1.2.3.4; # Link 4"
129
+echo -e "\t\tallow 1.2.3.4; # Link 5"
130
+echo -e "\t\tdeny all;"
131
+echo -e "\t\tauth_basic \"Restricted\";"
132
+echo -e "\t\tauth_basic_user_file /home/supernets/www/.htpasswd;"
133
+echo -e "\t}"
134
+echo "}"
135
+git clone --depth 1 https://github.com/supernets/www $HOME/www
136
+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
137
+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
138
+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
139
+systemctl enable certbot.timer && systemctl start certbot.timer
140
+systemctl enable nginx         && systemctl start nginx
141
diff --git a/deploy-unrealircd b/deploy-unrealircd
142
new file mode 100755
143
index 0000000..271cf1d
144
--- /dev/null
145
+++ b/deploy-unrealircd
146
@@ -0,0 +1,52 @@
147
+#!/bin/sh
148
+set -xev
149
+
150
+BACKUP=$HOME/unrealircd.backup
151
+SOURCE=$HOME/unrealircd.source
152
+UNREAL=$HOME/unrealircd
153
+
154
+setup() {
155
+	git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE
156
+	cd $SOURCE && echo -e "\n" | ./Config -nointro && make && make install
157
+	cd $HOME && rm -rf $SOURCE && rm $UNREAL/conf/*.conf
158
+}
159
+
160
+deploy() {
161
+	setup
162
+	read -p "Link Name: " NAME
163
+	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)
164
+	echo "[NOTE] - Your remote include should be in https://USERNAME:PASSWORD@HOSTNAME:PORT format"
165
+	read -p "Remote Include: " REMOTE
166
+	for item in aliases badwords except help ircd modules opers spamfilter; do echo $REMOTE/$item.conf >> $UNREAL/conf/unrealircd.conf; done
167
+	echo "me { name \"$NAME.supernets.org\"; info \"SuperNETs IRC Network\"; sid $SID; }" >> $UNREAL/conf/unrealircd.conf
168
+	SPKI=$($UNREAL/unrealircd spkifp | sed -n 5p)
169
+	echo -e "\nAdd the following line into the hub\'s links.conf file for this link:\n$SPKI"
170
+}
171
+
172
+update() {
173
+	#todo: check & kill abduco watchdog process
174
+	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit
175
+	mkdir $BACKUP
176
+	cp $UNREAL/conf/unrealircd.conf $BACKUP && cp $UNREAL/conf/ssl/server.*.pem $BACKUP
177
+	$UNREAL/unrealircd stop
178
+	rm -rf $UNREAL
179
+	setup
180
+	mv $BACKUP/unrealircd.conf $UNREAL/conf/ && mv $BACKUP/server.*.pem $UNREAL/conf/ssl
181
+	rm -r $BACKUP
182
+	$UNREAL/unrealircd start
183
+	watchdog
184
+}
185
+
186
+watchdog() {
187
+	if command -v abduco >/dev/null 2>&1; then
188
+		abduco -fnr ircdwatchdog     bash -c "while true; do [ ! -f $HOME/unrealircd/data/unrealircd.pid ] && $HOME/unrealircd/unrealircd start; sleep 15; done"
189
+	elif command -v screen >/dev/null 2>&1; then
190
+		screen -S   ircdwatchdog -dm bash -c "while true; do [ ! -f $HOME/unrealircd/data/unrealircd.pid ] && $HOME/unrealircd/unrealircd start; sleep 15; done"
191
+	else
192
+		echo "[!] - install abduco or screen"
193
+	fi
194
+}
195
+
196
+[ $1 = "deploy"   ] && deploy   && exit 1
197
+[ $1 = "update"   ] && update   && exit 1
198
+[ $1 = "watchdog" ] && watchdog && exit 1
199
diff --git a/startbots b/startbots
200
new file mode 100755
201
index 0000000..26248a4
202
--- /dev/null
203
+++ b/startbots
204
@@ -0,0 +1,11 @@
205
+#!/bin/sh
206
+pkill -9 abduco && pkill -9 python
207
+cd $HOME/bots              && abduco -fnr FUCKYOU      python 5000.py         && sleep 1
208
+cd $HOME/bots/anythinggoes && abduco -fnr anythinggoes python anythinggoes.py && sleep 1
209
+cd $HOME/bots              && abduco -fnr cancer       python cancer.py       && sleep 1
210
+cd $HOME/bots/dickserv     && abduco -fnr dickserv     python dickserv.py     && sleep 1
211
+cd $HOME/bots/irccex/efnet && abduco -fnr irccex-efnet python irccex.py       && sleep 1
212
+cd $HOME/bots/irccex/super && abduco -fnr irccex-super python irccex.py       && sleep 1
213
+cd $HOME/bots              && abduco -fnr limitserv    python limitserv.py    && sleep 1
214
+cd $HOME/bots/scroll       && abduco -fnr scroll       python scroll.py       && sleep 1
215
+cd $HOME/bots              && abduco -fnr spiderweb    python spiderweb.py
216
diff --git a/updates.py b/updates.py
217
new file mode 100644
218
index 0000000..d12ec05
219
--- /dev/null
220
+++ b/updates.py
221
@@ -0,0 +1,56 @@
222
+#!/usr/bin/env python
223
+import re, urllib.request
224
+
225
+anope_version      = '2.0.6'
226
+bootstrap_version  = '4.0.0'
227
+jquery_version     = '3.3.1'
228
+unrealircd_version = '4.0.17'
229
+
230
+def between(source, start, stop):
231
+	data = re.compile(start + '(.*?)' + stop, re.IGNORECASE|re.MULTILINE).search(source)
232
+	return data.group(1) if data else False
233
+
234
+def get_source(url):
235
+	req = urllib.request.Request(url)
236
+	req.add_header('User-Agent', 'DickServ/1.0')
237
+	source = urllib.request.urlopen(req, timeout=10)
238
+	charset = source.headers.get_content_charset()
239
+	return source.read().decode(charset) if charset else source.read().decode()
240
+
241
+def update_anope()      : return between(get_source('http://www.anope.org/'), '<span>Latest Stable Release:</span> Anope ', '\n')
242
+def update_bootstrap()  : return between(get_source('http://getbootstrap.com/'), '<p>Currently v', '. Code licensed')
243
+def update_jquery()     : return between(get_source('http://jquery.com/'), '<span>v', '</span>')
244
+def update_unrealircd() : return between(get_source('http://www.unrealircd.org/docs/FAQ'), '<p>The latest <b>Stable</b> version is <b>', '</b>')
245
+
246
+latest_anope = update_anope()
247
+if latest_anope:
248
+	if latest_anope != anope_version:
249
+		print(f'Anope version {latest_anope} has been released!')
250
+	else:
251
+		print('Anope is up to date.')
252
+else:
253
+	print('[!] - Can not retrieve latest Anope version.')
254
+latest_bootstrap = update_bootstrap()
255
+if latest_bootstrap:
256
+	if latest_bootstrap != bootstrap_version:
257
+		print(f'Bootstrap version {latest_bootstrap} has been released!')
258
+	else:
259
+		print('Bootstrap is up to date.')
260
+else:
261
+	print('[!] - Can not retrieve latest Bootstrap version.')
262
+latest_jquery = update_jquery()
263
+if latest_jquery:
264
+	if latest_jquery != jquery_version:
265
+		print(f'jQuery version {latest_jquery} has been released!')
266
+	else:
267
+		print('jQuery is up to date.')
268
+else:
269
+	print('[!] - Can not retrieve latest jQuery version.')
270
+latest_unrealircd = update_unrealircd()
271
+if latest_unrealircd:
272
+	if latest_unrealircd != unrealircd_version:
273
+		print(f'UnrealIRCd version {latest_unrealircd} has been released!')
274
+	else:
275
+		print('UnrealIRCd is up to date.')
276
+else:
277
+	print('[!] - Can not retrieve latest UnrealIRCd version.')