From 7e6e79f55fbfb5e5d1dc3829ccce7e2c4d1b1ed5 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 21 Feb 2023 00:17:23 -0500
Subject: linhes-system: add plexmediascanner.sh

lh_system_backup_job: change plex paths
---
 linhes/linhes-system/PKGBUILD             | 12 +++++++-----
 linhes/linhes-system/lh_mtc.cron          |  2 +-
 linhes/linhes-system/lh_system_backup_job | 28 +++++++---------------------
 linhes/linhes-system/plexmediascanner.sh  |  6 ++++++
 4 files changed, 21 insertions(+), 27 deletions(-)
 create mode 100755 linhes/linhes-system/plexmediascanner.sh

diff --git a/linhes/linhes-system/PKGBUILD b/linhes/linhes-system/PKGBUILD
index eceb676..c114a40 100755
--- a/linhes/linhes-system/PKGBUILD
+++ b/linhes/linhes-system/PKGBUILD
@@ -1,11 +1,12 @@
 pkgname=linhes-system
 pkgver=9.0.0
-pkgrel=48
+pkgrel=49
 arch=('x86_64')
 #install=$pkgname.install
 pkgdesc="Everything that makes LinHES a system"
 license=('GPL2')
-depends=('cronie' 'dbus-python' 'dvb-firmware' 'expect' 'flatpak' 'firefox' 'glances' 'kdialog' 'libnotify'
+depends=('cronie' 'dbus-python' 'dvb-firmware' 'expect' 'flatpak' 'firefox' 'glances' 'inetutils' 
+         'kdialog' 'libnotify'
          'logrotate' 'linhes-templates' 'linhes-theme' 'mlocate' 'ncdu' 'python-dateutil' 'python-pytz'
          'python-tzlocal' 'openssh' 'pacman-contrib' 'rsyslog' 'ttf-overlock' 'wget' 'x11vnc'
          'intel-media-driver' 'libva-intel-driver' 'libva-vdpau-driver')
@@ -15,7 +16,7 @@ binfiles="add_storage.py balance_storage_groups.py empty_storage_groups.py remov
           jobqueue_helper.py gen_lib_xml.py
           diskspace.sh find_orphans.py optimize_mythdb.py lh_mtc.py
           misc_recent_recordings.pl misc_status_config.py misc_status_info.sh
-          misc_upcoming_recordings.pl misc_which_recorder.pl
+          misc_upcoming_recordings.pl misc_which_recorder.pl plexmediascanner.sh
           create_media_dirs.sh be_check.py
           myth2mkv myth2mp3 myth2videos udev_link.sh"
 source=($binfiles
@@ -37,7 +38,7 @@ sha256sums=('525bfe29b63d3ec5a17a32fa29745e24070020490c3f5b6dd6b03250348fb324'
             '87875d9e5f5ce18208f419698ce69b6bcbcd08955a57a4a13940e715af58b787'
             '93d664f4a46fda05d0f754d19df40cbda120e325b80c07092345b14763993833'
             '8d6d09cedc85e49712144699ccb905be6ef663e9ab0bc01abd434370ab12fede'
-            '97a0ceb3a6ca667563becd42d9808a5077478da28245bf08d5c4fce9aa697067'
+            'b8871ab7e2aefac6c8ff3149a70d3624a48615fcbec7672ec20d321180d5c846'
             '91bdec992bb2c933e15625c181f2195c402060b879168ebf35944cb064c904b9'
             '5cacfdd02833e5a3130d765573e772e6bd5030336ba86239c5e4db5ffa36fc69'
             'ebdb3ee0212e0cc72526bb5e50a032573e1894acb7bf75617243b0b49aa1f8f2'
@@ -49,13 +50,14 @@ sha256sums=('525bfe29b63d3ec5a17a32fa29745e24070020490c3f5b6dd6b03250348fb324'
             '1819085bd2c9106482c5f243b95fddf3dae69212330ab76cb493add5c26a45a4'
             '62a5a195ddfaa13bbc7b5bc627cdd748f5d697d178a5238b71a703533bfdd587'
             '1d12a128a01dbf6327a80daab9edfdc57d393d02074d19c6a5bd54560cc6b0c0'
+            'bfb0cc87bf350214f38a262400bee0174fca75f15bed4eec6bdad4a34dde174c'
             'bffcc13e4b480f720feb2b3c781bc4247c63303250c3d885022c699573d45a33'
             '51093acab5e5a4de51a55f4bdf7b935f4f69edf3d84f1c37db710853ec95eca8'
             'ad4ddabbc34d5e1b308ece33cabf91d750f44894c52a18325762dea026152973'
             'a961cfdc6f02b12fb445777dd2c144fed96306ca2f430cc8853ae307c759c1ad'
             'd8574104b75c6d41284488612ec5583c50a8dab438492fa42c47231add4cfc54'
             '6bdbf593d3e1348d1a8f7c4c17cb2e893f7e18ae355daf978173e669cfe3be80'
-            '2fe78433b7b671d031450741d37167e3a20524a40e051a28643768c861555723'
+            'b3f02ec3f8cedc98c74b3169049b7b6aa78bd79d558a8bc98d00e064b983965c'
             '186203d3c0520bb3d611da99d33a7713e9c1563814285f1f101097234f214b2f'
             'd8d36a501928d0cc505957d392291fad317b1e895ff99847d90643cf5f622a89'
             'cdfc0c836b8194f631f4a9e022c232ff75a13ff1a161a1a011858578bea5f930'
diff --git a/linhes/linhes-system/lh_mtc.cron b/linhes/linhes-system/lh_mtc.cron
index 4ab62eb..b556d60 100644
--- a/linhes/linhes-system/lh_mtc.cron
+++ b/linhes/linhes-system/lh_mtc.cron
@@ -50,7 +50,7 @@ then
 
     if ! grep -q "Finished Backup" $logFile && grep -q "Finished Optimize" $logFile
     then
-        MYTHCONFDIR=/usr/share/mythtv unbuffer lh_mtc.py --backup | $log
+        sudo -u mythtv bash -c "MYTHCONFDIR=/usr/share/mythtv unbuffer lh_mtc.py --backup | $log"
         if [ $? = 0 ]
         then
             echo "" | $log
diff --git a/linhes/linhes-system/lh_system_backup_job b/linhes/linhes-system/lh_system_backup_job
index 0c8b468..8b226ac 100755
--- a/linhes/linhes-system/lh_system_backup_job
+++ b/linhes/linhes-system/lh_system_backup_job
@@ -7,10 +7,11 @@ MYTH_RUN_STATUS="1"
 . /etc/systemconfig
 BACKUPDIR=/data/storage/disk0/backup/system_backups
 SECBACKUPLINK=/data/storage/disk1
+PLEXDIR=/var/lib/plex
 KeepBackups=14
 DATE=`date +%F_%H-%M`
 backup_status=0
-#
+MYTHHOME=`lh_home_check.sh`
 
 MYTHSHUTDOWN="/usr/bin/mythshutdown"
 
@@ -48,13 +49,6 @@ function backup(){
             mysqldump -x mythconverg > $BACKUPDIR/$DATE/mythconverg
             backup_status_check $?
 
-            echo "    ncid (caller id)"
-            mysqldump -x ncid > $BACKUPDIR/$DATE/ncid  2>/dev/null
-
-            #this is all the users
-            echo "    users"
-            mysqldump -x mysql > $BACKUPDIR/$DATE/mysql_table
-
             #this is everything
             echo "    All databases in one file"
             mysqldump -x --all-databases > $BACKUPDIR/$DATE/all_databases
@@ -71,29 +65,21 @@ function backup(){
 
     echo "Backup etc"
     cp -rp /etc  $BACKUPDIR/$DATE/etc
-    if [ -e /var/lib/oss ]
-    then
-        cp -rp /var/lib/oss $BACKUPDIR/$DATE/oss
-        backup_status_check $?
-    fi
-
-    echo "Backup func keys"
-    cp -rp /etc/pki $BACKUPDIR/$DATE/pki
 
     echo "Backup Plex Media Server databases and preferences"
-    if [ -e  /data/storage/disk0/media/plex/Plex\ Media\ Server/Plug-in\ Support ]
+    if [ -e $PLEXDIR/Plex\ Media\ Server/Plug-in\ Support ]
     then
         mkdir $BACKUPDIR/$DATE/plex
         backup_status_check $?
     fi
-    if [ -e  /data/storage/disk0/media/plex/Plex\ Media\ Server/Plug-in\ Support/Databases ]
+    if [ -e  $PLEXDIR/Plex\ Media\ Server/Plug-in\ Support/Databases ]
     then
-        cp -rp /data/storage/disk0/media/plex/Plex\ Media\ Server/Plug-in\ Support/Databases $BACKUPDIR/$DATE/plex/Databases
+        cp -rp $PLEXDIR/Plex\ Media\ Server/Plug-in\ Support/Databases $BACKUPDIR/$DATE/plex/Databases
         backup_status_check $?
     fi
-    if [ -e  /data/storage/disk0/media/plex/Plex\ Media\ Server/Plug-in\ Support/Preferences ]
+    if [ -e  $PLEXDIR/Plex\ Media\ Server/Plug-in\ Support/Preferences ]
     then
-        cp -rp /data/storage/disk0/media/plex/Plex\ Media\ Server/Plug-in\ Support/Preferences $BACKUPDIR/$DATE/plex/Preferences
+        cp -rp $PLEXDIR/Plex\ Media\ Server/Plug-in\ Support/Preferences $BACKUPDIR/$DATE/plex/Preferences
         backup_status_check $?
     fi
 
diff --git a/linhes/linhes-system/plexmediascanner.sh b/linhes/linhes-system/plexmediascanner.sh
new file mode 100755
index 0000000..6ce2f5d
--- /dev/null
+++ b/linhes/linhes-system/plexmediascanner.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+exec 2>&1
+export TERM=linux
+. /etc/conf.d/plexmediaserver
+
+sudo -uplex -gplex LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" PLEX_MEDIA_SERVER_HOME="${PLEX_MEDIA_SERVER_HOME}" PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" /usr/lib/plexmediaserver/Plex\ Media\ Scanner $@
-- 
cgit v0.12

