From 89b919cc458145455234f595a0bd6c9f5a1acbbb Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Sat, 23 May 2026 00:23:16 -0600 Subject: [PATCH] 1779517396 --- customscripts/debian-setup.sh | 273 +++++++++++++++++++++++++++------- 1 file changed, 216 insertions(+), 57 deletions(-) diff --git a/customscripts/debian-setup.sh b/customscripts/debian-setup.sh index 7211e18..985ca6d 100644 --- a/customscripts/debian-setup.sh +++ b/customscripts/debian-setup.sh @@ -1,5 +1,74 @@ #!/bin/bash -set -euo pipefall +# todo: +## packages to add: cowsay iotop iptraf-ng gh btop htop screen byobu wget thefuck lynx zip unzip 7zip net-tools clamav php restic cifs-utils detox fdupes ffmpeg ffplay ripgrep avahi-daemon libnss-mdns xxd libimage-exiftool-perl ffuf +## enable start services: xrdp apache2 avahi-servicd scripot +## run customscripts +# set safety optinonz +set -o errexit # fail on error +set -o errtrace # run trace on error +set -o pipefail # fail on pipe fail +set -o nounset # fail on unset var + +# packages +new_packages=(gawk curl wget git gh build-essential scrypt openssl argon2 qbittorrent xfce4 gparted xrdp xz-utils 7zip zip unzip gzip apache2 php php-cli php-bz2 php-crypt-gpg php-curl php-db php-doc php-email-validator cowsay iotop iptraf-ng gh btop htop screen byobu wget thefuck lynx zip unzip 7zip net-tools clamav php restic cifs-utils detox fdupes ffmpeg ripgrep avahi-daemon libnss-mdns xxd libimage-exiftool-perl ffuf wireshark hashcat snap pipx) + +# user info +new_username="princesspi" +groups_username=("tty" "dialout" "plugdev" "sudo" "www-data") +home_username="/home/${new_username}" + +# services shit +services_to_enable=("apache2" "xrdp" "avahi-daemon" "avahi-utils") +services_to_disable=("nginx") + +# save here to use in error_handle function +num_of_args="$#" +all_args="$@" + + +# Define the cleanup function +error_handle() { + # CRITICAL: Capture the exit status code before ANY other command runs + local exit_code=$? + local script_path="$(realpath $0)" + local hr='====================================================' + echo + echo $hr + echo -e "🚨 \033[0;31m FATAL ERROR DETECTED \033[0m" + echo $hr + echo "-> Script : $0" + echo "-> Num Script Args : $num_of_args" + echo "-> Script Args : $all_args" + echo "-> Shell : $SHELL" + echo "-> Script Path : $script_path" + echo "-> Script (full) : $SHELL $script_path $all_args" + echo "-> User : $USER" + echo "-> Working Directory : $PWD" + echo "-> Failed Command : $BASH_COMMAND" + echo "-> Line Number : $LINENO" + echo "-> Exit Status : $exit_code" + echo "-> Seconds Elapsed : $SECONDS" + echo "-> Date Failed : $(date)" + # Generate a professional, clean stack traceback + echo "-> Stack Trace" + printf "\t" # to intent da stack trace + local frame=0 + # Loop backwards through the function execution stack array + while caller $frame; do + printf "\t" # to indenet da stack trace + frame=$((frame + 1)) + done + + # closing niceties + echo + echo $hr + echo + + # exit with last failcode + exit "$exit_code" +} + +trap error_handle ERR # to give pass/fail output from da commmands ## usage like checkcode $? @@ -14,64 +83,154 @@ checkcode () { if [ $retcode -ne 0 ]; then echo -e "\t\e[31mERROR!\033[0m Response Code: $retcode" else - echo -e "\t\e[1;32mOK!\e[0m" + printf '\e[1;32mOK!\e[0m' fi } -echo "apt: START" -echo "apt: updating" -sudo apt update &> /dev/null -checkcode $? -echo "apt: running dist-upgrade" -sudo apt dist-upgrade -y &> /dev/null -checkcode $? -echo "apt: install packages" -sudo apt install -y gawk curl wget git gh build-essential scrypt openssl argon2 qbittorrent xfce4 apache2 php php-cli php-bz2 php-crypt-gpg php-curl php-date php-db php-decimal php-doc php-email-validator php-enum php-facedetect &> /dev/null -checkcode $? -echo "apt: autoremoving" -sudo apt autoremove -y &> /dev/null -checkcode $? -echo "apt: FINISHED" +user() { + echo "user: START" + echo "user: create $new_username" + useradd "$new_username" + checkcode $? + echo "user: adding groups" + for group in "${groups_username[@]}"; do + echo "user: adding $new_username to group $group" + usermod -aG $group $new_username &> /dev/null + checkcode $? + done + checkcode $? + echo "user: FINISHED" +} -echo "pyenv: START" -echo "pyenv: installin" -curl -fsSL https://pyenv.run | bash &> /dev/null -checkcode $? -echo "pyenv: adding exports to ~/.bashrc" -echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc -checkcode $? -echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc -checkcode $? -echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc -checkcode $? -echo "pyenv: sourcing to ~/.bashrc" -source ~/.bashrc -checkcode $? -echo "pyenv: installing latest python3" -pyenv install 3:latest &> /dev/null -checkcode $? -echo "pyenv: setting latest python3 as global" -pyenv global 3:latest &> /dev/null -checkcode $? -echo "pyenv: FINISHED" +apt() { + echo "apt: START" + echo "apt: updating" + sudo apt update &> /dev/null + checkcode $? + echo "apt: running dist-upgrade" + sudo apt dist-upgrade -y &> /dev/null + checkcode $? + echo "apt: install packages" + sudo apt install -y "${new_packages[@]}" &> /dev/null + checkcode $? + sudo snap install urh + checkcode $? + echo "apt: autoremoving" + sudo apt autoremove -y &> /dev/null + checkcode $? + echo "apt: FINISHED" +} -echo "ble.sh: START" -echo "ble.sh: changing directory to /tmp" -cd /tmp -checkcode $? -echo "ble.sh: downloading" -git clone --recursive --depth 1 --shallow-submodules --single-branch -b master https://github.com/akinomyoga/ble.sh.git &> /dev/null -checkcode $? -echo "ble.sh: building and installing" -make -C ble.sh install PREFIX=~/.local &> /dev/null -checkcode $? -echo "ble.sh: setting up ~/.bashrc file" -echo '# ble.sh' >> ~/.bashrc -checkcode $? -echo 'source -- ~/.local/share/blesh/ble.sh' >> ~/.bashrc -checkcode $? -echo 'ble.sh: sourcing ~/.bashrc' -checkcode $? -source ~/.bashrc -checkcode $? -echo "ble.sh: FINISH" +pyenv() { + echo "pyenv: START" + echo "pyenv: installin" + curl -fsSL https://pyenv.run | bash &> /dev/null + checkcode $? + echo "pyenv: adding exports to $home_username/.bashrc" + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> $home_username/.bashrc + checkcode $? + echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> $home_username/.bashrc + checkcode $? + echo 'eval "$(pyenv init - bash)"' >> $home_username/.bashrc + checkcode $? + echo "pyenv: sourcing to $home_username/.bashrc" + source $home_username/.bashrc + checkcode $? + echo "pyenv: installing latest python3" + pyenv install 3:latest &> /dev/null + checkcode $? + echo "pyenv: setting latest python3 as global" + pyenv global 3:latest &> /dev/null + checkcode $? + echo "pyenv: FINISHED" +} + +blesh() { + echo "ble.sh: START" + echo "ble.sh: changing directory to /tmp" + cd /tmp + checkcode $? + echo "ble.sh: downloading" + git clone --recursive --depth 1 --shallow-submodules --single-branch -b master https://github.com/akinomyoga/ble.sh.git &> /dev/null + checkcode $? + echo "ble.sh: building and installing" + make -C ble.sh install PREFIX=$home_username/.local &> /dev/null + checkcode $? + echo "ble.sh: setting up $home_username/.bashrc file" + echo '# ble.sh' >> $home_username/.bashrc + checkcode $? + echo 'source -- $home_username/.local/share/blesh/ble.sh' >> $home_username/.bashrc + checkcode $? + echo 'ble.sh: sourcing $home_username/.bashrc' + checkcode $? + source $home_username/.bashrc + checkcode $? + echo "ble.sh: FINISHED" +} + +wordists() { + echo "Wordlists: START" + echo "wordlists: making $home_username/wordlists dir" + mkdir -p $home_username/wordlists &> /dev/null + checkcode $? + echo "wordlists: downloading seclists to $home_username/wordlists" + git clone --single-branch https://github.com/danielmiessler/SecLists.git $home_username/wordlists/SecLists &> /dev/null + # todo: finish +} + +services() { + echo "services: START" + echo "services: disable" + for service in $services_to_disable; do + echo "services: disabling $service" + sudo systemctl disable $service + chkcode $? + echo "services: stopping $service" + sudo systemctl stop "$service" + chkcode $? + echo "services: enable" + for service in $services_to_enable; do + echo "services: enabling $service" + sudo systemctl enable "$service" &> /dev/null + checkcode $? + echo "services: starting $service" + sudo systemctl start "$service" &> /dev/null + checkcode $? + done + echo "services: FINISHED" +} + +customscripts() { + echo "customscripts: START" + script="/tmp/install_script.sh" + echo "customscripts: downloading general-scripts-and-system-ssssssetup installer" + curl -s https://raw.githubusercontent.com/PrincessPi3/general-scripts-and-system-ssssssetup/refs/heads/main/customscripts/install_script.sh > "$script" + checkcode $? + echo "customscripts: making $script executable" + chmod +x "$script" + checkcode $? + echo "customscripts: running $script" + bash -c "$script full" + checkcode $? + echo "customscripts: running configure_webhook.sh full" + bash /usr/share/customscripts/configure_webhook.sh full + checkcode $? + echo "customscripts: updating user .bashrc" + echo 'export PATH="$PATH:/usr/share/customscripts' >> $home_username/.bashrc + checkcode $? + echo "customscripts: sourcing to $home_username/.bashrc" + source $home_username/.bashrc + checkcode $? + echo "customscripts: reloading shell" + exec $SHELL + checkcode $? +} + +# run in order +user +apt +pyenv +blesh +wordlists +services +customscripts \ No newline at end of file