#!/bin/bash ################################################# # General ################################################# function install_base { # Set hostname echo serviette > /etc/hostname # Allow every user to use DNS resolution chmod a+r /etc/resolv.conf # Update package list aptitude -y update # Configure locales aptitude -y install locales cat > /etc/locale.gen < /etc/timezone dpkg-reconfigure -f noninteractive tzdata # Install basic tools aptitude -y install zsh vim less gzip git-core curl python g++ iw wpasupplicant wireless-tools bridge-utils screen tmux mosh ed strace cowsay figlet toilet at pv mmv iputils-tracepath tre-agrep urlscan urlview autossh elinks irssi-scripts ncftp sc byobu mc tree atop iftop iotop nmap antiword moreutils net-tools whois pwgen haveged usbutils w3m htop nethack-console } ################################################# # Network Settings ################################################# function configure_network { # The correct firmware should be installed and a wlan0 interface present as # a minimal requirement cat > /etc/network/interfaces <> /etc/hosts < /etc/rc.local < /proc/sys/net/ipv4/ip_forward # Masquerade outgoing traffic from interface eth0 and wlan1 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE # Block outgoing and forwarded communication with other PGP/GPG keyservers # but still enable local communication (nginx reverse proxy) iptables -A OUTPUT -o lo -j ACCEPT iptables -A OUTPUT -p TCP --dport 11371 -j REJECT iptables -A OUTPUT -p UDP --dport 11371 -j REJECT iptables -A FORWARD -p UDP --dport 11371 -j REJECT iptables -A FORWARD -p TCP --dport 11371 -j REJECT exit 0 EOF } # Run the rc.local to put firewall rules in place /etc/rc.local ################################################# # Wireless Access Point ################################################# function install_hostapd { # Install HostAPd aptitude -y install hostapd # Create cHostAPd configuration file cat - << EOF > /etc/hostapd/hostapd.conf interface=wlan0 driver=nl80211 country_code=DE ssid=serviette hw_mode=g channel=6 wpa=2 wpa_passphrase=serviette wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP auth_algs=1 macaddr_acl=0 EOF # Specify configuration file sed -i 's/#DAEMON_CONF=""/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/' /etc/default/hostapd # Restart HostAPd to adopt changes service hostapd restart } ################################################# # DNS & DHCP Server ################################################# function install_dnsmasq { # Install Dnsmasq aptitude -y install dnsmasq # Create Dnsmasq configuration cat - << EOF > /etc/dnsmasq.conf interface=wlan0 domain=serviette.lan dhcp-range=192.168.23.50,192.168.23.150,12h EOF # Restart Dnsmasq to adopt changes service dnsmasq restart } ################################################# # FTP Server ################################################# function install_ftpd { aptitude -y install vsftpd } ################################################# # HTTP Server ################################################# function install_httpd { # Install Nginx, FastCGI Wrapper and PHP5 (CGI) aptitude -y install nginx-light fcgiwrap php5-cgi php5-fpm # Make sure that every new users gets his own public_html mkdir /etc/skel/public_html # Allow HTTP server user to create new users, required for self-service portal cat > /etc/sudoers < /etc/nginx/sites-available/serviette.lan < /home/haste/run.sh #!/bin/bash cd ~/haste-server npm start EOF chown haste:haste /home/haste/run.sh chmod +x /home/haste/run.sh # Create haste-server config cat - << EOF > /home/haste/haste-server/config.js { "host": "0.0.0.0", "port": 7777, "keyLength": 10, "maxLength": 400000, "staticMaxAge": 86400, "recompressStaticAssets": true, "logging": [ { "level": "verbose", "type": "Console", "colorize": true } ], "keyGenerator": { "type": "phonetic" }, "storage": { "type": "file", "path": "./data" }, "documents": { "about": "./about.md" } } EOF # Install and configure haste-server init script wget https://github.com/serviette/serviette/raw/master/haste-server.init -O /etc/init.d/haste-server chmod +x /etc/init.d/haste-server mkdir /var/log/haste-server chown haste:haste /var/log/haste-server/ update-rc.d haste-server defaults # Start Etherpad-lite service haste-server start # Create and endable virtual host cat > /etc/nginx/sites-available/bin.serviette.lan < /etc/nginx/sites-available/pads.serviette.lan < /etc/prosody/conf.d/serviette.cfg.lua < /etc/sks/mailsync echo '# Empty - Do not communicate with other keyservers.' > /etc/sks/membership # Enable start via init script echo 'initstart=yes' > /etc/default/sks # Start Synchronizing OpenPGP Key Server service sks start cat > /etc/nginx/sites-available/keyserver.serviette.lan < /home/sharingiscaring/run.sh #!/bin/bash cd ~ export PORT=8090 ./node_modules/.bin/sharingiscaring EOF chown sharingiscaring:sharingiscaring /home/sharingiscaring/run.sh chmod +x /home/sharingiscaring/run.sh # Install and configure SharingIsCaring init script wget https://github.com/serviette/serviette/raw/master/sharingiscaring.init -O /etc/init.d/sharingiscaring chmod +x /etc/init.d/sharingiscaring mkdir /var/log/sharingiscaring chown sharingiscaring:sharingiscaring /var/log/sharingiscaring/ update-rc.d sharingiscaring defaults # Start SharingIsCaring service sharingiscaring start # Create and endable virtual host cat > /etc/nginx/sites-available/sic.serviette.lan < /etc/exim4/update-exim4.conf.conf dc_eximconfig_configtype='local' dc_other_hostnames='serviette.lan' dc_local_interfaces='127.0.0.1 ; ::1' dc_readhost='' dc_relay_domains='' dc_minimaldns='false' dc_relay_nets='' dc_smarthost='' CFILEMODE='644' dc_use_split_config='false' dc_hide_mailname='' dc_mailname_in_oh='true' dc_localdelivery='mail_spool' EOF # Create Exim configuration from configuration template update-exim4.conf # Restart Exim to adopt changes service exim4 restart } ################################################# # SMTP & IMAP Server/Client ################################################# function install_sipwitch { # Install Sipwitch aptitude -y install sipwitch # Automatically load available plugins sed -i 's/#PLUGINS=.*/PLUGINS="auto"/' /etc/default/sipwitch # Start Sipwitch /etc/init.d/sipwitch start } #install_base #configure_network #install_hostapd #install_dnsmasq #install_ftpd #install_httpd #install_nodejs #install_etherpad #install_haste #install_sharingiscaring #install_ikiwiki #install_sks #install_prosody #install_ngircd #install_bitlbee #install_email #install_sipwitch