←︎ tools :: d419740


1
commit d419740c326eb902d275bdefbe6e939021cd77c4
2
Author: acidvegas <acid.vegas@acid.vegas>
3
Date:   Mon Aug 12 23:01:23 2019 -0400
4
5
    updated
6
---
7
 deploy-anope      |  6 ++----
8
 deploy-nginx      |  9 +++++----
9
 deploy-unrealircd | 37 +++++++++++++++++++++++++-----------
10
 monitor           |  8 ++++++++
11
 updates.py        | 56 -------------------------------------------------------
12
 5 files changed, 41 insertions(+), 75 deletions(-)
13
14
diff --git a/deploy-anope b/deploy-anope
15
index 7c1e606..beffeb2 100755
16
--- a/deploy-anope
17
+++ b/deploy-anope
18
@@ -7,8 +7,7 @@ SOURCE=$HOME/services.source
19
 
20
 setup() {
21
 	git clone --depth 1 https://github.com/supernets/anope.git $SOURCE
22
-	cd $SOURCE && $SOURCE/Config -nointro -quick && make && make install
23
-	cd $HOME && rm -rf $SOURCE
24
+	cd $SOURCE && $SOURCE/Config -nointro -quick && make && make install && cd $HOME && rm -rf $SOURCE
25
 }
26
 
