From 8bb3946105f0a76d5160159f7d17fbeec0a5af01 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Mon, 15 Aug 2022 13:48:12 +0200 Subject: [PATCH] Made major improvements --- sos-git.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/sos-git.sh b/sos-git.sh index 14cab39..2c68b6e 100755 --- a/sos-git.sh +++ b/sos-git.sh @@ -62,14 +62,14 @@ function getDefaultConfiguration() { # #SOSGIT_MKDIR=/bin/mkdir\n # #\n # ## mv\n - # ## DEFAULT: /bin/mv + # ## DEFAULT: /bin/mv\n # ## The mv command must be from GNU\n # ## coreutils, otherwise it may not\n # ## work correctly with sos-git.\n # #SOSGIT_MV=/bin/mv\n # #\n # ## chmod\n - # ## DEFAULT: /bin/chmod + # ## DEFAULT: /bin/chmod\n # ## The chmod command must be from\n # ## GNU coreutils, otherwise it may\n # ## not work correctly with sos-git.\n @@ -134,7 +134,7 @@ function getDefaultConfiguration() { # ## DEFAULT: false\n # ## Disables the root warning\n # #SOSGIT_NOROOTWARNING=false\n - export "SOSGIT_EXITSTRING=SOSGIT_CONFIGVERSION=6\n# sos-git configuration\n# this is the default configuration, you\n# may make changes in sos-git.conf.d\n# since they may get overriten in a future\n# update.\n\n# Commands\n## Shell\n## DEFAULT: /bin/sh\n## You may want to set this to /bin/bash\n#SOSGIT_SHELL=/bin/sh\n#\n## Shell arguments\n## DEFAULT:\n## Here you can define your custom shell\n## arguments, like another rcfile.\n#SOSGIT_SHELLARGS=\n#\n## Make\n## DEFAULT: /bin/make\n#SOSGIT_MAKE=/bin/make\n#\n## Editor\n## DEFAULT: /bin/nano\n## You may want to set this to /bin/vi\n## or /bin/vim or any other editor.\n#SOSGIT_EDITOR=/bin/nano\n#\n## cURL\n## DEFAULT: /bin/curl\n#SOSGIT_CURL=/bin/curl\n#\n## git\n## DEFAULT: /bin/git\n#SOSGIT_GIT=/bin/git\n#\n## ls\n## DEFAULT: /bin/ls\n## The ls command must be from GNU\n## coreutils, otherwise it may not\n## work correctly with sos-git.\n#SOSGIT_LS=/bin/ls\n#\n## rm\n## DEFAULT: /bin/rm\n## The rm command must be from GNU\n## coreutils, otherwise it may not\n## work correctly with sos-git.\n#SOSGIT_RM=/bin/rm\n#\n## mkdir\n## DEFAULT: /bin/mkdir\n## The mkdir command must be from\n## GNU coreutils, otherwise it may\n## not work correctly with sos-git.\n#SOSGIT_MKDIR=/bin/mkdir\n#\n## mv\n## DEFAULT: /bin/mv\n## The mv command must be from GNU\n## coreutils, otherwise it may not\n## work correctly with sos-git.\n#SOSGIT_MV=/bin/mv\n#\n## chmod\n## DEFAULT: /bin/chmod\n## The chmod command must be from\n## GNU coreutils, otherwise it may\n## not work correctly with sos-git.\n#SOSGIT_CHMOD=/bin/chmod\n\n# Title\n## Suppress\n## DEFAULT: false\n## This hides the branding at\n## startup completely.\n#SOSGIT_TITLE_SUPPRESS=false\n#\n## Text\n## DEFAULT: false\n## This prints the branding\n## at startup in normal text.\n#SOSGIT_TITLE_TEXT=false\n\n# Temp\n# DEFAULT: /dev/shm\n# The temporary directory.\n# NO TRAILING SLASH AT THE END!\n#SOSGIT_TMP=/dev/shm\n\n# Repository save directory\n# DEFAULT: \$HOME/.sostools/git/repos\n# The directory where your downloaded\n# repositories are stored.\n# NO TRAILING SLASH AT THE END!\n# NO ~, USE \$HOME INSTEAD!\n#SOSGIT_REPOS=\$HOME/.sostools/git/repos\n\n# Internet\n## Update URL\n## DEFAULT: https://staropensource.ddns.net\n## /git/staropensource/sostools\n## /raw/branch/develop/sos-git.sh\n## The update URL, from where sos-git gets\n## updates. The save location will be\n## determined from the command line arguments.\n#SOSGIT_UPDATEURL=https://staropensource.ddns.net/git/staropensource/sostools/raw/branch/develop/sos-git.sh\n#\n## Request string\n## DEFAULT: https://staropensource.ddns.net\n## /git/%s/%s\n## String is used for making requests and\n## downloading repositories. First %s is user,\n## second %s is the repository.\n## NO TRAILING SLASH AT THE END!\n#SOSGIT_REQUESTSTRING=https://staropensource.ddns.net/git/%s/%s\n#\n## Remote request string\n## DEFAULT: https://%s:%s@staropensource.ddns.net/%s/%s## String is used for remoteauth, that updates\n## the remote string in git. First %s is username,\n## second %s is password, third %s is user and\n## fourth %s is the repository.\n## NO TRAILING SLASH AT THE END!\n#SOSGIT_REQUESTSTRING_REMOTE=https://%s:%s@staropensource.ddns.net/%s/%s\n# No root warning\n## DEFAULT: false\n## Disables the root warning\n#SOSGIT_NOROOTWARNING=false\n" + export "SOSGIT_EXITSTRING=SOSGIT_CONFIGVERSION=6# sos-git configuration\n# this is the default configuration, you\n# may make changes in sos-git.conf.d\n# since they may get overriten in a future\n# update.\n\n# Commands\n## Shell\n## DEFAULT: /bin/sh\n## You may want to set this to /bin/bash\n#SOSGIT_SHELL=/bin/sh\n\n## Shell arguments\n## DEFAULT:\n## Here you can define your custom shell\n## arguments, like another rcfile.\n#SOSGIT_SHELLARGS=\n#\n## Make\n## DEFAULT: /bin/make\n#SOSGIT_MAKE=/bin/make\n#\n## Editor\n## DEFAULT: /bin/nano\n## You may want to set this to /bin/vi\n## or /bin/vim or any other editor.\n#SOSGIT_EDITOR=/bin/nano\n#\n## cURL\n## DEFAULT: /bin/curl\n#SOSGIT_CURL=/bin/curl\n#\n## git\n## DEFAULT: /bin/git\n#SOSGIT_GIT=/bin/git\n#\n## ls\n## DEFAULT: /bin/ls\n## The ls command must be from GNU\n## coreutils, otherwise it may not\n## work correctly with sos-git.\n#SOSGIT_LS=/bin/ls\n#\n## rm\n## DEFAULT: /bin/rm\n## The rm command must be from GNU\n## coreutils, otherwise it may not\n## work correctly with sos-git.\n#SOSGIT_RM=/bin/rm\n#\n## mkdir\n## DEFAULT: /bin/mkdir\n## The mkdir command must be from\n## GNU coreutils, otherwise it may\n## not work correctly with sos-git.\n#SOSGIT_MKDIR=/bin/mkdir\n#\n## mv\n## DEFAULT: /bin/mv\n## The mv command must be from GNU\n## coreutils, otherwise it may not\n## work correctly with sos-git.\n#SOSGIT_MV=/bin/mv\n#\n## chmod\n## DEFAULT: /bin/chmod\n## The chmod command must be from\n## GNU coreutils, otherwise it may\n## not work correctly with sos-git.\n#SOSGIT_CHMOD=/bin/chmod\n\n# Title\n## Suppress\n## DEFAULT: false\n## This hides the branding at\n## startup completely.\n#SOSGIT_TITLE_SUPPRESS=false\n#\n## Text\n## DEFAULT: false\n## This prints the branding\n## at startup in normal text.\n#SOSGIT_TITLE_TEXT=false\n\n# Temp\n# DEFAULT: /dev/shm\n# The temporary directory.\n# NO TRAILING SLASH AT THE END!\n#SOSGIT_TMP=/dev/shm\n\n# Repository save directory\n# DEFAULT: \$HOME/.sostools/git/repos\n# The directory where your downloaded\n# repositories are stored.\n# NO TRAILING SLASH AT THE END!\n# NO ~, USE \$HOME INSTEAD!\n#SOSGIT_REPOS=\$HOME/.sostools/git/repos\n\n# Internet\n## Update URL\n## DEFAULT: https://staropensource.ddns.net\n## /git/staropensource/sostools\n## /raw/branch/develop/sos-git.sh## The update URL, from where sos-git gets\n## updates. The save location will be\n## determined from the command line arguments.\n#SOSGIT_UPDATEURL=https://staropensource.ddns.net/git/staropensource/sostools/raw/branch/develop/sos-git.sh\n#\n## Request string\n## DEFAULT: https://staropensource.ddns.net\n## /git/%s/%s\n## String is used for making requests and\n## downloading repositories. First %s is user,\n## second %s is the repository.## NO TRAILING SLASH AT THE END!\n#SOSGIT_REQUESTSTRING=https://staropensource.ddns.net/git/%s/%s\n#\n## Remote request string\n## DEFAULT: https://%s:%s@staropensource.ddns.net/%s/%s## String is used for remoteauth, that updates\n## the remote string in git. First %s is username,\n## second %s is password, third %s is user and\n## fourth %s is the repository.\n## NO TRAILING SLASH AT THE END!\n#SOSGIT_REQUESTSTRING_REMOTE=https://%s:%s@staropensource.ddns.net/%s/%s\n\n# No root warning\n## DEFAULT: false\n## Disables the root warning\n#SOSGIT_NOROOTWARNING=false\n" return "0" } function loadDefaultConfiguration() { @@ -187,8 +187,10 @@ function loadSystemConfiguration() { fi fi else - getDefaultConfiguration - echo -e "$SOSGIT_EXITSTRING" &> /etc/sostools/git/sos-git.conf + if [ "$(whoami)" == "root" ]; then + getDefaultConfiguration + echo -e "$SOSGIT_EXITSTRING" &> /etc/sostools/git/sos-git.conf + fi fi if [ -d "/etc/sostools/git/sos-git.conf.d/" ]; then for file in $($SOSGIT_LS --color=never -w 1 "/etc/sostools/git/sos-git.conf.d/");do @@ -292,14 +294,16 @@ function checkFastSettings() { fi } function chmodConfiguration() { - chmod +x "$HOME/.sostools/git/sos-git.conf" &> /dev/null + $SOSGIT_CHMOD +x "$HOME/.sostools/git/sos-git.conf" &> /dev/null for file in $($SOSGIT_LS --color=never -w 1 "$HOME/.sostools/git/sos-git.conf.d"); do - chmod +x "$HOME/.sostools/git/sos-git.conf.d/$file" &> /dev/null - done - chmod +x "/etc/sostools/git/sos-git.conf" &> /dev/null - for file in $($SOSGIT_LS --color=never -w 1 "/etc/sostools/git/sos-git.conf.d"); do - chmod +x "/etc/sostools/git/sos-git.conf.d/$file" &> /dev/null + $SOSGIT_CHMOD +x "$HOME/.sostools/git/sos-git.conf.d/$file" &> /dev/null done + if [ -d "/etc/sostools/git/" ] && [ "$(whoami)" == "root" ]; then + $SOSGIT_CHMOD +x "/etc/sostools/git/sos-git.conf" &> /dev/null + for file in $($SOSGIT_LS --color=never -w 1 "/etc/sostools/git/sos-git.conf.d"); do + $SOSGIT_CHMOD +x "/etc/sostools/git/sos-git.conf.d/$file" &> /dev/null + done + fi } loadDefaultConfiguration checkFastSettings @@ -409,7 +413,7 @@ if [ ! "$SOSGIT_TITLE_SUPPRESS" == "true" ]; then echo " |___/" echo "" else - echo "sos-git" + echo -e "sos-git\n" fi fi checkRootUser