Make auto-update git aware (#133)
* Make auto-update git aware Fixes #106 * Some slight tweaking and bug-fixing
This commit is contained in:
parent
80c0580707
commit
c35208061c
14
global.sh
14
global.sh
@ -24,22 +24,30 @@ parse_yaml() {
|
||||
|
||||
# automatic update function
|
||||
gitupdate() {
|
||||
git remote add upstream https://github.com/jailmanager/jailman.git > /dev/null 2>&1
|
||||
if [ "$(git config --get remote.origin.url)" = "https://github.com/Ornias1993/jailman" ]
|
||||
then
|
||||
echo "The repository has been moved, please reinstall using the new repository: jailmanager/jailman"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$1" = "" ] || [ "$1" = "HEAD" ];
|
||||
then
|
||||
echo "Detatched or invalid GIT HEAD detected, please reinstall"
|
||||
else
|
||||
echo "checking for updates using Branch: $1"
|
||||
git fetch upstream > /dev/null 2>&1
|
||||
git fetch > /dev/null 2>&1
|
||||
git update-index -q --refresh > /dev/null 2>&1
|
||||
CHANGED=$(git diff --name-only "$1")
|
||||
if [ -n "$CHANGED" ];
|
||||
then
|
||||
echo "script requires update"
|
||||
git reset --hard > /dev/null 2>&1
|
||||
git checkout "${1}" > /dev/null 2>&1
|
||||
git pull > /dev/null 2>&1
|
||||
echo "script updated, please restart the script manually"
|
||||
exit 1
|
||||
else
|
||||
echo "script up-to-date"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
jailcreate() {
|
||||
|
@ -20,8 +20,7 @@ if ! [ "$(id -u)" = 0 ]; then
|
||||
fi
|
||||
|
||||
# Auto Update
|
||||
BRANCH="upstream/minor-dev"
|
||||
gitupdate "${BRANCH}"
|
||||
gitupdate $(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)") || exit 1
|
||||
|
||||
# If no option is given, point to the help menu
|
||||
if [ $# -eq 0 ]
|
||||
|
Loading…
Reference in New Issue
Block a user