mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-19 21:03:19 -07:00
Added auto-update option
This commit is contained in:
parent
0e7f98756f
commit
5c31c355ef
1 changed files with 34 additions and 2 deletions
|
@ -48,6 +48,7 @@ FORCE=no
|
||||||
PUBLIC=no
|
PUBLIC=no
|
||||||
AUTOINSTALL=no
|
AUTOINSTALL=no
|
||||||
AUTODELETE=no
|
AUTODELETE=no
|
||||||
|
AUTOUPDATE=no
|
||||||
|
|
||||||
# Sanity, make sure wget is in our path...
|
# Sanity, make sure wget is in our path...
|
||||||
wget >/dev/null 2>/dev/null
|
wget >/dev/null 2>/dev/null
|
||||||
|
@ -67,17 +68,20 @@ URL_DOWNLOAD=https://plex.tv/downloads?channel=plexpass
|
||||||
URL_DOWNLOAD_PUBLIC=https://plex.tv/downloads
|
URL_DOWNLOAD_PUBLIC=https://plex.tv/downloads
|
||||||
|
|
||||||
# Parse commandline
|
# Parse commandline
|
||||||
set -- $(getopt fhko: -- "$@")
|
ALLARGS="$@"
|
||||||
|
set -- $(getopt aufhko: -- "$@")
|
||||||
while true;
|
while true;
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(-h) echo -e "Usage: $(basename $0) [-afhkop]\n\na = Auto install if download was successful (requires root)\nd = Auto delete after auto install\nf = Force download even if it's the same version or file already exists (WILL NOT OVERWRITE)\nh = This help\nk = Reuse last authentication\no = 32-bit version (default 64 bit)\np = Public Plex Media Server version"; exit 0;;
|
(-h) echo -e "Usage: $(basename $0) [-afhkop]\n\na = Auto install if download was successful (requires root)\nd = Auto delete after auto install\nf = Force download even if it's the same version or file already exists (WILL NOT OVERWRITE)\nh = This help\nk = Reuse last authentication\no = 32-bit version (default 64 bit)\np = Public Plex Media Server version\nu = Auto update plexupdate.sh before running it (experimental)\n"; exit 0;;
|
||||||
(-a) AUTOINSTALL=yes;;
|
(-a) AUTOINSTALL=yes;;
|
||||||
(-d) AUTODELETE=yes;;
|
(-d) AUTODELETE=yes;;
|
||||||
(-f) FORCE=yes;;
|
(-f) FORCE=yes;;
|
||||||
(-k) KEEP=yes;;
|
(-k) KEEP=yes;;
|
||||||
(-o) RELEASE="32-bit";;
|
(-o) RELEASE="32-bit";;
|
||||||
(-p) PUBLIC=yes;;
|
(-p) PUBLIC=yes;;
|
||||||
|
(-u) AUTOUPDATE=yes;;
|
||||||
|
(-U) AUTOUPDATE=no;;
|
||||||
(--) ;;
|
(--) ;;
|
||||||
(-*) echo "Error: unrecognized option $1" 1>&2; exit 1;;
|
(-*) echo "Error: unrecognized option $1" 1>&2; exit 1;;
|
||||||
(*) break;;
|
(*) break;;
|
||||||
|
@ -85,6 +89,34 @@ do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "${AUTOUPDATE}" == "yes" ]; then
|
||||||
|
git >/dev/null 2>/dev/null
|
||||||
|
if [ $? -eq 127 ]; then
|
||||||
|
echo "Error: You need to have git installed for this to work"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
pushd "$(dirname "$0")" >/dev/null
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
echo "Error: This is not a git repository, auto update only works if you've done a git clone"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git status | grep "nothing to commit" >/dev/null 2>/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: You have made changes to the script, cannot auto update"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -n "Auto updating..."
|
||||||
|
git pull >/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo 'Error: Unable to update git, try running "git pull" manually to see what is wrong'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "OK"
|
||||||
|
popd >/dev/null
|
||||||
|
$0 ${ALLARGS} -U
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
# Sanity check
|
# Sanity check
|
||||||
if [ "${EMAIL}" == "" -o "${PASS}" == "" ] && [ "${PUBLIC}" == "no" ]; then
|
if [ "${EMAIL}" == "" -o "${PASS}" == "" ] && [ "${PUBLIC}" == "no" ]; then
|
||||||
echo "Error: Need username & password to download PlexPass version. Otherwise run with -p to download public version."
|
echo "Error: Need username & password to download PlexPass version. Otherwise run with -p to download public version."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue