diff --git a/customscripts/debian-setup.sh b/customscripts/debian-setup.sh index 428d521..cd41749 100644 --- a/customscripts/debian-setup.sh +++ b/customscripts/debian-setup.sh @@ -23,7 +23,7 @@ groups_username=("tty" "dialout" "plugdev" "sudo" "www-data") home_username="/home/${new_username}" # services shit -services_to_enable=("ssh" "apache2" "xrdp" "avahi-daemon" "avahi-utils") +services_to_enable=("ssh" "apache2" "xrdp" "avahi-daemon") services_to_disable=("nginx") # save here to use in error_handle function @@ -106,7 +106,7 @@ reset_root() { echo "reset_root: START" echo "reset_root: change password" sudo passwd root - chkcode $? + checkcode $? echo "reset_root: FINISHED" } @@ -150,20 +150,25 @@ pyenv() { 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 + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> "$home_username/.bashrc" checkcode $? - echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> $home_username/.bashrc + echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> "$home_username/.bashrc" checkcode $? - echo 'eval "$(pyenv init - bash)"' >> $home_username/.bashrc + echo 'eval "$(pyenv init -)"' >> "$home_username/.bashrc" checkcode $? echo "pyenv: sourcing to $home_username/.bashrc" - source $home_username/.bashrc + source "$home_username/.bashrc" checkcode $? echo "pyenv: installing latest python3" - pyenv install 3:latest &> /dev/null + latest_python=$(pyenv install --list | grep -E '^[[:space:]]*3\.[0-9]+\.[0-9]+$' | tail -1 | tr -d '[:space:]') + if [ -z "$latest_python" ]; then + echo "pyenv: could not detect latest Python 3 version" + exit 1 + fi + pyenv install "$latest_python" &> /dev/null checkcode $? echo "pyenv: setting latest python3 as global" - pyenv global 3:latest &> /dev/null + pyenv global "$latest_python" &> /dev/null checkcode $? reload_shell echo "pyenv: FINISHED" @@ -203,15 +208,16 @@ wordists() { services() { echo "services: START" echo "services: disable" - for service in $services_to_disable; do + for service in "${services_to_disable[@]}"; do echo "services: disabling $service" - sudo systemctl disable $service - chkcode $? + sudo systemctl disable "$service" + checkcode $? echo "services: stopping $service" sudo systemctl stop "$service" - chkcode $? + checkcode $? + done echo "services: enable" - for service in $services_to_enable; do + for service in "${services_to_enable[@]}"; do echo "services: enabling $service" sudo systemctl enable "$service" &> /dev/null checkcode $? @@ -238,7 +244,7 @@ customscripts() { bash /usr/share/customscripts/configure_webhook.sh full checkcode $? echo "customscripts: updating user .bashrc" - echo 'export PATH="$PATH:/usr/share/customscripts' >> $home_username/.bashrc + echo 'export PATH="$PATH:/usr/share/customscripts"' >> "$home_username/.bashrc" checkcode $? reload_shell }