Skip to content

Instantly share code, notes, and snippets.

@timwattenberg
Created July 2, 2014 09:05
Show Gist options
  • Save timwattenberg/a714096649c4122893d8 to your computer and use it in GitHub Desktop.
Save timwattenberg/a714096649c4122893d8 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo -e "=== danceComp-Server-Setup ===\n"
echo -e "+++ Adding users... +++"
adduser --gecos "" admin
echo
adduser --disabled-login --shell /bin/false --gecos "" tnw
echo -e "--- done. ---\n"
echo -e "+++ Setting hostname... +++"
read -p "Set hostname to [`cat /etc/hostname`]: " hostname
if [ $hostname ]; then
echo $hostname > /etc/hostname
/etc/init.d/hostname.sh
fi
echo -e "--- done. ---\n"
echo -e "+++ Updating Package-Lists and packages... +++"
echo "deb http://ftp.halifax.rwth-aachen.de/debian/ wheezy-backports main" > /etc/apt/sources.list.d/backports.list
apt-get update
apt-get upgrade
echo -e "--- done. ---\n"
echo -e "+++ Installing utils... +++"
apt-get -y install vim dnsutils curl
echo -e "--- done. ---\n"
echo -e "+++ Installing samba(-server)... +++"
apt-get -y install samba samba-doc
echo -e "--- done. ---\n"
echo -e "+++ Installing smbclient/cifs-utils... +++"
apt-get -y install smbclient cifs-utils
echo -e "--- done. ---\n"
echo -e "+++ Installing nfs-server... +++"
apt-get -y install nfs-kernel-server
echo -e "--- done. ---\n"
echo -e "+++ Installing munin (monitoring)... +++"
apt-get -y install munin
echo -e "--- done. ---\n"
echo -e "+++ Installing nginx (webserver)... +++"
apt-get -y install nginx
echo -e "--- done. ---\n"
echo -e "+++ Installing bind (dns-server)... +++"
apt-get -y install bind9 bind9-doc
echo -e "--- done. ---\n"
echo -e "+++ Installing node/npm... +++"
apt-get -y install nodejs nodejs-legacy
curl --insecure https://www.npmjs.org/install.sh | bash
echo -e "--- done. ---\n"
echo -e "+++ Configuring samba... +++"
mv /etc/samba/smb.conf /etc/samba/smb.conf.old
cat > /etc/samba/smb.conf <<__EOF__
# Global parameters
[global]
workgroup = TNW
server string = %h Samba %v Server
#netbios name = SAMBA
map to guest = bad user
log file = /var/log/samba/log.%m
#socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
#preferred master = no
#local master = no
dns proxy = no
security = user
#share modes = yes
#default = turnierdaten
# Shares
[turnierdaten]
path = /home/tnw
writeable = yes
#locking = no
#oplocks = no
#create mask = 666
#directory mask = 777
[admin]
path = /home/admin
__EOF__
service samba restart
echo -e "--- done. ---\n"
echo -e "+++ Configuring nginx... +++"
cat > /etc/nginx/sites-available/`cat /etc/hostname`.tnw <<__EOF__
server {
server_name `cat /etc/hostname`.tnw;
location /munin/static/ {
alias /etc/munin/static/;
expires modified +1w;
}
location /munin/ {
alias /var/cache/munin/www/;
expires modified +310s;
}
}
__EOF__
ln -s /etc/nginx/sites-available/`cat /etc/hostname`.tnw /etc/nginx/sites-enabled/`cat /etc/hostname`.tnw
service nginx restart
echo -e "--- done. ---\n"
echo -e "+++ Configuring bind... +++"
mv /etc/bind/named.conf.local /etc/bind/named.conf.local.old
cat > /etc/bind/named.conf.local <<__EOF__
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "tnw" {
type master;
file "/etc/bind/db.tnw";
};
__EOF__
cat > /etc/bind/db.tnw <<__EOF__
;; db.tnw
;; Zone für tnw
;;
\$TTL 1h
@ IN SOA `cat /etc/hostname`.tnw. root.tnw. (
0 ; Serial
8h ; Refresh
2h ; Retry
1w ; Expire
2h ) ; Negative Cache TTL
; DNS Server
@ IN NS server1.tnw.
@ IN NS server2.tnw.
server1 IN A 10.0.0.10
server2 IN A 10.0.0.11
__EOF__
service bind9 restart
echo -e "--- done. ---\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment