Made code & QoL optimizations

This commit is contained in:
JeremyStarTM 2022-08-14 20:46:52 +02:00
parent 49a20881b5
commit f986307683

View file

@ -161,8 +161,6 @@ function loadDefaultConfiguration() {
}
function loadSystemConfigurationMigrationError() {
echo "Your system configuration file is too old, but can't be reset."
# echo "Please update all configuration files to the new version,"
# echo "if you still want to use them."
echo ""
echo "If you want to ignore loading the system configuration,"
echo "create a empty file at $HOME/.sostools/git/nosysconf"
@ -177,16 +175,12 @@ function loadSystemConfiguration() {
source "/etc/sostools/git/sos-git.conf"
if [ ! "$SOSGIT_CONFIGVERSION" == "$SOSGIT_EXITSTRING" ]; then
if [ "$(whoami)" == "root" ]; then
$SOSGIT_RM -rf "/etc/sostools/git/sos-git.conf.bak" "/etc/sostools/git/sos-git.conf.d.bak" &> /dev/null
$SOSGIT_RM -rf "/etc/sostools/git/sos-git.conf" &> /dev/null
if [ ! "$?" == "0" ]; then loadSystemConfigurationMigrationError; fi
if [ -f "/etc/sostools/git/sos-git.conf" ] || [ -d "/etc/sostools/git/sos-git.conf" ]; then loadSystemConfigurationMigrationError; fi
getDefaultConfiguration
echo -e "$SOSGIT_EXITSTRING" &> /etc/sostools/git/sos-git.conf
echo "Your system configuration file is too old and has been reset."
#echo "A backup is named \"sos-git.conf.bak\" and \"sos-git.conf.d.bak\"."
#echo "Please update all configuration files to the new version,"
#echo "if you still want to use them."
exit "250"
else
loadSystemConfigurationMigrationError
@ -209,14 +203,9 @@ function loadUserConfiguration() {
source "$HOME/.sostools/git/sos-git.conf"
if [ ! "$SOSGIT_CONFIGVERSION" == "$SOSGIT_EXITSTRING" ]; then
$SOSGIT_RM "$HOME/.sostools/git/sos-git.conf" &> /dev/null
#$SOSGIT_RM "$HOME/.sostools/git/sos-git.conf.bak" "$HOME/.sostools/git/sos-git.conf.d.bak" &> /dev/null
#$SOSGIT_MV "$HOME/.sostools/git/sos-git.conf" "$HOME/.sostools/git/sos-git.conf.bak" &> /dev/null
#$SOSGIT_MV "$HOME/.sostools/git/sos-git.conf.d" "$HOME/.sostools/git/sos-git.conf.d.bak" &> /dev/null
doUserSetup "force+noinfo"
getDefaultConfiguration
echo "$SOSSSH_EXITSTRING" &> "$HOME/.sostools/git/sos-git.conf"
echo "Your user configuration file is too old and has been reset."
#echo "A backup is named \"sos-git.conf.bak\" and \"sos-git.conf.d.bak\"."
#echo "Please update all configuration files to the new version,"
#echo "if you still want to use them."
exit "251"
fi
fi
@ -279,6 +268,18 @@ function doRepositorySetup() {
$SOSGIT_MKDIR -p "$SOSGIT_REPOS"
fi
}
function checkRootUser() {
if [ "$(whoami)" == "root" ] && [ ! "$SOSGIT_NOROOTWARNING" == "true" ]; then
echo "Warning! You are running sos-git as the root user."
echo " Please switch to a normal account, unless"
echo " the repository asks for these permissions."
echo ""
echo " To disable this warning, create a file at"
echo " \"$HOME/.sostools/git/sos-git.conf.d/norootwarning.conf\" or"
echo " \"/etc/sostools/git/sos-git.conf.d/norootwarning.conf\" with"
echo " the content \"SOSGIT_NOROOTWARNING=true\"."
fi
}
loadDefaultConfiguration
loadSystemConfiguration
loadUserConfiguration
@ -387,6 +388,7 @@ if [ ! "$SOSGIT_TITLE_SUPPRESS" == "true" ]; then
echo "sos-git"
fi
fi
checkRootUser
if [ "$1" == "" ]; then
echo "Use \"sos-git help\" for all commands."
echo "If you want more information, use \"sos-git helpextend\"."