#!/usr/bin/bash ####################################################################### #Script Name: dsktp_setup_deb.sh #Version: 1.6 #Description: Wrapper for installing DA server #Last Modify Date: 03102021 #Author:Brent Dacus #Email:brent[at]thedacus[dot]net ####################################################################### # Banner # ####################################################################### export COLUMNS=100 debsetup_banner() { cat <<"eot" ad88888ba es d8" "8b ds // DdadPPYba, Y8, 88 // HH 8b ,adPPYba, `Y8aaaaa, 88\\' 88 88 8b,dPPYba, a8 44 a8P_____88 `"""""8b, 88 \\ 88 88 88P' "8a 8b 55 8PP""""""" `8b 88 kk 88 88 88 d8 D8 aa "8b, ,aa Y8a a8P 88 s\ "8a, ,a88 88b, ,a8" TTTYbbd8"' `"Ybbd8"' "Y88888P" Y8 e\ `"YbbdP'Y8 88`YbbdP"' 88 88 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.net cpu_cores="$(grep >(tee -a ${LOG_FILE}) 2>&1 ####################################################################### # User Variables # ####################################################################### rootemail="tech@thedacus.lan" bshrc=~/.bashrc bshrcpersn=~/.bashrc-personal limitsconf="/etc/security/limits.conf" sysctlconf="/etc/sysctl.conf" ####################################################################### # Main Util Functions # ####################################################################### mkdir -p ~/archsetupbuild/ 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 doas rm -f "${1}.bak" doas cp -f "${1}" "${1}.bak" doas chmod 600 "${1}.bak" fi doas wget --no-check-certificate -q -O "${1}" "${2}" doas chmod 755 "${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.' | doas tee -a "${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}" | doas tee -a "${2}" fi } doreboot() { printf "Need to reboot? (y/n)? " read -r yn yn=${yn:-n} case $yn in [Yy]*) doas reboot ;; [Nn]*) ;; esac } cycleswap() { printf "Cycling Swapfile.\n" swapoff -a sleep 10 swapon -a } ####################################################################### # Add Admin User # ####################################################################### addadminuser() { printf "Installing doas package.\n" printf "Please Wait.\n" sudo apt-get install doas printf 'Setting up DOAS file.\n' if ! grep -q "#BD doas file setup" /etc/doas.conf; then sudo tee /etc/doas.conf &>/dev/null </dev/null <&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