From 3fa4d68d6454b6521b5ff6ffaa53d964d1b8ba72 Mon Sep 17 00:00:00 2001 From: pvincent Date: Tue, 3 Aug 2021 19:55:37 +0400 Subject: [PATCH] runVoidError --- src/main | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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!"