-
Notifications
You must be signed in to change notification settings - Fork 1
/
master_create_and_setup.sh
265 lines (219 loc) · 9.95 KB
/
master_create_and_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash
##################################################### Owner Information ###################################################
## ##
## Created by Robert "Red" English (KsaRedFx) for open source use under the licence "Creative Commons ##
## Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) Feel free to use this script for any reason as long as you follow ##
## the rules of the licence found here: http://creativecommons.org/licenses/by-sa/3.0/ ##
## Basically this just means that you have to credit me and inform me when you are using it, or any part of it ##
## commercially, even with editing, then licence that work under a similar licence to this one. ##
## ##
## "Red" on irc.ospnet.org #sllabs or #castlestoryonline ##
## @KsaRedFx on Twitter ##
## http://brokengear.net ##
## ##
####################################################### Instructions ######################################################
## ##
## Make sure to run the file in a fresh user for the ircd and to follow the promted questions and instructions closely ##
## ##
########################################################## Purpose ########################################################
## ##
## This script was developed to give you a simple and easy way to install an ircd and syncronise it with the repos ##
## ##
## ##
###########################################################################################################################
echo "Please pick what part of the script you'd like to run"
echo "1) Intial Setup"
echo "2) Syncronisation"
echo "3) Install IRCD Remotely"
if [ $que = 1 ] ; then
echo "Initial Setup Starting"
echo "Are you sure this is what you want to do? (y/n)"
read answer
if [ $answer != y ] ; then
echo "Exiting"
exit
fi
echo "Please enter the IRC network's domain, example: ospnet.org"
read domain
echo "The IRC network's domain is $domain"
echo "Is this correct? (y/n)"
read answer
if [ $answer != y ] ; then
echo "Exiting"
exit
fi
echo "Creating Directories"
mkdir -p ~/.repo
mkdir -p ~/.repo/keys
mkdir -p ~/.repo/leaves
mkdir -p ~/.repo/base
mkdir -p ~/config
echo "Creating Links"
ln -s ~/.repo/keys ~/config/keys
ln -s ~/.repo/leaves ~/config/leaves
ln -s ~/.repo/base ~/config/base
echo "Initialising Git"
cd git && git init
echo "Generating Key"
ssh-keygen -t rsa -C "Git Master@$domain"
cat ~/.ssh/id_rsa.pub > ~/configs/keys/authorized_keys
echo "Please keep this key handy"
cat ~/configs/keys/authorized_keys
echo "Copying default configs"
cp -R ~/IRCSetupScripts/config/* ~/config/base
echo "Generating syncronisation script"
echo "#"\!"/bin/bash
sh .confs.sh
cd ~/.repo
git add .
git commit -am 'Snyc Update" > sync
echo "#"\!"/bin/bash
for item in ircd.motd ircd.conf operators.conf general.conf
do
done"
echo ""
echo "#####################################################################"
echo "Generating SSL Certificate, Key, and DH Params"
echo "You will be asked several questions, so pay attention"
echo "#####################################################################"
echo ""
cd ~/config/base
echo "Generating self-signed certificate ... "
openssl req -x509 -nodes -newkey rsa:1024 -keyout ssl.key -out ssl.cert
echo "Generating Diffie-Hellman file for secure SSL/TLS negotiation ... "
openssl dhparam -out dh.pem 2048
fi
if [ $que = 2 ] ; then
echo "Syncing"
sh sync
echo "Complete"
fi
if [ $que = 3 ] ; then
echo ""
echo "Please enter your new leaf's name, example: Opal"
read name
echo "Please enter your new leaf's IP, example: 184.164.131.180"
read network
echo "Please enter the name of the user you are installing the IRCD to"
read user
echo ""
echo "Server's name is $name"
echo "Server's IP is $network"
echo "Server's user is $user"
echo "Is this correct? (y/n)"
read answer
if [ $answer != y ] ; then
echo "Exiting"
exit
fi
if [ $bypass != y ] ; then
echo ""
echo "Please enter your IRC Network's name, example: OSPnet"
read ircname
echo "Please enter the IRC Network's root domain, example: ospnet.org"
read domain
echo ""
echo "The IRC Network's name is $ircname"
echo "The root domain name is $domain"
echo "Is this correct? (y/n)"
read answer
if [ $answer != y ] ; then
echo "Exiting"
exit
fi
echo ""
echo "Please place the below key in authorized_keys on the remote server"
echo ""
cat ~/.ssh/id_rsa.pub
echo ""
echo "Is this complete? (y/n)"
read answer
if [ $answer != y ] ; then
echo "Exiting"
exit
fi
fi
if [ $info != y ] ; then
echo ""
echo "#####################################################################"
echo "Before you let this script continue, please make sure you've installed all the required packages"
echo "To do so, please run 'sudo apt-get install -y build-essential git bison flex libssl-dev'"
echo ""
echo "If you don't do this then the install will probably fail"
echo "#####################################################################"
echo ""
echo "Is this complete? (y/n)"
read answer
if [ $answer != y ] ; then
echo "Exiting"
exit
fi
fi
cd ~
echo "Continuing"
echo "Editing the sync script"
sed -i "5irsync -vue ~/config/leaves/$name.conf ssh $user@$network:ircd/etc/server.conf" sync
sed -i "5irsync -vue ~/config/base/\$item ssh $user@$network:ircd/etc" .confs.sh
sed -i "5irsync -vue ~/config/keys/authorized_keys ssh $user@$network:.ssh/authorized_keys" sync
echo "Preparing the IRCD install"
echo "git clone git://github.com/snoonetIRC/charybdis.git && cd charybdis" > inst.sh
echo './configure --prefix="$PWD/ircd" --enable-epoll --enable-openssl --enable-ipv6 --disable-assert' >> inst.sh
echo "make" >> inst.sh
echo "make install" >> inst.sh
echo "rm inst.sh" >> inst.sh
rsync -vue ~/inst ssh $user@$network:inst
ssh $user@network sh inst
echo "Install of IRCD Complete"
echo "Setting up Config File"
echo "listen {" > ~/config/leaves/$name.conf
echo " port = 5000, 6667 .. 6669;" >> ~/config/leaves/$name.conf
echo " sslport = 6697;" >> ~/config/leaves/$name.conf
echo "};" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo "serverinfo {" >> ~/config/leaves/$name.conf
echo " name = \"$name.$domain\";" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " sid = \"<unique digit, letter, letter>\";" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " description = \"$ircname leaf node.\";" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " network_name = \"$ircname.\";" >> ~/config/leaves/$name.conf
echo " network_desc = \"$ircname network.\";" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " hub = no;" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " vhost = \"$network\";" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " ssl_private_key = \"etc/ssl.key\";" >> ~/config/leaves/$name.conf
echo " ssl_cert = \"etc/ssl.cert\";" >> ~/config/leaves/$name.conf
echo " ssh_dh_params = \"etc/dh.pem\";" >> ~/config/leaves/$name.conf
echo " ssld_count = 5;" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " default_max_clients = 1000;" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo " nicklen = 30;" >> ~/config/leaves/$name.conf
echo "};" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo "admin {" >> ~/config/leaves/$name.conf
echo " name = \"$ircname admin.\";" >> ~/config/leaves/$name.conf
echo " description = \"$ircname administrator.\";" >> ~/config/leaves/$name.conf
echo " email = \"support@$domain\";" >> ~/config/leaves/$name.conf
echo "};" >> ~/config/leaves/$name.conf
echo "" >> ~/config/leaves/$name.conf
echo "connect \"<hub name>.$domain\" {" >> ~/config/leaves/$name.conf
echo " host = \"<hub IP>\";" >> ~/config/leaves/$name.conf
echo " send_password = \"<password hub is expecting>\";" >> ~/config/leaves/$name.conf
echo " accept_password = \"<password your new server will expect from hub>\";" >> ~/config/leaves/$name.conf
echo " port = 22223;" >> ~/config/leaves/$name.conf
echo " hub_mask = \"*\";" >> ~/config/leaves/$name.conf
echo " class = \"server\";" >> ~/config/leaves/$name.conf
echo " flags = autoconn, compressed, topicburst, ssl;" >> ~/config/leaves/$name.conf
echo "};" >> ~/config/leaves/$name.conf
echo ""
echo "####################################################################"
echo "Config file setup and placed in ~/config/leaves/$name.conf"
echo "Please edit this file accordingly then run the sync option"
echo "####################################################################"
nano ~/config/leaves/$name.conf
sh ~/sync
fi