27
 deploy() {
28
@@ -17,8 +16,7 @@ deploy() {
29
 }
30
 
31
 update() {
32
-	#todo: check & kill abduco watchdog process
33
-	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit
34
+	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit #todo: check & kill abduco watchdog process
35
 	mkdir $BACKUP
36
 	cp $NAOPE/conf/services.conf $BACKUP && cp $ANOPE/data/anope.db $BACKUP
37
 	pkill -9 services
38
diff --git a/deploy-nginx b/deploy-nginx
39
index 26b437d..6f7c68b 100755
40
--- a/deploy-nginx
41
+++ b/deploy-nginx
42
@@ -1,7 +1,8 @@
43
 #!/bin/sh
44
 set -xev
45
-
46
 pacman -S certbot nginx-mainline
47
+htpasswd -c /home/irc/public_html/conf/.htpasswd restricted
48
+certbot --nginx -d hub.supernets.org
49
 echo "worker_processes auto;"
50
 echo "worker_cpu_affinity auto;"
51
 echo "error_log logs/error.log;"
52
@@ -15,10 +16,10 @@ echo -e "\taccess_log off;"
53
 echo -e "\tsendfile on;"
54
 echo -e "\tserver_tokens off;"
55
 echo -e "\tserver {"
56
-echo -e "\t\tlisten PORT;"      #note: change port
57
-echo -e "\t\tlisten [::]:PORT;" #note: change port
58
+echo -e "\t\tlisten PORT ssl;"      #note: change port
59
+echo -e "\t\tlisten [::]:PORT ssl;" #note: change port
60
 echo -e "\t\troot /home/supernets/www;"
61
-echo -e "\t\tserver_name localhost;"
62
+echo -e "\t\tserver_name hub.supernets.org;"
63
 echo -e "\t\tcharset UTF-8;"
64
 echo -e "\t\t#satisfy all;"
65
 echo -e "\t\tallow 1.2.3.4; # Link 1" #note: add all ipv4/ipv6 links
66
diff --git a/deploy-unrealircd b/deploy-unrealircd
67
index 271cf1d..599bd52 100755
68
--- a/deploy-unrealircd
69
+++ b/deploy-unrealircd
70
@@ -1,37 +1,52 @@
71
 #!/bin/sh
72
 set -xev
73
 
74
-BACKUP=$HOME/unrealircd.backup
75
-SOURCE=$HOME/unrealircd.source
76
 UNREAL=$HOME/unrealircd
77
+BACKUP=$UNREAL.backup
78
+SOURCE=$UNREAL.source
79
 
80
-setup() {
81
-	git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE
82
-	cd $SOURCE && echo -e "\n" | ./Config -nointro && make && make install
83
-	cd $HOME && rm -rf $SOURCE && rm $UNREAL/conf/*.conf
84
+get_latest() {
85
+	curl -s https://www.unrealircd.org/downloads/list.json | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^version/ {print $2}' | sed 's/\(^"\|"$\)//g'
86
+}
87
+
88
+update_source() {
89
+	wget -O $SOURCE.tar.gz https://www.unrealircd.org/downloads/unrealircd-latest.tar.gz
90
+	tar -xvf $SOURCE.tar.gz --one-top-level --strip-components=1
91
+	rm $SOURCE.tar.gz
92
+	sed -i 's;//#undef FAKELAG_CONFIGURABLE;#define FAKELAG_CONFIGURABLE;g' $SOURCE/include/config.h
93
+	sed -i 's_\t\t\tsendnotice(acptr, "*** You were forced to join %s", jbuf);_\t\t\t//sendnotice(acptr, "*** You were forced to join %s", jbuf);_g' $SOURCE/src/modules/m_sapart.c
94
+	rm -r $SOURCE/doc/conf/aliases $SOURCE/doc/conf/examples $SOURCE/doc/conf/help
95
+	rm -r $SOURCE/doc/conf/*.conf
96
+	cp $HOME/dev/git/supernets/unrealircd/doc/conf/*.conf $SOURCE/doc/conf/
97
+	cp $HOME/dev/git/supernets/unrealircd/src/ssl.cnf $SOURCE/src/ssl.cnf
98
 }
99
 
100
 deploy() {
101
-	setup
102
+	git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE
103
+	cd $SOURCE && echo -e "\n" | ./Config -nointro && make && make install && cd $HOME && rm -rf $SOURCE
104
+	rm $UNREAL/conf/*.conf
105
 	read -p "Link Name: " NAME
106
 	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)
107
-	echo "[NOTE] - Your remote include should be in https://USERNAME:PASSWORD@HOSTNAME:PORT format"
108
+	echo "[NOTE] - Your remote include should be in http(s)://USERNAME:PASSWORD@HOSTNAME:PORT format"
109
 	read -p "Remote Include: " REMOTE
110
 	for item in aliases badwords except help ircd modules opers spamfilter; do echo $REMOTE/$item.conf >> $UNREAL/conf/unrealircd.conf; done
111
 	echo "me { name \"$NAME.supernets.org\"; info \"SuperNETs IRC Network\"; sid $SID; }" >> $UNREAL/conf/unrealircd.conf
112
 	SPKI=$($UNREAL/unrealircd spkifp | sed -n 5p)
113
 	echo -e "\nAdd the following line into the hub\'s links.conf file for this link:\n$SPKI"
114
+	$UNREAL/unrealircd start &
115
 }
116
 
117
 update() {
118
-	#todo: check & kill abduco watchdog process
119
 	[ ! -z $(screen -ls | grep ircdwatchdog) ] && screen -S ircdwatchdog -X quit
120
+	[ ! -z $(abduco     | grep ircdwatchdog) ] && pkill -9 $(abduco | grep ircdwatchdog | awk '{print $4}')
121
 	mkdir $BACKUP
122
 	cp $UNREAL/conf/unrealircd.conf $BACKUP && cp $UNREAL/conf/ssl/server.*.pem $BACKUP
123
+	#cp $UNREAL/conf/links.conf $BACKUP && cp $UNREAL/conf/modules.conf $BACKUP && cp $UNREAL/conf/opers.conf $BACKUP
124
 	$UNREAL/unrealircd stop
125
 	rm -rf $UNREAL
126
-	setup
127
-	mv $BACKUP/unrealircd.conf $UNREAL/conf/ && mv $BACKUP/server.*.pem $UNREAL/conf/ssl
128
+	git clone --depth 1 https://github.com/supernets/unrealircd.git $SOURCE
129
+	cd $SOURCE && echo -e "\n" | ./Config -nointro && make && make install && cd $HOME && rm -rf $SOURCE
130
+	mv $BACKUP/*.conf $UNREAL/conf/ && mv $BACKUP/server.*.pem $UNREAL/conf/ssl
131
 	rm -r $BACKUP
132
 	$UNREAL/unrealircd start
133
 	watchdog
134
diff --git a/monitor b/monitor
135
new file mode 100755
136
index 0000000..b248485
137
--- /dev/null
138
+++ b/monitor
139
@@ -0,0 +1,8 @@
140
+#!/bin/sh
141
+while true; do
142
+	for i in $(dig irc.supernets.org A irc.supernets.org AAAA +short); do
143
+		ping -c 1 $i &> /dev/null
144
+		[ $? -ne 0 ] && echo "`date`: ping failed! ($i)" #&& notify-send "`date`: ping failed! ($i)"
145
+	done
146
+	sleep 3600
147
+done
148
diff --git a/updates.py b/updates.py
149
deleted file mode 100644
150
index d12ec05..0000000
151
--- a/updates.py
152
+++ /dev/null
153
@@ -1,56 +0,0 @@
154
-#!/usr/bin/env python
155
-import re, urllib.request
156
-
157
-anope_version      = '2.0.6'
158
-bootstrap_version  = '4.0.0'
159
-jquery_version     = '3.3.1'
160
-unrealircd_version = '4.0.17'
161
-
162
-def between(source, start, stop):
163
-	data = re.compile(start + '(.*?)' + stop, re.IGNORECASE|re.MULTILINE).search(source)
164
-	return data.group(1) if data else False
165
-
166
-def get_source(url):
167
-	req = urllib.request.Request(url)
168
-	req.add_header('User-Agent', 'DickServ/1.0')
169
-	source = urllib.request.urlopen(req, timeout=10)
170
-	charset = source.headers.get_content_charset()
171
-	return source.read().decode(charset) if charset else source.read().decode()
172
-
173
-def update_anope()      : return between(get_source('http://www.anope.org/'), '<span>Latest Stable Release:</span> Anope ', '\n')
174
-def update_bootstrap()  : return between(get_source('http://getbootstrap.com/'), '<p>Currently v', '. Code licensed')
175
-def update_jquery()     : return between(get_source('http://jquery.com/'), '<span>v', '</span>')
176
-def update_unrealircd() : return between(get_source('http://www.unrealircd.org/docs/FAQ'), '<p>The latest <b>Stable</b> version is <b>', '</b>')
177
-
178
-latest_anope = update_anope()
179
-if latest_anope:
180
-	if latest_anope != anope_version:
181
-		print(f'Anope version {latest_anope} has been released!')
182
-	else:
183
-		print('Anope is up to date.')
184
-else:
185
-	print('[!] - Can not retrieve latest Anope version.')
186
-latest_bootstrap = update_bootstrap()
187
-if latest_bootstrap:
188
-	if latest_bootstrap != bootstrap_version:
189
-		print(f'Bootstrap version {latest_bootstrap} has been released!')
190
-	else:
191
-		print('Bootstrap is up to date.')
192
-else:
193
-	print('[!] - Can not retrieve latest Bootstrap version.')
194
-latest_jquery = update_jquery()
195
-if latest_jquery:
196
-	if latest_jquery != jquery_version:
197
-		print(f'jQuery version {latest_jquery} has been released!')
198
-	else:
199
-		print('jQuery is up to date.')
200
-else:
201
-	print('[!] - Can not retrieve latest jQuery version.')
202
-latest_unrealircd = update_unrealircd()
203
-if latest_unrealircd:
204
-	if latest_unrealircd != unrealircd_version:
205
-		print(f'UnrealIRCd version {latest_unrealircd} has been released!')
206
-	else:
207
-		print('UnrealIRCd is up to date.')
208
-else:
209
-	print('[!] - Can not retrieve latest UnrealIRCd version.')