From e3cb0f0676ff6765d040f2f69a2240c17a2f76c6 Mon Sep 17 00:00:00 2001 From: MrDoobPG <46342172+MrDoobPG@users.noreply.github.com> Date: Mon, 25 Nov 2019 22:07:53 +0100 Subject: [PATCH] token / plexpatrol --- menu/plexpatrol/plexpatrol.sh | 14 ++++++++++---- menu/plexpatrol/remove-plexpatrol.yml | 15 ++++++++++----- menu/plexpatrol/token.sh | 19 ++----------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/menu/plexpatrol/plexpatrol.sh b/menu/plexpatrol/plexpatrol.sh index b5adf3d2..931d9fb8 100644 --- a/menu/plexpatrol/plexpatrol.sh +++ b/menu/plexpatrol/plexpatrol.sh @@ -72,12 +72,14 @@ badinput() { question1 } +####################################################################################### +### Remove old folder and create first layout for token section0(){ sect0="/var/plexguide/plexpatrol/plex.token" if [[ ! -f $sect0 ]]; then - bash /opt/plexguide/menu/plexpatrol/token.sh - else question1 ; fi -} + bash /opt/plexguide/menu/plexpatrol/token.sh && oldvalue ; fi +} +######################################################################################### selection1() { tee <<-EOF @@ -240,7 +242,7 @@ EOF } # FIRST QUESTION question1() { - +deploycheck video=$(cat /var/plexguide/plexpatrol/video.transcodes) video4k=$(cat /var/plexguide/plexpatrol/video.transcodes4k) ips=$(cat /var/plexguide/plexpatrol/multiple.ips) @@ -254,6 +256,9 @@ question1() { 🚀 Plex - Patrol Interface || l3uddz/plex_patrol ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Plex Token [ $pstatus ] + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [1] Instantly Kick Video Transcodes? [ $video ] [2] Instantly Kick Video 4k Transcodes? [ $video4k ] @@ -304,3 +309,4 @@ variable /var/plexguide/plexpatrol/check.interval "NON-SET" variable /var/plexguide/plexpatrol/multiple.ips "NON-SET" variable /var/plexguide/plexpatrol/kick.minutes "NON-SET" deploycheck +question1 diff --git a/menu/plexpatrol/remove-plexpatrol.yml b/menu/plexpatrol/remove-plexpatrol.yml index e72d47a7..7e996d84 100644 --- a/menu/plexpatrol/remove-plexpatrol.yml +++ b/menu/plexpatrol/remove-plexpatrol.yml @@ -11,24 +11,29 @@ gather_facts: false tasks: # FACTS ###################################################################### - #when: not config.stat.exists - name: Check Service's Existance stat: path: '/etc/systemd/system/plexpatrol.service' register: pgp + ignore_errors: yes - name: Stop service service: name: plexpatrol state: stopped when: pgp.stat.exists + ignore_errors: yes - - name: Daemon-PTS-Patrol stop + - name: Daemon-Plex-Patrol stop systemd: state=stopped name=plexpatrol daemon_reload=yes enabled=no + ignore_errors: yes - - name: Remove Basic Directories + - name: Remove old and new Basic Directories file: 'path={{item}} state=absent mode=0775 owner=1000 group=1000' with_items: - - '/opt/appdata/plexpatrol/' + - '/opt/pgpatrol/' + - '/opt/appdata/pgpatrol/' + - '/var/plexguide/pgpatrol' + - '/var/plexguide/plexpatrol' - '/etc/systemd/system/plexpatrol.service' - - '/var/plexguide/plexpatrol' \ No newline at end of file + - '/etc/systemd/system/pgpatrol.service' \ No newline at end of file diff --git a/menu/plexpatrol/token.sh b/menu/plexpatrol/token.sh index defe428b..e89ba941 100644 --- a/menu/plexpatrol/token.sh +++ b/menu/plexpatrol/token.sh @@ -21,18 +21,6 @@ badinput2() { question2 } -tokenstatus() { - ptokendep=$(cat /var/plexguide/plexpatrol/plex.token) - if [ "$ptokendep" != "" ]; then - PGSELFTEST=$(curl -LI "http://localhost:32400/system?X-Plex-Token=$(cat /var/plexguide/plexpatrol/plex.token)" -o /dev/null -w '%{http_code}\n' -s) - if [[ $PGSELFTEST -ge 200 && $PGSELFTEST -le 299 ]]; then - pstatus="✅ DEPLOYED" - else - pstatus="❌ DEPLOYED BUT TOKEN FAILED" - fi - else pstatus="⚠️ NOT DEPLOYED"; fi -} - question1() { tee <<-EOF @@ -40,9 +28,7 @@ question1() { 🌎 PlexToken Generator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Token Status : [$pstatus] - -[ 1 ] - Generate new Token for Plex Patrol +Generate new Token for Plex Patrol ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ EOF @@ -130,7 +116,7 @@ if [ -z "$X_PLEX_TOKEN" ]; then fi echo $X_PLEX_TOKEN >/var/plexguide/plexpatrol/plex.token - token=$(cat /var/plexguide/plex.token) + token=$(cat /var/plexguide/plexpatrol/plex.token) if [ "$token" != "" ]; then tee <<-EOF @@ -155,5 +141,4 @@ EOF } # FUNCTIONS END ############################################################## -tokenstatus question1