Created
May 12, 2012 17:21
-
-
Save fapestniegd/2667748 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#selfip=$(dig +short $(hostname -f)) | |
DOMAIN="websages.com" | |
ircd_servers=( "freyr" "odin" "thor" "loki" "vili" ) | |
ircd_int_ips=("172.16.0.1" "172.16.0.2" "172.16.0.3" "172.16.0.10" "172.16.0.11" ) | |
################################################################################ | |
IMONE=0 | |
for idx in `seq 0 $(expr ${#ircd_servers[@]} - 1)`;do | |
if [ "$(hostname -s)" == "${ircd_servers[${idx}]}" ];then | |
IMONE=1 | |
fi | |
done | |
# This *must* be initiated from a node that is not one of the irc servers... | |
if [ ${IMONE} -ne 1 ]; then | |
clear; | |
for idx in `seq 0 $(expr ${#ircd_servers[@]} - 1)`;do | |
if [ -z $1 ]; then | |
(cd $(dirname $0); scp -p $(basename $0) root@${ircd_servers[${idx}]}.${DOMAIN}:/tmp) | |
ssh root@${ircd_servers[${idx}]}.${DOMAIN} /bin/bash /tmp/$(basename $0) | |
fi | |
if [ "$1" == "${ircd_servers[${idx}]}" ]; then | |
(cd $(dirname $0); scp -p $(basename $0) root@${ircd_servers[${idx}]}.${DOMAIN}:/tmp) | |
ssh root@${ircd_servers[${idx}]}.${DOMAIN} /bin/bash /tmp/$(basename $0) | |
fi | |
done | |
exit 0; | |
fi | |
for idx in `seq 0 $(expr ${#ircd_servers[@]} - 1)`;do | |
if [ "$(hostname -s)" == "${ircd_servers[${idx}]}" ];then | |
selfip=${ircd_int_ips[${idx}]}; | |
selfname=${ircd_servers[${idx}]}; | |
fi | |
done | |
# | |
echo ${selfip} | |
################################################################################ | |
# Install the packages we'll need | |
# | |
dpkg -l | grep -q ircd-hybrid || apt-get install -y ircd-hybrid | |
dpkg -l | grep -q hybserv || apt-get install -y hybserv | |
if [ ! -f /etc/ircd-hybrid/ircd.conf.dist ]; then | |
cp /etc/ircd-hybrid/ircd.conf /etc/ircd-hybrid/ircd.conf.dist | |
fi | |
################################################################################ | |
# This stuff is the same on all nodes: | |
# | |
cat<<EOF >/etc/ircd-hybrid/ircd.conf | |
serverinfo { | |
name="${selfname}.vpn.${DOMAIN}"; | |
description = "ircd-hybrid 7.2-debian"; | |
network_name = "websages.com"; | |
network_desc = "just a bunch of people who like beer."; | |
hub = yes; | |
vhost = "${selfip}"; | |
#vhost6 = "3ffe:80e8:546::2"; | |
max_clients = 512; | |
}; | |
admin { | |
name = "ircmaster"; | |
description = "IRC Administrators"; | |
email = "<ircmaster@websages.com>"; | |
}; | |
log { | |
use_logging = yes; | |
fname_userlog = "logs/userlog"; | |
fname_operlog = "logs/operlog"; | |
fname_killlog = "logs/kill"; | |
fname_klinelog = "logs/kline"; | |
fname_glinelog = "logs/gline"; | |
log_level = L_INFO; | |
}; | |
class { | |
name = "users"; | |
ping_time = 2 minutes; | |
number_per_ip = 100; | |
max_number = 100; | |
sendq = 100 kbytes; | |
}; | |
class { | |
name = "restricted"; | |
ping_time = 1 minute 30 seconds; | |
number_per_ip = 1; | |
max_number = 100; | |
sendq = 60kb; | |
}; | |
class { | |
name = "opers"; | |
ping_time = 5 minutes; | |
number_per_ip = 10; | |
max_number = 100; | |
sendq = 100kbytes; | |
}; | |
class { | |
name = "server"; | |
ping_time = 5 minutes; | |
connectfreq = 5 minutes; | |
max_number = 5; | |
sendq=2 megabytes; | |
}; | |
listen { | |
host = "${selfip}"; | |
port = 6665 .. 6669; | |
}; | |
listen { | |
host = "127.0.0.1"; | |
port = 6665 .. 6669; | |
}; | |
auth { | |
user = "*@127.0.0.1"; | |
user = "*@172.16.0.1"; | |
user = "*@172.16.0.2"; | |
user = "*@172.16.0.3"; | |
user = "*@172.16.0.10"; | |
user = "*@172.16.0.11"; | |
spoof = "irc.websages.com"; | |
spoof_notice = yes; | |
exceed_limit = yes; | |
kline_exempt = yes; | |
gline_exempt = yes; | |
no_tilde = yes; | |
class = "opers"; | |
}; | |
auth { | |
user = "*@*"; | |
class = "users"; | |
#restricted = yes; | |
have_ident = no; | |
}; | |
#################################################################### | |
# This should probably be generated from ldap | |
# | |
operator { | |
name = "james"; | |
user = "whitejs@irc.websages.com"; | |
user = "whitejs@127.0.0.1"; | |
user = "whitejs@172.16.0.1"; | |
user = "whitejs@172.16.0.2"; | |
user = "whitejs@172.16.0.3"; | |
user = "whitejs@172.16.0.10"; | |
user = "whitejs@172.16.0.11"; | |
password = "\$1\$qt.mwB3o\$GJ9z4zrAfs2G7fK9JI5a71"; | |
class = "opers"; | |
global_kill = yes; | |
remote = yes; | |
kline = yes; | |
unkline = yes; | |
gline = yes; | |
die = yes; | |
rehash = yes; | |
nick_changes = yes; | |
admin = yes; | |
}; | |
EOF | |
################################################################################ | |
# This will depend on what node we're on, create connections for the other nodes | |
# | |
SECRETSALT=smeg | |
for idx in `seq 0 $(expr ${#ircd_servers[@]} - 1)`;do | |
if [ "${ircd_servers[${idx}]}" != "$(hostname -s)" ]; then | |
#send_pass=$(echo -n "$(hostname -f)-${ircd_servers[${idx}]}.{DOMAIN}"|md5sum|awk '{print $1}'|cut -b 1-10 ) | |
#recv_pass=$(echo -n "${ircd_servers[${idx}]}.${DOMAIN}-$(hostname -f)"|md5sum|awk '{print $1}'|cut -b 1-10 ) | |
send_pass=$(echo -n "${SECRETSALT}-${selfip}-${ircd_int_ips[${idx}]}"|md5sum|awk '{print $1}'|cut -b 1-10 ) | |
recv_pass=$(echo -n "${SECRETSALT}-${ircd_int_ips[${idx}]}-${selfip}"|md5sum|awk '{print $1}'|cut -b 1-10 ) | |
cat<<EOF >>/etc/ircd-hybrid/ircd.conf | |
connect { | |
name = "${ircd_servers[${idx}]}.vpn.${DOMAIN}"; | |
host = "${ircd_int_ips[${idx}]}"; | |
send_password = "${send_pass}"; | |
accept_password = "${recv_pass}"; | |
encrypted = no; | |
port = 6666; | |
hub_mask = "*"; | |
class = "server"; | |
autoconn = yes; | |
compressed = yes; | |
}; | |
shared { | |
name = "${ircd_int_ips[${idx}]}"; | |
user = "root@${ircd_int_ips[${idx}]}"; | |
}; | |
EOF | |
fi | |
done | |
################################################################################ | |
# More stuff common to all servers | |
# | |
cat<<EOF >>/etc/ircd-hybrid/ircd.conf | |
resv { | |
reason = "There are no services on this network"; | |
nick = "nickserv"; | |
nick = "chanserv"; | |
channel = "#services"; | |
reason = "Clone bots"; | |
nick = "clone*"; | |
}; | |
channel { | |
use_invex = yes; | |
use_except = yes; | |
use_knock = yes; | |
knock_delay = 5 minutes; | |
knock_delay_channel = 1 minute; | |
max_chans_per_user = 15; | |
quiet_on_ban = yes; | |
max_bans = 25; | |
default_split_user_count = 0; | |
default_split_server_count = 2; | |
no_create_on_split = no; | |
no_join_on_split = no; | |
disable_local_channels = no; | |
}; | |
serverhide { | |
flatten_links = no; | |
links_delay = 5 minutes; | |
hidden = no; | |
disable_hidden = no; | |
hide_servers = no; | |
}; | |
general { | |
oper_pass_resv = yes; | |
disable_remote_commands = no; | |
default_floodcount = 10; | |
failed_oper_notice = yes; | |
dots_in_ident=2; | |
dot_in_ip6_addr = yes; | |
min_nonwildcard = 4; | |
anti_nick_flood = yes; | |
max_nick_time = 20 seconds; | |
max_nick_changes = 5; | |
anti_spam_exit_message_time = 0 minutes; | |
ts_warn_delta = 30 seconds; | |
ts_max_delta = 5 minutes; | |
kline_with_reason = yes; | |
warn_no_nline = yes; | |
stats_o_oper_only=yes; | |
stats_P_oper_only=no; | |
stats_i_oper_only=masked; | |
stats_k_oper_only=masked; | |
caller_id_wait = 1 minute; | |
pace_wait_simple = 1 second; | |
pace_wait = 10 seconds; | |
short_motd = no; | |
ping_cookie = no; | |
no_oper_flood = yes; | |
true_no_oper_flood = yes; | |
idletime = 0; | |
max_targets = 4; | |
client_flood = 20; | |
message_locale = "standard"; | |
oper_only_umodes = bots, cconn, debug, full, skill, nchange, | |
rej, spy, external, operwall, locops, unauth; | |
oper_umodes = locops, servnotice, operwall, wallop; | |
#servlink_path = "/usr/lib/ircd-hybrid/servlink"; | |
default_cipher_preference = "BF/128"; | |
throttle_time = 10; | |
}; | |
glines { | |
enable = yes; | |
duration = 1 day; | |
logging = reject, block; | |
user = "god@I.still.hate.packets"; | |
name = "hades.arpa"; | |
action = reject, block; | |
user = "god@*"; | |
name = "*"; | |
action = block; | |
}; | |
modules { | |
path = "/usr/lib/ircd-hybrid/modules"; | |
path = "/usr/lib/ircd-hybrid/modules/autoload"; | |
module = "m_tburst.so"; | |
module = "m_opme.so"; | |
}; | |
EOF | |
################################################################################ | |
# | |
# | |
#/etc/hybserv/hybserv.conf | |
IRCPS=$(ps -ef | grep " /usr/sbin/ircd-hy[b]rid "|awk '{print $2}') | |
if [ -z "${IRCPS}" ]; then | |
/etc/init.d/ircd-hybrid restart | |
else | |
kill -HUP ${IRCPS} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment