#!/usr/bin/bash ####################################################################### #Script Name: svr_setup_deb.sh #Version: 1.6 #Description: Wrapper for installing deb server #Last Modify Date: 03102021 #Author:Brent Dacus #Email:brent[at]thedacus[dot]net ####################################################################### # Banner # ####################################################################### export COLUMNS=100 dasetup_banner() { cat <<"eot" ad88888ba d8" "8b ,d DdadPPYba, Y8, 88 HH 8b ,dPPYba, `Y8aaaaa, ,adPPYba, MM88MMM 88 88 8b,dPPYba, a8 44 88P' "8a `"""""8b, a8P_____88 88 88 88 88P' "8a 8b 55 88 d8 `8b 8PP""""""" 88 88 88 88 d8 D8 aa 88 'b8 Y8a a8P "8b, ,aa 88, "8a, ,a88 88b, ,a8" TTTYbbd8"' `lLYbbdP''ag "Y88888P" `"Ybbd8"' "Y888 `"YbbdP'Y8 88`YbbdP"' 88 88 eot cat <<"eot" Author: Brent Dacus eot } ####################################################################### # Variables # ####################################################################### cur_hostname="$(hostname)" serverip="$(hostname -I | awk '{print $1}')" serverip6="$(hostname -I | awk '{print $2}')" servername="$(hostname -s)" svrdomainname="$(hostname -d)" hstdomainname=thedacus.lan cpu_cores=1 cpu_cores="$(grep >(tee -a ${LOG_FILE}) 2>&1 aptargs="-y" export DA_EMAIL="tech@delainhosting.com" ####################################################################### # User Variables # ####################################################################### rootemail="tech@regularguy.info" bshrc="/root/.bashrc" limitsconf="/etc/security/limits.conf" sysctlconf="/etc/sysctl.conf" myconf="/etc/my.cnf" ####################################################################### # Main Util Functions # ####################################################################### mkdir -p ~/svrsetupbuild/ trap '' 2 # ignore ctrl+c ##set PS3 prompt## PS3="Number selection? " linebreak() { printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - } do_install() { printf "Installing %s into %s.\n" "${1}" "${dir}" cd "${dir}" || exit if [ -f "${1}" ]; then rm -f "${1}.bak" cp -f "${1}" "${1}.bak" chmod 600 "${1}.bak" fi wget --no-check-certificate -q -O "${1}" "${2}" chmod 755 "${1}" #chown diradmin:diradmin "${1}" } do_setting() { printf "Installing value %s into %s.\n" "${1}" "${2}" printf 'Adding values in to %s.\n Please wait.\n' "${2}" if ! grep -q '#added by DH.' "${2}"; then echo '#added by DH.' >>"${2}" fi if grep -q \\"${1}" "${2}"; then printf '%s exists.\n Skipping.\n' "${1}" else printf '%s does not exist\n' "$1" echo "${1}" >>"${2}" fi } doreboot() { printf "Need to reboot? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) reboot ;; [Nn]*) ;; esac } cycleswap() { printf "Cycling Swapfile.\n" swapoff -a sleep 10 swapon -a } ####################################################################### # Add Admin User # ####################################################################### addadminuser() { printf "Installing Standard packages.\n" printf "Please Wait.\n" apt-get install ${aptargs} perl wget curl nano btop >/dev/null bshrvals=("alias fbc='fail2ban-client status '" "export EDITOR='nano'") printf 'Adding values in to %s.\n Please wait.\n' "$bshrc" for bshrval in "${bshrvals[@]}"; do if grep -q "$bshrval" ${bshrc}; then printf '%s exists.\n Skipping.\n' "$bshrval" else printf '%s does not exist\n' "$bshrval" printf '#added by DH.\n' >>${bshrc} printf '%s\n' "$bshrval" >>${bshrc} fi done if ! grep -q daconf /root/.bashrc; then printf 'Bash shell profile not set up. adding...\n' cat <<"eol" >>/root/.bashrc export EDITOR='nano' export LS_OPTIONS='--color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias lh='history |grep ' alias search='find / -name ' alias doserver='curl -o svr_setup_deb.sh -L https://files.delaintech.com/svr_setup_deb.sh && bash svr_setup_deb.sh' alias fbc='fail2ban-client status ' alias cycle='systemctl restart ' alias status='systemctl status ' eol printf "Print Profile File.\n" cat /root/.bashrc printf "Done.\n" else printf "Profile already setup. See Below.\n" cat /root/.bashrc fi } ####################################################################### # Turn on IPV6 # ####################################################################### setipv6() { printf "Do we need to turn on IPV6? REBOOT REQUIRED (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) sed -i "/net.ipv6.conf.all.disable_ipv6.*/d" /etc/sysctl.conf sysctl -q -p echo 0 >/proc/sys/net/ipv6/conf/all/disable_ipv6 doreboot ;; [Nn]*) ;; esac } ####################################################################### # Set Timezone # ####################################################################### settimezone() { printf "What TimeZone are you in? [America/Chicago]: " read -r tmzone tmzone=${tmzone:-America/Chicago} if timedatectl | grep -q "America/Chicago"; then printf "%s found\n" "$tmzone" else timedatectl set-timezone "$tmzone" timedatectl set-local-rtc 0 printf "We set timezone as:\n" timedatectl printf "Done.\n" fi } ####################################################################### # Add Hosts file # ####################################################################### creathostfile() { # does the Host already exist? if ! grep -q ${hstdomainname} /etc/hosts; then printf 'Hostfile not found. adding...\n' cat <<"eol" >>/etc/hosts # This host address 172.20.0.1 dacusrtr01.thedacus.lan dacusrtr01 172.20.10.1 dacusmainsw01.thedacus.lan dacusmainsw01 172.20.10.2 dacuspowsw01.thedacus.lan dacuspowsw01 172.20.10.3 dacustvboxsw01.thedacus.lan dacustvboxsw01 172.20.10.4 brentsofficeswi01.thedacus.lan brentsofficeswi01 172.20.10.5 dacusswitch03.thedacus.lan dacusswitch03 172.20.10.20 brentsoffice.thedacus.lan brentsoffice 172.20.10.21 upstairshallway.thedacus.lan upstairshallway 172.20.10.22 masterbedrom.thedacus.lan masterbedrom 172.20.10.30 nasalaser01.thedacus.lan nasalaser01 172.20.10.53 dns01.thedacus.lan dns01 172.20.10.54 dns02.thedacus.lan dns02 172.20.20.2 mox01.thedacus.lan mox01 172.20.20.3 moxbkup01.thedacus.lan moxbkup01 172.20.20.4 moby.thedacus.lan moby 172.20.20.7 dacuspbx.thedacus.lan dacuspbx 172.20.20.8 forgejo01.thedacus.lan forgejo01 172.20.20.9 dacusomada.thedacus.lan dacusomada 172.20.20.10 dacusnas.thedacus.lan dacusnas 172.20.30.1 dacusha01.thedacus.lan dacusha01 172.20.30.3 alarm01.thedacus.lan alarm01 172.20.30.4 dacuslutron01.thedacus.lan dacuslutron01 172.20.30.5 dacuswater01.thedacus.lan dacuswater01 172.20.30.20 drivewaycam.thedacus.lan drivewaycam 172.20.30.21 backdoorcam.thedacus.lan backdoorcam 172.20.30.22 frontdoorcam.thedacus.lan frontdoorcam 172.20.30.23 frontdoorbell.thedacus.lan frontdoorbell 172.20.30.36 dacushomerun.thedacus.lan dacushomerun 172.20.30.40 dacusemby01.thedacus.lan dacusemby01 eol printf "Print Host File.\n" cat /etc/hosts printf "Done.\n" else printf "Hostfile exsits.\nSee Below.\n" cat /etc/hosts fi } ####################################################################### # Set Server Hostname # ####################################################################### creathostname() { setipv6 # does the Host already exist? unset new_hostname printf "Please enter a Hostname to add: " read -r new_hostname if ! grep -q "$new_hostname" /etc/hosts; then printf 'Hostname not found. adding...\n' printf "Changing hostname %s from to %s...\n" "$cur_hostname" "$new_hostname" hostnamectl set-hostname "$new_hostname" serverip="$(hostname -I | awk '{print $1}')" serverip6="$(hostname -I | awk '{print $2}')" servername="$(hostname -s)" echo "${serverip} ${new_hostname} ${servername}" >>/etc/hosts echo "${serverip6} ${new_hostname} ${servername}" >>/etc/hosts printf "Print Host File.\n" cat /etc/hosts printf "\nDone.\n" else printf "Hostname exsits.\nAll good.\n" fi } ####################################################################### # Remove Hostnames # ####################################################################### removehosts() { printf "Here is the Host file.\n" cat /etc/hosts printf "\nWhat is the server name or ip to remove? " read -r removehosts sed -i.bkp '/'$removehosts'/d ' /etc/hosts printf "Print Host.\n" cat /etc/hosts printf "\nDone.\n" while true; do printf "Continue removing? (y/n)?" read -r yn yn=${yn:-n} case $yn in [Yy]*) removehosts break ;; [Nn]*) break ;; esac done } ####################################################################### # Add External Hosts # ####################################################################### addhosts() { # does the Host already exist? unset serverip add_hostname servername printf "Enter Hostname to add:[ IP FDQN Hostname ]: " read -r serverip add_hostname servername if ! grep -q "$add_hostname" /etc/hosts; then printf 'Hostname not found. adding...\n' echo "${serverip} ${add_hostname} ${servername}" | tee -a /etc/hosts printf "Print Host File.\n" cat /etc/hosts printf "Done.\n" else printf "Hostname exsits.\nAll good.\n" fi while true; do printf "Continue adding? (y/n)?" read -r yn yn=${yn:-n} case $yn in [Yy]*) creathostentry break ;; [Nn]*) break ;; esac done } ####################################################################### # Add Swapfile # ####################################################################### creatswapfile() { printf 'Enter Swapfile size in GB: ' read -r swapsize swapsize=${swapsize:-2} printf "You choose %s GB for swap.\n" "$swapsize" # does the swap file already exist? cp /etc/fstab /etc/fstab.bak # if not then create it if ! grep -q "swap" /etc/fstab; then printf 'Swap file not found.\nCreating Swap file.\n' fallocate -l "${swapsize}"G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile printf "/swapfile none swap defaults 0 0" | tee -a /etc/fstab printf "\nDone\nSwap should be active.\nIf not reboot.\n" else printf 'Swap file found.\nNo changes made.\n' fi } ####################################################################### # Update OS on Server # ####################################################################### serverupdate() { printf "Debian Cleaning and Updating.\n" apt-get ${aptargs} autoremove apt-get autoclean apt-get ${aptargs} update apt-get ${aptargs} upgrade apt-get ${aptargs} dist-upgrade printf "Done.\n" } ####################################################################### # Install Standard Packages # ####################################################################### installpreq() { printf "Run Pre Install? (y/n)?" read -r yn yn=${yn:-n} case $yn in [Yy]*) apt-get install ${aptargs} nano git apt-transport-https btop screen tuned pcregrep rsync ;; [Nn]*) ;; esac printf "Set forward email? (y/n)?" read -r yn yn=${yn:-n} case $yn in [Yy]*) printf "Email set to %s.\n" "$DA_EMAIL" #printf "Nameservers set to %s and %s.\n" "$DA_NS1" "$DA_NS2" echo ${DA_EMAIL} >/root/.forward printf "Email forward set to %s.\n" "$DA_EMAIL" linebreak tuned-adm profile virtual-host printf "Done.\n" ;; [Nn]*) ;; esac } ####################################################################### # Harden Server # ####################################################################### hardenserver() { printf "Do we need to Secure sshd? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) cursshport="$(grep -m1 -E "Port .*" /etc/ssh/sshd_config)" printf "Enter SSH port to change to: " read -r sshport sshport=${sshport:-14} printf "Set to Port: %s\n" "$sshport" printf "Securing the server, please wait...\n" sed -i -e "s/$cursshport/Port ${sshport}/g" /etc/ssh/sshd_config sed -i -e 's/.*UseDNS .*/UseDNS no/g' /etc/ssh/sshd_config sed -i -e 's/#AddressFamily any/AddressFamily inet/g' /etc/ssh/sshd_config sed -i -e 's/#LoginGraceTime 2m/LoginGraceTime 2m/g' /etc/ssh/sshd_config sed -i -e 's/#MaxAuthTries 6/MaxAuthTries 5/g' /etc/ssh/sshd_config sed -i -e 's/#MaxStartups 10:30:100/MaxStartups 10:30:100/g' /etc/ssh/sshd_config sed -i -e 's/.*PermitRootLogin yes/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config sed -i -e 's/.*PasswordAuthentication .*/PasswordAuthentication no/g' /etc/ssh/sshd_config sed -i -e 's/#ClientAliveInterval .*/ClientAliveInterval 120/g' /etc/ssh/sshd_config sed -i -e 's/#ClientAliveCountMax .*/ClientAliveCountMax 15/g' /etc/ssh/sshd_config sed -i -e 's/.*PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config sed -i -e 's/.*AuthorizedKeysFile .*/AuthorizedKeysFile .*/g' /etc/ssh/sshd_config systemctl restart sshd ;; [Nn]*) ;; esac if [[ $(systemctl is-active rpcbind) = active ]]; then printf "rpcbind found.\nRemoving.\n" systemctl stop rpcbind systemctl disable rpcbind printf "Removal complete.\n" else printf "RPCbind not found.\nNo changes made.\n" fi if [[ $(systemctl is-active firewalld) = active ]]; then printf "Firewalld found.\nRemoving.\n" systemctl unmask --now firewalld systemctl disable firewalld apt-get ${aptargs} remove firewalld printf "Removal complete.\n" else printf "Firewalld not found.\nNo changes made.\n" fi printf "Do we need to intall Fail2Ban? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) installf2b ;; [Nn]*) ;; esac } ####################################################################### # Install Fail2Ban # ####################################################################### installf2b() { if [[ $(systemctl is-active fail2ban) = active ]]; then printf "Fail2Ban already Installed.\nUpdating configuration.\n" sed -i -e "s|dbpurgeage = .*|dbpurgeage = 1296000|g" /etc/fail2ban/fail2ban.conf printf "Which webserver are we using? (Nginx-Apache) \n" echo "1 Apache" echo "2 Nginx" echo "3 Nginx-Apache" read -r websrv websrv=${websrv:-1} case $websrv in 1) wget -rnH --cut-dirs=3 https://files.delaintech.com/f2b/da/ap/jail.local -P /etc/fail2ban/ ;; 2) wget -rnH --cut-dirs=3 https://files.delaintech.com/f2b/da/ngx/jail.local -P /etc/fail2ban/ ;; 3) wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/jail.local -P /etc/fail2ban/ ;; *) echo "Please choose a different one." ;; esac wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/fail2ban -P /etc/logrotate.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/paths-overrides.local -P /etc/fail2ban/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/abuseipdb.conf -P /etc/fail2ban/action.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/csf-ip-deny.conf -P /etc/fail2ban/action.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/wordpress.conf -P /etc/fail2ban/filter.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/wordpress-xmlrpc.conf -P /etc/fail2ban/filter.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/proftpd-anon.conf -P /etc/fail2ban/filter.d/ sed -i -e "s|comment=Fail2ban Reports Abuse.|comment=Fail2ban at $servername Reports Abuse.|g" /etc/fail2ban/action.d/abuseipdb.conf sed -i -e "s|mode = .*|mode = aggressive|g" /etc/fail2ban/filter.d/exim.conf touch /var/www/html/roundcube/logs/errors.log systemctl restart fail2ban systemctl status fail2ban ${da} set bruteforce 0 ${da} set brute_force_log_scanner 0 ${da} set brute_force_scan_apache_logs 0 else printf "Fail2Ban Installing.\nAlso turning off BFM in DA.\n" apt-get install ${aptargs} fail2ban iptables geoip-bin geoip-database python3-pyinotify systemctl enable fail2ban systemctl start fail2ban printf "Which webserver are we using? (Nginx-Apache) \n" echo "1 Apache" echo "2 Nginx" echo "3 Nginx-Apache" read -r websrv websrv=${websrv:-1} case $websrv in 1) wget -rnH --cut-dirs=3 https://files.delaintech.com/f2b/da/ap/jail.local -P /etc/fail2ban/ ;; 2) wget -rnH --cut-dirs=3 https://files.delaintech.com/f2b/da/ngx/jail.local -P /etc/fail2ban/ ;; 3) wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/jail.local -P /etc/fail2ban/ ;; *) echo "Please choose a different one." ;; esac sed -i -e "s|dbpurgeage = .*|dbpurgeage = 1296000|g" /etc/fail2ban/fail2ban.conf wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/paths-overrides.local -P /etc/fail2ban/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/abuseipdb.conf -P /etc/fail2ban/action.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/csf-ip-deny.conf -P /etc/fail2ban/action.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/wordpress.conf -P /etc/fail2ban/filter.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/wordpress-xmlrpc.conf -P /etc/fail2ban/filter.d/ wget -rnH --cut-dirs=2 https://files.delaintech.com/f2b/da/proftpd-anon.conf -P /etc/fail2ban/filter.d/ sed -i -e "s|comment=Fail2ban Reports Abuse.|comment=Fail2ban at $servername Reports Abuse.|g" /etc/fail2ban/action.d/abuseipdb.conf sed -i -e "s|mode = .*|mode = aggressive|g" /etc/fail2ban/filter.d/exim.conf touch /var/www/html/roundcube/logs/errors.log systemctl restart fail2ban ${da} set bruteforce 0 ${da} set brute_force_log_scanner 0 ${da} set brute_force_scan_apache_logs 0 fi bshrvals=("alias fbc='fail2ban-client status '") printf 'Adding values in to %s.\n Please wait.\n' "$bshrc" for bshrval in "${bshrvals[@]}"; do if grep -q "$bshrval" ${bshrc}; then printf '%s exists.\n Skipping.\n' "$bshrval" else printf '%s does not exist\n' "$bshrval" printf '#added by DH.\n' >>${bshrc} printf '%s\n' "$bshrval" >>${bshrc} fi done } ####################################################################### # Install Mysqltuner # ####################################################################### installmysqltuner() { cd /usr/bin || exit wget http://mysqltuner.pl/ -O mysqltuner wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv chmod +x mysqltuner } ####################################################################### # Install Maldetect # ####################################################################### installmaldetect() { cd $builddir || return wget https://www.rfxn.com/downloads/maldetect-current.tar.gz tar -xzf maldetect-*.tar.gz rm -rf maldetect-*.tar.gz cd maldetect* || return sh install.sh wget https://files.delaintech.com/conf.maldet -O conf.maldet \cp -f conf.maldet /usr/local/maldetect/ maldet -u fi } ####################################################################### # Main Configure Section # ####################################################################### ####################################################################### # Configure DNS # ####################################################################### confnamed() { sed -i -e "s|.*listen-on-v6[[:blank:]]*.{ any; };||g" /etc/bind/named.conf.options sed -i -e "s|.*allow-transfer[[:blank:]]*.{ none; };||g" /etc/bind/named.conf.options if ! grep -q "recursion no;" /etc/bind/named.conf.options; then printf "Setting up DNS.\n" cp /etc/bind/named.conf.options /etc/bind/named.conf.options.bak sed -i.bkp '/dnssec-validation yes;/a\ listen-on { '"$serverip"'; };\ listen-on-v6 { '"$serverip6"'; };\ dnssec-enable yes;\ dnssec-lookaside auto;\ bindkeys-file "/etc/bind/named.iscdlv.key";\ recursion no;\ notify yes;\ allow-transfer { 209.145.52.110; 144.91.108.77; };\ also-notify { 209.145.52.110; 144.91.108.77; };\ version "Not Found";\ ' /etc/bind/named.conf.options else printf "DNS Setup Complete.\n" fi printf "Standard Namesevers or Custom? (Standard) \n" echo "1 Standard" echo "2 Custom" read -r nssrv nssrv=${nssrv:-1} case $nssrv in 1) ${da} set ns1 "dns3.${svrdomainname}" ${da} set ns2 "dns2.${svrdomainname}" ;; 2) unset ns1 printf "What is the NS1 you would like to set? (fdqn) " read -r ns1 ${da} set ns1 "$ns1" unset ns2 printf "What is the NS2 you would like to set? (fdqn) " read -r ns2 ${da} set ns2 "$ns2" ;; *) echo "Please choose a different one." ;; esac apt-get remove resolvconf echo 'make_resolv_conf() { :; }' >/etc/dhcp/dhclient-enter-hooks.d/leave_my_resolv_conf_alone chmod 755 /etc/dhcp/dhclient-enter-hooks.d/leave_my_resolv_conf_alone if ! grep -q "9.9.9.9" /etc/resolv.conf; then printf "Setup Resolver configuration.\n" cat >/etc/resolv.conf <&1 OS_VER=$(sed 's/\..*//' /etc/debian_version) if [ "$OS_VER" = 11 ]; then printf "This appears to be Debian version %s which is Good!!\n" "$OS_VER" elif [ "$OS_VER" = 12 ]; then printf "This appears to be Debian version %s which is Better!!\n" "$OS_VER" else [ "$OS_VER" != 11 ] printf "System runs on unsupported Linux. Exiting...\n" exit fi #Menus Starts here linebreak printf "Hostname: %s Server IP: %s Server IPV6: %s \n" "$serverip" "$cur_hostname" "$serverip6" linebreak cat <<"eot" MAIN SERVER SETUP MENU eot linebreak while true; do options=("Add Admin User" "Timezone" "Host file" "Hostname" "Remove hosts" "Add hosts" "Swap file" "Update server" "Install Required Packages" "Harden Server" "Install Directadmin" "Install Firewall" "Install LetsEncrypt" "Install KernelCare" "Install ImmunifyAV" "Install Installatron" "Configure Directadmin" "Configure Named" "Configure Mail" "Configure Apache" "Configure MySql" "Configure Nginx" "Configure Proftpd" "Performance Tweaks" "Check Server Status" "Build All" "Backup Server Files" "Quit") printf "Choose an option: \n" select opt in "${options[@]}"; do case $REPLY in 1) addadminuser break ;; 2) settimezone break ;; 3) creathostfile break ;; 4) creathostname break ;; 5) removehosts break ;; 6) addhosts break ;; 7) creatswapfile break ;; 8) serverupdate break ;; 9) installpreq break ;; 10) hardenserver break ;; 11) installdirectadmin break ;; 12) installfirewall break ;; 13) installletsencrypt break ;; 14) installkernelcare break ;; 15) installimuav break ;; 16) installinstallatron break ;; 17) confdirectadmin break ;; 18) confnamed break ;; 19) confmail break ;; 20) confhttpd break ;; 21) confmysql break ;; 22) confnginx break ;; 23) confproftpd break ;; 24) perfmserver break ;; 25) serverstatus break ;; 26) buildalld break ;; 27) backupall break ;; 28) break 2 ;; *) echo "Invalid option. Try again." >&2 ;; esac done done if [ -d "$builddir" ]; then rm -rf $builddir fi mkdir $builddir if [ "$run" ]; then ${run} exit fi printf "Cleaning up build files, please wait...\n" cd ~ || exit rm -rf $builddir