diff --git a/src/main b/src/main index 3352a78..85d01a1 100755 --- a/src/main +++ b/src/main @@ -3,7 +3,7 @@ ## FUNCTIONS ## --------- -function trap_error(){ +function trap_error { error_code=$1 error_line=$2 @@ -14,18 +14,16 @@ function trap_error(){ } - -function runVoid(){ +function runVoid { trap - ERR local COMMAND="$@" bash -c "${COMMAND}" >/dev/null 2>&1 - error=$? + runVoidError=$? trap 'trap_error $? $LINENO' ERR - return $error } -function askConfirmation (){ +function askConfirmation { case "$1" in y|Y|yes|YES ) QUESTION="(Y/n)?" @@ -48,7 +46,6 @@ function askConfirmation (){ ## --------- BASEDIR=/opt/debian-gnome -GIT_REPOSITORY_RAW="https://git.artcode.re/pvincent/debian-gnome/raw/master" ALLOWED_USERS=$(id -un) #CUSTOMIZE if needed! REQUIRED_PACKAGES=( \ vim git wget curl \ @@ -73,12 +70,11 @@ else echo "repositories recently updated!" fi - echo "# required packages" echo "===================" for package in ${REQUIRED_PACKAGES[@]}; do runVoid dpkg-query --status $package - if [ $? -ne 0 ] ; then + if [ $runVoidError -ne 0 ] ; then echo -n "installing package <$package> ... " ; sudo apt install -y $package echo "DONE" @@ -105,7 +101,7 @@ echo "## openssh-server" echo "=================" PGKNAME='openssh-server' runVoid dpkg-query --status $PGKNAME -if [ $? -ne 0 ] ; then +if [ $runVoidError -ne 0 ] ; then set -e sudo apt install -y $PGKNAME sudo /opt/debian-bash/tools/append_or_replace "^#\?PermitRootLogin.*$" "PermitRootLogin no" /etc/ssh/sshd_config @@ -190,7 +186,7 @@ fi echo "## gnome-extensions-cli" echo "=======================" runVoid command gnome-extensions-cli -if [[ $? -ne 0 ]]; then +if [[ $runVoidError -ne 0 ]]; then sudo pip3 install gnome-extensions-cli else echo "gnome-extensions-cli already installed!"