Made code & QoL optimizations
This commit is contained in:
parent
49a20881b5
commit
f986307683
1 changed files with 16 additions and 14 deletions
30
sos-git.sh
30
sos-git.sh
|
@ -161,8 +161,6 @@ function loadDefaultConfiguration() {
|
||||||
}
|
}
|
||||||
function loadSystemConfigurationMigrationError() {
|
function loadSystemConfigurationMigrationError() {
|
||||||
echo "Your system configuration file is too old, but can't be reset."
|
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 ""
|
||||||
echo "If you want to ignore loading the system configuration,"
|
echo "If you want to ignore loading the system configuration,"
|
||||||
echo "create a empty file at $HOME/.sostools/git/nosysconf"
|
echo "create a empty file at $HOME/.sostools/git/nosysconf"
|
||||||
|
@ -177,16 +175,12 @@ function loadSystemConfiguration() {
|
||||||
source "/etc/sostools/git/sos-git.conf"
|
source "/etc/sostools/git/sos-git.conf"
|
||||||
if [ ! "$SOSGIT_CONFIGVERSION" == "$SOSGIT_EXITSTRING" ]; then
|
if [ ! "$SOSGIT_CONFIGVERSION" == "$SOSGIT_EXITSTRING" ]; then
|
||||||
if [ "$(whoami)" == "root" ]; 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
|
$SOSGIT_RM -rf "/etc/sostools/git/sos-git.conf" &> /dev/null
|
||||||
if [ ! "$?" == "0" ]; then loadSystemConfigurationMigrationError; fi
|
if [ ! "$?" == "0" ]; then loadSystemConfigurationMigrationError; fi
|
||||||
if [ -f "/etc/sostools/git/sos-git.conf" ] || [ -d "/etc/sostools/git/sos-git.conf" ]; then loadSystemConfigurationMigrationError; fi
|
if [ -f "/etc/sostools/git/sos-git.conf" ] || [ -d "/etc/sostools/git/sos-git.conf" ]; then loadSystemConfigurationMigrationError; fi
|
||||||
getDefaultConfiguration
|
getDefaultConfiguration
|
||||||
echo -e "$SOSGIT_EXITSTRING" &> /etc/sostools/git/sos-git.conf
|
echo -e "$SOSGIT_EXITSTRING" &> /etc/sostools/git/sos-git.conf
|
||||||
echo "Your system configuration file is too old and has been reset."
|
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"
|
exit "250"
|
||||||
else
|
else
|
||||||
loadSystemConfigurationMigrationError
|
loadSystemConfigurationMigrationError
|
||||||
|
@ -209,14 +203,9 @@ function loadUserConfiguration() {
|
||||||
source "$HOME/.sostools/git/sos-git.conf"
|
source "$HOME/.sostools/git/sos-git.conf"
|
||||||
if [ ! "$SOSGIT_CONFIGVERSION" == "$SOSGIT_EXITSTRING" ]; then
|
if [ ! "$SOSGIT_CONFIGVERSION" == "$SOSGIT_EXITSTRING" ]; then
|
||||||
$SOSGIT_RM "$HOME/.sostools/git/sos-git.conf" &> /dev/null
|
$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
|
getDefaultConfiguration
|
||||||
#$SOSGIT_MV "$HOME/.sostools/git/sos-git.conf" "$HOME/.sostools/git/sos-git.conf.bak" &> /dev/null
|
echo "$SOSSSH_EXITSTRING" &> "$HOME/.sostools/git/sos-git.conf"
|
||||||
#$SOSGIT_MV "$HOME/.sostools/git/sos-git.conf.d" "$HOME/.sostools/git/sos-git.conf.d.bak" &> /dev/null
|
|
||||||
doUserSetup "force+noinfo"
|
|
||||||
echo "Your user configuration file is too old and has been reset."
|
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"
|
exit "251"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -279,6 +268,18 @@ function doRepositorySetup() {
|
||||||
$SOSGIT_MKDIR -p "$SOSGIT_REPOS"
|
$SOSGIT_MKDIR -p "$SOSGIT_REPOS"
|
||||||
fi
|
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
|
loadDefaultConfiguration
|
||||||
loadSystemConfiguration
|
loadSystemConfiguration
|
||||||
loadUserConfiguration
|
loadUserConfiguration
|
||||||
|
@ -387,6 +388,7 @@ if [ ! "$SOSGIT_TITLE_SUPPRESS" == "true" ]; then
|
||||||
echo "sos-git"
|
echo "sos-git"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
checkRootUser
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
echo "Use \"sos-git help\" for all commands."
|
echo "Use \"sos-git help\" for all commands."
|
||||||
echo "If you want more information, use \"sos-git helpextend\"."
|
echo "If you want more information, use \"sos-git helpextend\"."
|
||||||
|
@ -414,7 +416,7 @@ elif [ "$1" == "help" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$1" == "helpextend" ]; then
|
elif [ "$1" == "helpextend" ]; then
|
||||||
echo "<required> [optional]"
|
echo "<required> [optional]"
|
||||||
echo "command | args | description"
|
echo "command | args | description"
|
||||||
echo "branch | <repository> | list all branches"
|
echo "branch | <repository> | list all branches"
|
||||||
echo "build | <repository> | build repository"
|
echo "build | <repository> | build repository"
|
||||||
echo "shell | <repository> | spawn shell in repository"
|
echo "shell | <repository> | spawn shell in repository"
|
||||||
|
|
Reference in a new issue