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
24
global.sh
24
global.sh
@ -24,21 +24,29 @@ parse_yaml() {
|
|||||||
|
|
||||||
# automatic update function
|
# automatic update function
|
||||||
gitupdate() {
|
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" ]
|
||||||
echo "checking for updates using Branch: $1"
|
|
||||||
git fetch upstream > /dev/null 2>&1
|
|
||||||
git update-index -q --refresh > /dev/null 2>&1
|
|
||||||
CHANGED=$(git diff --name-only "$1")
|
|
||||||
if [ -n "$CHANGED" ];
|
|
||||||
then
|
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 > /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"
|
echo "script requires update"
|
||||||
git reset --hard > /dev/null 2>&1
|
git reset --hard > /dev/null 2>&1
|
||||||
git checkout "${1}" > /dev/null 2>&1
|
|
||||||
git pull > /dev/null 2>&1
|
git pull > /dev/null 2>&1
|
||||||
echo "script updated, please restart the script manually"
|
echo "script updated, please restart the script manually"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "script up-to-date"
|
echo "script up-to-date"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,7 @@ if ! [ "$(id -u)" = 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Auto Update
|
# Auto Update
|
||||||
BRANCH="upstream/minor-dev"
|
gitupdate $(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)") || exit 1
|
||||||
gitupdate "${BRANCH}"
|
|
||||||
|
|
||||||
# If no option is given, point to the help menu
|
# If no option is given, point to the help menu
|
||||||
if [ $# -eq 0 ]
|
if [ $# -eq 0 ]
|
||||||
|
Loading…
Reference in New Issue
Block a user