#!/usr/bin/bash ####################################################################### #Script Name: poud_server_bsd.sh #Version: 1.6 #Description: Install for Pouderie on FreeBSD #Last Modify Date: 09242021 #Author:Brent Dacus #Email:brent[at]thedacus[dot]net ####################################################################### # Banner # ####################################################################### export COLUMNS=100 nssetupdeb_banner() { cat <<"eot" ad8888ba d8" "8b ,aiiiiia, ,d nnd8888bn Y8, 6' " 88 ns 'we `Y8aaaaa, `8aaaa, ,adPPYba, MM88MMM 88 88 8b,dPPYba, ns we `"""""8b, `"8b, a8P_____88 88 88 88 88P' "8a ns we `8b `8b 8PP""""""" 88 88 88 88 d8 ns we '8a a8P Y8a a8P "8b, ,aa 88, "8a, ,a88 88b, ,a8" ns we "Y88888P" `"YbbdP' `"Ybbd8"' "Y888 `"YbbdP'Y8 88`YbbdP"' 88 88 eot cat <<"eot" POUDIERIE SERVER eot cat <<"eot" Author: Brent Dacus eot } ####################################################################### # Variables # ####################################################################### cur_hostname="$(hostname)" serverip="$(ifconfig | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk 'NR==1{ print $2}')" serverip6="$(ifconfig | grep -E 'inet6.[0-9]' | grep -v '127.0.0.1' | awk 'NR==1{ print $2}')" servername="$(hostname -s)" os=$(uname) vn=$(freebsd-version -u | tr -s '0-9.' | cut -d \. -f1) pvn=$(freebsd-version -u | tr -s '0-9.' | cut -d - -f3) prvn=$(freebsd-version -u | tr -s '0-9.' | cut -d - -f1) servername="$(hostname -s)" svrdomainname="$(hostname -d)" rootemail="tech@delainhosting.com" cpu_cores=1 cpu_cores=$(/sbin/sysctl hw.ncpu | cut -d\ -f2) logfile=/root/install.log vmsetupbuild="/root/vmsetupbuild" vm="/usr/local/sbin/virtualmin" pkgargs="-y" rcconf=/etc/rc.conf ldrconf=/boot/loader.conf ####################################################################### # User Variables # ####################################################################### random_pass=$(pwgen -nys 10 1) ####################################################################### # Main Util Functions # ####################################################################### mkdir -p ~/dasetupbuild/ 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 644 "${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" pkg install ${pkgargs} wget curl nano bash beadm pwgen >/dev/null printf "Add an admin user? Enter username [bdacus01]:" read -r admuser admuser=${admuser:-bdacus01} if ! grep -E "^$admuser\b" /etc/passwd >/dev/null; then printf "User found: %s\n" "$admuser" else echo "$random_pass" | pw user add "$admuser" -m -s /bin/tcsh -G wheel -h 0 printf "Created admin user %s with %s.\n" "$admuser" "$random_pass" echo "$random_pass" >/home/"${admuser}"/pass.txt fi printf "User Creation Done.\n" if ! grep -q "#User Config" /home/"$admuser"/.cshrc; then printf 'C shell profile not set up. adding...\n' sed -i -e 's/.*EDITOR.*/setenv EDITOR nano/g' /home/"$admuser"/.cshrc cat <<"eol" >>/home/"$admuser"/.cshrc #User Config alias rm rm -i alias cp cp -i alias mv mv -i alias df df -achT alias lh 'history |grep ' alias la ls -abFG alias lc ls -bCG alias ll ls -abhlG alias lr ls -bRG alias lh='history |grep ' alias search='find / -name ' alias doserver 'curl -o vm_setup_bsd.sh -L https://files.delaintech.com/vm_setup_bsd.sh && bash vm_setup_bsd.sh' eol printf "Print Profile File for %s.\n" "$admuser" cat /home/"$admuser"/.cshrc printf "Done." else printf "C Profile already setup for %s.\n" "$admuser" fi if ! grep -q "EDITOR=nano" /home/"$admuser"/.profile; then printf 'Shell profile not set up. adding Editor...\n' printf "EDITOR=nano\nexport EDITOR\n" | tee -a /home/"$admuser"/.profile else printf 'Editor already added to .profile.\n' fi if ! grep -q doserver /root/.cshrc; then printf 'C shell profile not set up for root. adding...\n' sed -i -e 's/.*EDITOR.*/setenv EDITOR nano/g' /root/.cshrc cat <<"eol" >>/root/.cshrc alias rm rm -i alias cp cp -i alias mv mv -i alias df df -achT alias lh 'history |grep ' alias la ls -abFG alias lc ls -bCG alias ll ls -abhlG alias lr ls -bRG alias lh='history |grep ' alias search='find / -name ' alias doserver 'curl -o vm_setup_bsd.sh -L https://files.delaintech.com/vm_setup_bsd.sh && bash vm_setup_bsd.sh' eol printf "Print C Profile for root.\n" cat /root/.cshrc printf "Done.\n" else printf "C Profile already setup for root. See Below.\n" cat /root/.cshrc fi if ! grep -q "EDITOR=nano" /root/.profile; then printf 'Shell profile not set up. adding Editor...\n' printf "EDITOR=nano\nexport EDITOR\n" | tee -a /root/.profile else printf 'Editor already added to .profile.\n' fi printf "Set shell as sh for Root. See Below.\n" pw user mod root -s /bin/csh linebreak pw user show root } ####################################################################### # Set Timezone # ####################################################################### settimezone() { printf "What TimeZone are you in? [America/Chicago]: " read -r tmzone tmzone=${tmzone:-America/Chicago} if grep -E "^$tmzone" /var/db/zoneinfo >/dev/null; then printf "%s found\n" "$tmzone" else tzsetup "$tmzone" fi printf "We set timezone as: " cat /var/db/zoneinfo printf "Done.\n" } ####################################################################### # Add Hosts file # ####################################################################### creathostfile() { # does the Host already exist? if ! grep -q "${svrdomainname}" /etc/hosts; then printf 'Hostfile not found. adding...\n' cat <<"eol" >>/etc/hosts 209.126.81.64 apollo.delainhosting.com apollo 209.145.52.110 athena.delainhosting.com athena 144.91.108.77 thor.delainhosting.com thor 154.12.224.183 saturn.delainhosting.com saturn 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() { # does the Host alreadry exist? unset new_hostname printf "Please enter a Hostname to add: " read -r new_hostname if ! grep -q "$new_hostname" /etc/rc.conf >/dev/null; then printf 'Hostname not found. adding...\n' printf "Changing hostname %s from to %s...\n" "$cur_hostname" "$new_hostname" sysrc hostname="$new_hostname" servername="${new_hostname}" | cut -d "." -f1 echo "${servername}" echo "${serverip} ${new_hostname} ${servername}" >>/etc/hosts echo "${serverip6} ${new_hostname} ${servername}" >>/etc/hosts printf "Print Host File.\n" cat /etc/hosts printf "Done.\n" else printf "Hostname exsits.\nAll good.\n" fi } ####################################################################### # Add External Hosts # ####################################################################### creathostentry() { # 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}" >>/etc/hosts echo "${serverip6} ${add_hostname} ${servername}" >>/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 } ####################################################################### # Remove Hostnames # ####################################################################### removehosts() { printf "Here is the Host file.\n" cat /etc/hosts printf "What 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 "Done.\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 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' truncate -s "${swapsize}"G /swapfile chmod 0600 /swapfile swapon -aq printf "md99 none swap sw,file=/swapfile,late 0 0" | tee -a /etc/fstab swapon -aqL swapinfo -g printf "Done Swap should be active.\nIf not reboot.\n" else printf 'Swap file found.\nNo changes made.\n' fi } ####################################################################### # Update OS on Server # ####################################################################### serverupdate() { printf "Do we need to do a release update? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) printf "Release to move to? 13.0-RELEASE: " read -r bsdrelease freebsd-update upgrade -r "$bsdrelease" printf "Updating FreeBSD.\nHold Please.\n" freebsd-update install doreboot ;; [Nn]*) ;; esac printf "Post reboot run update install? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) printf "Updating FreeBSD.\nHold Please.\n" freebsd-update install pkg bootstrap -f ;; [Nn]*) ;; esac printf "FreeBSD Cleaning and Updating.\n" pkg autoremove ${pkgargs} >/dev/null pkg clean -a ${pkgargs} >/dev/null printf "Done.\n" printf "Updating FreeBSD.\nHold Please.\n" freebsd-update fetch install doreboot printf "Updating All Packages.\n" mkdir -p /usr/local/etc/pkg/repos cp /etc/pkg/FreeBSD.conf /usr/local/etc/pkg/repos/FreeBSD.conf sed -i -e 's/quarterly/latest/g' /usr/local/etc/pkg/repos/FreeBSD.conf pkg update -f && pkg upgrade ${pkgargs} >/dev/null printf "Done.\n" } ####################################################################### # 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 .*/LoginGraceTime 2m/g' /etc/ssh/sshd_config sed -i -e 's/.*MaxAuthTries .*/MaxAuthTries 3/g' /etc/ssh/sshd_config sed -i -e 's/.*MaxStartups .*/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 4/g' /etc/ssh/sshd_config sed -i -e 's/.*UseBlacklist no/UseBlacklist yes/g' /etc/ssh/sshd_config sed -i -e 's/.*AllowTcpForwarding .*/AllowTcpForwarding no/g' /etc/ssh/sshd_config sed -i -e 's/.*Compression .*/Compression no/g' /etc/ssh/sshd_config sed -i -e 's/.*AllowAgentForwarding yes/AllowAgentForwarding no/g' /etc/ssh/sshd_config sed -i -e 's/.*X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config # remove or disable services sysrc rpcbind_enable="NO" service rpcbind onestop service rpcbind onedisable service sshd restart ;; [Nn]*) ;; esac printf "Do we need to Secure TMP? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) if ! grep -q 'zfs_enable="YES"' /etc/rc.conf; then printf 'Filesystem UFS.\n' filesys="ufs" else printf 'Filesystem ZFS.\n' filesys="zfs" fi case $filesys in "zfs") if ! grep -q "tmpfs" /etc/fstab; then printf 'tmpfs file not found.\nCreating tmp file.\n' sysrc tmpfs_load="YES" umount -f zroot/tmp zfs set mountpoint=none zroot/tmp umount -f zroot/var/tmp zfs set mountpoint=none zroot/var/tmp rm -rf /tmp mkdir /tmp rm -rf /var/tmp mkdir /var/tmp mount -t tmpfs -o rw,nosuid,noexec,mode=01777 tmpfs /tmp mount -t tmpfs -o rw,nosuid,noexec,mode=01777 tmpfs /var/tmp echo "tmpfs /tmp tmpfs rw,nosuid,noexec,mode=01777 0 0" | tee -a /etc/fstab echo "tmpfs /var/tmp tmpfs rw,nosuid,noexec,mode=01777 0 0" | tee -a /etc/fstab zfs destroy zroot/tmp zfs destroy zroot/var/tmp printf "Done tmp and /var/tmp should be active and secure. ZFS filesystem removed.\nIf not reboot.\n" else printf 'tmp file found.\nNo changes made.\n' fi ;; "ufs") if ! grep -q "tmpfs" /etc/fstab; then printf 'tmpfs file not found.\nCreating tmp file.\n' sysrc tmpfs_load="YES" umount -f /tmp umount -f /var/tmp rm -rf /tmp mkdir /tmp rm -rf /var/tmp mkdir /var/tmp mount -t tmpfs -o rw,nosuid,noexec,mode=01777 tmpfs /tmp mount -t tmpfs -o rw,nosuid,noexec,mode=01777 tmpfs /var/tmp echo "tmpfs /tmp tmpfs rw,nosuid,noexec,mode=01777 0 0" | tee -a /etc/fstab echo "tmpfs /var/tmp tmpfs rw,nosuid,noexec,mode=01777 0 0" | tee -a /etc/fstab printf "Done tmp and /var.tmp should be active and secure. UFS filesystem removed.\nIf not reboot.\n" else printf 'tmp file found.\nNo changes made.\n' fi ;; *) printf 'Not sure of filesystem.\nNo changes made.\n' ;; esac ;; [Nn]*) ;; esac } ####################################################################### # Install Firewall # ####################################################################### installfirewall() { pkg install ${pkgargs} pftop spamd touch /usr/local/etc/whitelist_ips echo "99.34.232.208" >/usr/local/etc/whitelist_ips echo "127.0.0.1" >>/usr/local/etc/whitelist_ips echo "$serverip" >>/usr/local/etc/whitelist_ips touch /usr/local/etc/blocked_ips printf "Securing the server, please wait...\n" wget -rnH --cut-dirs=2 http://files.delaintech.com/bsd/pf/pf.conf -P /etc/ >>${logfile} wget -rnH --cut-dirs=2 http://files.delaintech.com/bsd/pf/pfloadtable.sh -P /usr/local/bin/ >>${logfile} chmod 755 /usr/local/bin/pfloadtable.sh wget -rnH --cut-dirs=2 http://files.delaintech.com/bsd/pf/pfloadabipdb.sh -P /usr/local/bin/ >>${logfile} chmod 755 /usr/local/bin/pfloadabipdb.sh wget -rnH --cut-dirs=2 http://files.delaintech.com/bsd/pf/pfloadcountry.sh -P /usr/local/bin/ >>${logfile} chmod 755 /usr/local/bin/pfloadcountry.sh cronline0="#pf jobs" ( crontab -l 2>/dev/null echo "$cronline0" ) | sort - | uniq - | crontab - cronline1="@reboot /usr/local/bin/pfloadtable.sh" cronline2="@reboot /usr/local/bin/pfloadabipdb.sh" cronline3="@reboot /usr/local/bin/pfloadcountry.sh" cronline4="0 0 * * * /sbin/pfctl -t bruteforce -T expire 432000" cronline5="0 1 * * * /usr/local/bin/pfloadabipdb.sh" cronline6="0 1 * * * /usr/local/bin/pfloadcountry.sh" crontab -l | sed -e '/^#pf jobs/a\ '"$cronline1" | sort - | uniq - | crontab - crontab -l | sed -e '/^#pf jobs/a\ '"$cronline2" | sort - | uniq - | crontab - crontab -l | sed -e '/^#pf jobs/a\ '"$cronline3" | sort - | uniq - | crontab - crontab -l | sed -e '/^#pf jobs/a\ '"$cronline4" | sort - | uniq - | crontab - crontab -l | sed -e '/^#pf jobs/a\ '"$cronline5" | sort - | uniq - | crontab - crontab -l | sed -e '/^#pf jobs/a\ '"$cronline6" | sort - | uniq - | crontab - service cron restart wget -rnH --cut-dirs=2 http://files.delaintech.com/bsd/pf/blacklistd.conf -P /etc/ >>${logfile} ###Spamd setup sh /usr/local/sbin/add-spamd-to-etc-service grep -q "## For Spamd" /etc/rc.conf.local if [ $? -ne 0 ]; then cat <<"eol" >>/etc/rc.conf.local ## For Spamd spamd_flags="-4 -G20:4:864 -h notyourserver.org -l127.0.0.1 -n \"Not your mail Server.\" -S10 -s1 -v -w1" spamd_black=NO spamlogd_flags="-I -i lo0" eol else printf 'RC local setup already. No changes made.\n' fi if ! grep -q "all:" /usr/local/etc/spamd/spamd.conf; then touch /usr/local/etc/spamd/spamd.conf cat <<"eol" >/usr/local/etc/spamd/spamd.conf all:\ :: eol else printf 'Spamd.conf setup already. No changes made.\n' fi cp /etc/fstab /etc/fstab.bak.obsp # if not then create it if ! grep -q "fdescfs" /etc/fstab; then printf 'fdescfs file not found. Creating fdescfs file.\n' echo "fdescfs /dev/fd fdescfs rw 0 0" | tee -a /etc/fstab printf "Done fdescfs should be active. If not reboot.\n" else printf 'fdescfs file found. No changes made.\n' fi if ! grep -q "## For Spamd" /etc/syslog.conf; then touch /var/log/spamd cat <<"eol" >>/etc/syslogd.conf ## For Spamd !spamd daemon.err;daemon.warn;daemon.info /var/log/spamd eol service syslogd restart else printf 'Syslogd setup alreadry. No changes made.\n' fi sysrc firewall_enable="NO" sysrc blacklistd_enable="YES" sysrc obspamd_enable="YES" sysrc obspamlogd_enable="YES" sysrc pf_enable="YES" sysrc pf_rules="/etc/pf.conf" sysrc pflog_enable="YES" sysrc pflog_logfile="/var/log/pflog" sysrc sendmail_enable="NO" sysrc sendmail_submit_enable="NO" sysrc sendmail_outbound_enable="NO" sysrc sendmail_msp_queue_enable="NO" pfctl -nf /etc/pf.conf kldload -n pf kldstat -h service obspamd enable service obspamd start service ipfw onestop doreboot } installpreq() { pkg install ${pkgargs} apache24 php74 pigz pbzip2 rsync zip unzip webmin wget sudo openssl screen nano curl >/dev/null printf 'Setting up DOAS file.\n' grep -q "#DH doas file setup" /usr/local/etc/doas.conf if [ $? -ne 0 ]; then cp /usr/local/etc/doas.conf.sample /usr/local/etc/doas.conf cat >/usr/local/etc/doas.conf <>${ldrconf} printf '%s\n' "$ldrval" >>${ldrconf} fi done printf 'Setting up Boot Environments.\n' if beadm list | grep -q factory"$prvn"; then printf 'Factory BE Exists. Skipping.\n' else printf 'Factory BE Does not exist\n' beadm create factory"$prvn" printf 'Added. factory%s.\n' "$prvn" fi if beadm list | grep -q "powerdns"$prvn" NR"; then printf 'PowerDNS BE is already Active.\n Skipping.\n' else printf 'Activating BE.\n' beadm activate powerdns"$prvn" printf 'Added. PowerDNS%s.\nYou might need to reboot.\n' "$prvn" doreboot fi } 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 #------------------------------------------------------------------------------# # Pull in your conf.maldet here. Change the links. #------------------------------------------------------------------------------# wget https://files.delaintech.com/conf.maldet -O conf.maldet \cp -f conf.maldet /usr/local/maldetect/ maldet -u } installwebmin() { echo "Installing Webmin." if [ -f /var/webmin ]; then echo "Webmin is installed Skipping." else pkg install ${pkgargs} webmin p5-DBD-mysql /usr/local/lib/webmin/setup.sh service webmin enable service webmin start fi } installmariadb() { echo "Installing Mysql 5.7 server." if [ -f /usr/local/etc/mysql/my.cnf ]; then echo "Mysql is installed Skipping." else pkg install ${pkgargs} mysql57-server service mysql-server enable service mysql-server start mysql_secure_installation cp /root/.mysql_secret /root/.mysql_secret.bkp echo "Done." fi echo "Downloading and importing PDNS Database schema..." wget https://files.delaintech.com/mysql_pdns.sql -O mysql_pdns.sql >>${ilog} mysql -u$db_root_user -p >${ilog} echo "Done." service mysql-server restart printf "Please create Admin user: " read -r admuser printf "Please give Admin User a password: " read -rs admpass echo "" mysql -u$db_root_user -p <>${ilog} pkg install ${pkgargs} powerdns service pdns enable service pdns start echo "Done." fi echo "Configuring PDNS." #no quotes in pdns.conf cp /usr/local/etc/pdns/pdns.conf /usr/local/etc/pdns/pdns.conf.bak grep -q "gmysql-dbname=pdns_db" /usr/local/etc/pdns/pdns.conf if [ $? -ne 0 ]; then echo 'PDNS config not found. Creating.' cat >/usr/local/etc/pdns/pdns.conf <>${ilog} } serverstatus() { echo "Checking Webmin." service webmin status echo "Checking MariaDB." service mysql-server status echo "Checking PowerDNS." service pdns status echo "done" } #-----------------------------------------------------------------------------# # Main PowerDNS Setup - Above here. # #-----------------------------------------------------------------------------# clear linebreak echo "" nssetupdeb_banner echo "" linebreak #Check that user is root. if [ "$(id -u)" = "0" ]; then printf "We are root. Continuing on....\n" else printf "This script must be run as root. Exiting.\n" exit 1 fi #What OS level are you on? printf "This installer is for FreeBSD 12+.\n" 2>&1 if [ "$os" = "FreeBSD" ] && [ "$vn" -gt 12 ]; then printf "System runs on %s version %s patch level %s. Great! Continuing on....\n" "$os" "$prvn" "$pvn" else printf "System runs on unsupported os. Exiting...\n" exit fi #Menus Starts here linebreak cat <&2 ;; esac done done if [ -d "$builddir" ]; then rm -rf $builddir fi mkdir $builddir if [ $run ]; then ${run} exit fi echo "Cleaning up build files, please wait..." cd ~ rm -rf $builddir echo "Good work see you later."