mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-20 13:23:21 -07:00
Make auto-update not enter infinte update loops
This commit is contained in:
parent
7b32e0dcd3
commit
36559df390
1 changed files with 31 additions and 25 deletions
|
@ -120,9 +120,9 @@ usage() {
|
||||||
echo " -P Show progressbar when downloading big files"
|
echo " -P Show progressbar when downloading big files"
|
||||||
echo " -r Print download URL and exit"
|
echo " -r Print download URL and exit"
|
||||||
echo " -s Auto start (needed for some distros)"
|
echo " -s Auto start (needed for some distros)"
|
||||||
echo " -u Auto update plexupdate.sh before running it (experimental)"
|
echo " -u Auto update plexupdate.sh before running it (default with installer)"
|
||||||
echo " -U Do not autoupdate plexupdate.sh (experimental, default)"
|
echo " -U Do not autoupdate plexupdate.sh"
|
||||||
echo " -v Show additional debug information (cannot be saved or set via config)"
|
echo " -v Show additional debug information"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Long Argument Options:"
|
echo " Long Argument Options:"
|
||||||
echo " --config <path/to/config/file> Configuration file to use"
|
echo " --config <path/to/config/file> Configuration file to use"
|
||||||
|
@ -308,40 +308,47 @@ if [ ! -z "${RELEASE}" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${AUTOUPDATE}" = "yes" ]; then
|
if [ "${AUTOUPDATE}" = "yes" ]; then
|
||||||
|
GIT_UPDATED=no
|
||||||
|
|
||||||
if ! hash git 2>/dev/null; then
|
if ! hash git 2>/dev/null; then
|
||||||
error "You need to have git installed for this to work"
|
error "You need to have git installed for this to work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd "$(dirname "$0")" >/dev/null
|
pushd "$(dirname "$0")" >/dev/null
|
||||||
|
|
||||||
if [ ! -d .git ]; then
|
if [ ! -d .git ]; then
|
||||||
error "This is not a git repository, auto update only works if you've done a git clone"
|
error "This is not a git repository. Auto-update only works if you've done a git clone"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
git status | grep "git commit -a" >/dev/null 2>/dev/null
|
|
||||||
if [ $? -eq 0 ]; then
|
if git diff --quiet; then
|
||||||
error "You have made changes to the script, cannot auto update"
|
error "You have made changes to the plexupdate files, cannot auto update"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
info "Auto updating"
|
|
||||||
git pull >/dev/null
|
if git fetch --quiet && git diff --quiet FETCH_HEAD; then
|
||||||
if [ $? -ne 0 ]; then
|
info "Auto-updating..."
|
||||||
|
if ! git merge --quiet FETCH_HEAD; then
|
||||||
error 'Unable to update git, try running "git pull" manually to see what is wrong'
|
error 'Unable to update git, try running "git pull" manually to see what is wrong'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
else
|
||||||
info "Update complete"
|
info "Update complete"
|
||||||
|
GIT_UPDATED=yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
if ! type "$0" 2>/dev/null >/dev/null ; then
|
if [ ! -f "$0" ]; then
|
||||||
if [ -f "$0" ]; then
|
|
||||||
/bin/bash "$0" -U ${ALLARGS[@]}
|
|
||||||
else
|
|
||||||
error "Unable to relaunch, couldn't find $0"
|
error "Unable to relaunch, couldn't find $0"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
elif [ "${GIT_UPDATED}" = "yes" ]; then
|
||||||
else
|
[ -x "$0" ] || chmod 755 "$0"
|
||||||
"$0" -U ${ALLARGS[@]}
|
"$0" ${ALLARGS[@]}
|
||||||
fi
|
|
||||||
exit $?
|
exit $?
|
||||||
|
#else we now return you to your regularly scheduled programming
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sanity check
|
# Sanity check
|
||||||
|
@ -355,8 +362,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [ "${AUTOINSTALL}" = "yes" -o "${AUTOSTART}" = "yes" ]; then
|
if [ "${AUTOINSTALL}" = "yes" -o "${AUTOSTART}" = "yes" ]; then
|
||||||
id | grep -i 'uid=0(' 2>&1 >/dev/null
|
if [ ${EUID} -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
error "You need to be root to use AUTOINSTALL/AUTOSTART option."
|
error "You need to be root to use AUTOINSTALL/AUTOSTART option."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue