summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/LinHES-system')
-rwxr-xr-xabs/core/LinHES-system/LinHES-session40
-rwxr-xr-xabs/core/LinHES-system/LinHES-start19
-rwxr-xr-xabs/core/LinHES-system/PKGBUILD43
-rwxr-xr-xabs/core/LinHES-system/add_storage.py115
-rw-r--r--abs/core/LinHES-system/autostart.run7
-rwxr-xr-xabs/core/LinHES-system/balance_storage_groups.py153
-rwxr-xr-xabs/core/LinHES-system/checkXFSfrag.sh7
-rwxr-xr-xabs/core/LinHES-system/empty_storage_groups.py195
-rwxr-xr-xabs/core/LinHES-system/etc_care.cron2
-rw-r--r--abs/core/LinHES-system/find_orphans.py31
-rwxr-xr-xabs/core/LinHES-system/idle.py25
-rw-r--r--abs/core/LinHES-system/lh_system_backup_job43
-rw-r--r--abs/core/LinHES-system/linhes_update.sh72
-rw-r--r--abs/core/LinHES-system/linhes_update2.sh49
-rwxr-xr-xabs/core/LinHES-system/myth_mtc.cron26
-rwxr-xr-xabs/core/LinHES-system/myth_mtc.py59
-rwxr-xr-xabs/core/LinHES-system/mythvidexport.py20
-rwxr-xr-xabs/core/LinHES-system/stop_xss.sh2
-rw-r--r--abs/core/LinHES-system/system.install2
19 files changed, 739 insertions, 171 deletions
diff --git a/abs/core/LinHES-system/LinHES-session b/abs/core/LinHES-system/LinHES-session
index 4563078..c2b9b03 100755
--- a/abs/core/LinHES-system/LinHES-session
+++ b/abs/core/LinHES-system/LinHES-session
@@ -88,36 +88,34 @@ function load_nvidia_settings(){
function run_tilda(){
if [ -f /usr/bin/tilda ]
then
- if [ ! -e ~/.tilda/config_0 ]
+ if [ ! -e ~/.config/tilda/config_0 ]
then
- mkdir -p ~/.tilda/
+ mkdir -p ~/.config/tilda/
fi
width=`/usr/bin/xwininfo -root|grep Width | awk '{ print $2}'`
height=`/usr/bin/xwininfo -root|grep Height | awk '{ print $2}'`
center=$[width/2]
- sixtypercent=`echo "scale=0; ( $width*.6) / 1" |bc`
- quarter_height=`echo "scale=0; ($height*.35) /1" |bc`
+ tilda_width=`echo "scale=0; ( $width*.9) / 1" |bc`
+ tilda_height=`echo "scale=0; ($height*.4) /1" |bc`
-
- if [ $sixtypercent -lt 700 ]
- then
- sixtypercent=700
+ if [ $tilda_width -lt 700 ]
+ then
+ tilda_width=700
fi
- if [ $quarter_height -lt 350 ]
- then
- quarter_height=350
+ if [ $tilda_height -lt 350 ]
+ then
+ tilda_height=350
fi
- startloc=`echo "scale=0 ; (${center}-(${sixtypercent})/2) / 1" |bc`
+ startloc=`echo "scale=0 ; (${center}-(${tilda_width})/2) / 1" |bc`
- sed -e "s/^max_width.*$/max_width = $sixtypercent/" \
- -e "s/^max_height.*$/max_height = $quarter_height/" \
- -e "s/^x_pos.*$/x_pos = $startloc/g" /etc/tilda_config > ~/.tilda/config_0
+ sed -e "s/^max_width.*$/max_width = $tilda_width/" \
+ -e "s/^max_height.*$/max_height = $tilda_height/" \
+ -e "s/^x_pos.*$/x_pos = $startloc/g" /etc/tilda_config > ~/.config/tilda/config_0
/usr/bin/tilda -h &
-
fi
}
@@ -391,6 +389,15 @@ function stop_plymouth()
fi
}
+function machine-id_check()
+{
+ if [ ! -s /etc/machine-id ]
+ then
+ echo "Setting machine ID in /etc/machine-id"
+ sudo systemd-machine-id-setup
+ fi
+}
+
if [ x"$WM" = "fluxbox" ]
then
@@ -412,6 +419,7 @@ notify_scan &
auto_start &
update_apple_trailers
stop_plymouth &
+machine-id_check &
first_configure
show_help_tip
start_myth
diff --git a/abs/core/LinHES-system/LinHES-start b/abs/core/LinHES-system/LinHES-start
index 88ecffb..de6e9db 100755
--- a/abs/core/LinHES-system/LinHES-start
+++ b/abs/core/LinHES-system/LinHES-start
@@ -11,18 +11,18 @@
# Site administrators are STRONGLY urged to write nicer versions.
#
# $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $
-. /etc/profile
MYTH_RUN_STATUS="1"
+. /etc/profile
unset DBUS_SESSION_BUS_ADDRESS
unset SESSION_MANAGER
userclientrc=/etc/X11/Sessions/LinHES
userserverrc=$HOME/.xserverrc
-sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc
-sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc
-defaultclient=/usr/X11R6/bin/xterm
-defaultserver=/usr/X11R6/bin/X
+sysclientrc=/etc/X11/xinit/xinitrc
+sysserverrc=/etc/X11/xinit/xserverrc
+defaultclient=/usr/bin/xterm
+defaultserver=/usr/bin/X
defaultclientargs=""
defaultserverargs=""
clientargs=""
@@ -31,8 +31,6 @@ serverargs=""
-
-
if [ -f $userclientrc ]; then
defaultclientargs=$userclientrc
elif [ -f $sysclientrc ]; then
@@ -154,10 +152,3 @@ fi
if command -v deallocvt > /dev/null 2>&1; then
deallocvt
fi
-
-
-
-
-
-
-
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index d6b4bac..4af9bea 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
pkgname=LinHES-system
-pkgver=8.3
-pkgrel=9
+pkgver=8.4
+pkgrel=10
arch=('i686' 'x86_64')
install=system.install
pkgdesc="Everything that makes LinHES an automated system"
@@ -10,14 +10,15 @@ depends=('linhes-sounds' 'xdotool' 'tilda' 'keylaunch'
'python2-dbus' 'unclutter' 'wmctrl' 'archlinux-xdg-menu'
'ethtool' 'gnu-netcat' 'normalize' 'ttf-overlock'
'handbrake-cli' 'mkvtoolnix' 'mplayer' 'runit-scripts>=8.1-12')
-backup=('etc/modprobe.d/alsa-base.conf')
+backup=('etc/modprobe.d/alsa-base.conf' 'etc/X11/autostart/autostart.run')
binfiles="LinHES-start optimize_mythdb.py myth_mtc.py
load-modules-mythvantage.sh unclutter-toggle.sh tvterm.sh
mythfrontend-start set_windowmanager.sh myth_status.py myth_status.sh
install_supplemental_service.sh get_airplay_key importfiles.sh
lh_system_backup lh_system_backup_job lh_system_restore_job
lh_system_host_update lh_system_all_host_update
- add_storage.py diskspace.sh cacheclean lh_backend_control.sh
+ add_storage.py balance_storage_groups.py empty_storage_groups.py
+ diskspace.sh cacheclean lh_backend_control.sh
create_media_dirs.sh msg_client.py msg_daemon.py mythvidexport.py
gen_is_xml.py gen_lib_xml.py gen_light_include.py gen_game_xml.py
misc_recent_recordings.pl misc_status_config.py misc_status_info.sh
@@ -27,7 +28,7 @@ binfiles="LinHES-start optimize_mythdb.py myth_mtc.py
linhes_update.sh linhes_update2.sh myth2mkv myth2mp3 ripD_eject.sh
mythwelcome-config.py mythwelcome-set-alarm.sh mythwelcome-test-wakeup.sh"
-source=(LinHES-session LinHES-profile.sh $binfiles
+source=(LinHES-session autostart.run LinHES-profile.sh $binfiles
alsa-base cacheclean.cron fstrim.cron myth_mtc.cron xfs_defrag.cron etc_care.cron
readme_is_xml readme_light add_storage.readme
system-sudo.rules msg.cfg)
@@ -39,6 +40,7 @@ package() {
BINDIR=$pkgdir/usr/bin
install -m755 -D LinHES-session $pkgdir/etc/X11/Sessions/LinHES
+ install -m755 -D autostart.run $pkgdir/etc/X11/autostart/autostart.run
install -m755 -D LinHES-profile.sh $pkgdir/etc/profile.d/LinHES-profile.sh
#files install to /usr/LH/bin
@@ -77,11 +79,12 @@ package() {
}
-md5sums=('8415c4b2587a8a1e6a312484c1edafcb'
+md5sums=('c03d5e54f00e404c561c7dc69fff9168'
+ 'ad5e144999b6f37931dea799c2761c7e'
'de32a1c50101265dd7f6ca5037f7a26a'
- '301884fb60521627fffd1160b2cf5181'
+ '2d7b8414ddce5f401331342ac1529c22'
'76b2637cac0452b3acdbeeb4e8a5474b'
- 'd02ddadeb2181f90954e435842cd7f0a'
+ '8e5d224788154fea8639a37eecdaefd9'
'dc3eef2a624754e16805d72bbe488b67'
'617af86b901538817ebdcaf646248dc5'
'542e670e78d117657f93141e9689f54d'
@@ -93,18 +96,20 @@ md5sums=('8415c4b2587a8a1e6a312484c1edafcb'
'33fbebbd546672cedd3c5e7350ab414e'
'c773d8caacba8fbd4968e8afe5137bc6'
'3edef50a49a47694bf8add39cc160add'
- '8336874ee9e527f9799c3dec9fb770b5'
+ 'a730185e0d5d8bd0b6d06938d841c8c0'
'bc69a520add58ede9b060c73e67ace13'
'74e17d6f7453c52d56fecaed5c3f6ad5'
'47e093e8cfe4b5b96602358e1f540832'
- '63bbc62240f46a9997eaae4a84b09b76'
+ 'e270f46a1737a52e8f6b915830ef65f7'
+ '0c81e5cad656f6260e39cd7585b1421a'
+ 'e5bb027c54a2727d0bcf8d6fb357ba32'
'2c005d95312018bef80092136f80f254'
'c8db6a83ecc089ea37ab7fcb0f7a01cf'
'ca63946920ba33de1f15abda83e74e40'
'84c0ea62550b0bf9d84ab48eddc08276'
'3e60b17892e5b8214d47dcfddf5215a4'
'57ec994cc3964a10c00580e89ebcae35'
- '1da933fd2f4436c1ecaf3d6d0c7c0d68'
+ '00330dab3979f34b07b23b20ea06d37e'
'0c3509b48f11af0dc1bf989721fe9ca7'
'9249313ae171abd5405f60625020da63'
'f3502bb7c665750da0ecdf6918f7c838'
@@ -117,14 +122,14 @@ md5sums=('8415c4b2587a8a1e6a312484c1edafcb'
'd8f30983055dcfe2f53197d0f9a62158'
'17f678d37187be0f12d67f64e40429c6'
'bacc813b48bafcc6fe906e5969930501'
- '8e02efe1ad0df9a179075147eebb05b9'
+ 'dedd3fcb1abec6361f4060d8149c7d6d'
'8b0298f70f97cc1dc2a58b9a73c64bd3'
- '716710e0db42147b079c9ec1c7080efa'
- '34fc1f58ad1eabf4eff4979d420760c0'
- '69ecfe682f1b61c2c4c95d890b9f523c'
+ 'b4bb70650893c811c854d446cfa6ca6a'
+ 'e30bf8ec8b9dcc2ceb7127375a91d8d1'
+ 'e9f545c3bcf9c85b45496c281fc6a1b8'
'a94fe6d980f4b810f2e2ae5352084b39'
- '384956b4fd9bf40907856bab0e67b169'
- 'f4ce577e2ab1b6dbf9def46a8ab86e2d'
+ '0d1632ea63d8145c173c6aecf0b007f0'
+ 'ff689f2e9572a78d88384b2e5774f579'
'28f29578e5b3ba84fdf2aa57cf475bcf'
'4a1fda884dcd7d65fb2690fbdbd92a83'
'2b7fe3b57592823a4c7e3ec132dcb7f4'
@@ -134,9 +139,9 @@ md5sums=('8415c4b2587a8a1e6a312484c1edafcb'
'eb879fee9603a05d5420d4ce8ed9e450'
'02c810c2f47b7c4495fdacaf54189473'
'1aac1872bf9569ea58ceb2f6f766a654'
- 'dc48a53d4e5fe27b218657ccc318d07f'
+ '1fb7b4badf30508b0a761a2ae7d7887d'
'4d7164800122243be6513b29c8fc498e'
- 'd14fdc38878c70011754317b0f2ea59e'
+ '0b05329fda4b7c982778c233495a53d9'
'36bdfa8d877cea20ca3870faf08e08d5'
'59d0602bac7e06f11abba1894acc8bb0'
'b12bbf3e028f51b08acef2799a5708bc'
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py
index 2518927..260421f 100755
--- a/abs/core/LinHES-system/add_storage.py
+++ b/abs/core/LinHES-system/add_storage.py
@@ -2,7 +2,7 @@
#add_storage.py used to auto add new storage to MythTV storage groups
#If it's a new disk it will erase the entire disk and reformat.
#
-#Disks that are mounted, in fstab, size < 5000 bytes, optical or
+#Disks that are mounted, in fstab, size < 5000 bytes, optical or
#have already been seen will not be presented as an option.
#
@@ -31,9 +31,11 @@ SG_MAP={
'Music' :'media/music',
'Streaming' :'media/streaming',
'Videos' :'media/video',
+ 'Photographs':'media/photos',
'Banners' :'media/artwork/banners',
'Coverart' :'media/artwork/coverart',
'Fanart' :'media/artwork/fanart',
+ 'MusicArt' :'media/artwork/musicart',
'Screenshots':'media/artwork/screenshots',
'Trailers' :'media/artwork/trailers',
}
@@ -296,7 +298,7 @@ class disk_device:
print " Creating directory structure:"
print " %s" %self.new_mount_point
for y in FS_LIST:
- print " %s" %y
+ print " %s" %y
new_dir="%s/%s" %(self.new_mount_point,y)
try:
os.stat(new_dir)
@@ -351,6 +353,7 @@ class disk_device:
self.config.set('storage','fstype',self.new_fstype)
self.config.set('storage','shareable','True')
self.config.set('storage','mmount',self.mmount)
+ self.config.set('storage','storage_groups',self.dir_sg)
self.config.set('storage','disk_num',self.disk_num)
@@ -364,7 +367,7 @@ class disk_device:
return
def symlink_disk(self):
- print " Creating symlink for disk%s" %self.disk_num
+ print " Creating symlink for disk%s" %self.disk_num
disk_ln="%s/disk%s" %(self.top_mount_dir,self.disk_num)
cmd = "ln -s %s %s" %(self.new_mount_point,disk_ln)
runcmd(cmd)
@@ -479,7 +482,7 @@ def prompt_to_continue(process_list):
if destruction:
print "** WARNING: These disk(s) WILL be partitioned and formatted. **\n ** All content on these disk(s) will be erased. **"
else:
- print " ** These disk(s) will NOT be partitioned and formatted. **"
+ print " ** These disk(s) will NOT be partitioned and formatted. **"
for i in process_list:
print " %s" %(i.get_name())
str1 = raw_input("\n Press Y to add disk(s), any other key to cancel:")
@@ -503,12 +506,12 @@ def prompt_sg(dir_sg):
loop = True
prompt_string='''
MythTV Storage Groups are used for artwork, database backups,
- music, streaming, TV recordings, and videos.
+ photos, music, streaming, TV recordings, and videos.
The content on these storage groups will
only be available while the system is online.
- Enabling MythTV Storage Groups will create the directories
+ Enabling MythTV Storage Groups will create the directories
on the disk(s) and add the paths to the MythTV database.
Enable MythTV Storage Groups (Y/N)?:'''
@@ -551,7 +554,7 @@ def last_disk_num():
return num_list[-1]
#--------------------------------------------
-def main(scan_only, destruction, no_mount, install_call , dir_sg):
+def main(scan_only, destruction, no_mount, install_call, dir_sg):
global bus
bus = dbus.SystemBus()
@@ -742,6 +745,83 @@ def myth_main(no_mount,install_call,dir_sg):
cmd = "systemconfig.py -m fileshare"
runcmd(cmd)
+def reconstruct_storagegroups():
+ print "\nRecreating Storage Groups from contents of /etc/storage.d/\n"
+
+ DB = MythDB()
+ host=gethostname()
+
+ for conf_file in glob.glob('%s/*.conf' %storage_dir):
+ parser = SafeConfigParser()
+ parser.read(conf_file)
+ mount_point = parser.get('storage', 'mountpoint')
+ mmount = parser.getboolean('storage', 'mmount')
+ if not os.path.ismount(mount_point):
+ print "Skipping: " + mount_point + " not mounted"
+ continue
+ try:
+ dir_sg = parser.getboolean('storage', 'storage_groups')
+ except ConfigParser.NoOptionError, err:
+ print "SG not found in conf, get setting from DB"
+ dir_sg = False
+ # Get Storage Group directories from DB
+ recs = DB.getStorageGroup(groupname="Default")
+ for record in recs:
+ if record.dirname.startswith(mount_point):
+ dir_sg = True
+ # Write SG usage to conf
+ parser.set('storage','storage_groups',str(dir_sg))
+ with open(conf_file, 'wb') as conf_file:
+ parser.write(conf_file)
+
+ if dir_sg is True:
+ print "SGs Enabled for: " + mount_point
+ print " Creating directory structure:"
+ print " %s" %mount_point
+ for y in FS_LIST:
+ new_dir="%s/%s" %(mount_point,y)
+ try:
+ os.stat(new_dir)
+ print " %s - exists" %y
+ except:
+ os.makedirs(new_dir)
+ cmd="chown -R mythtv:mythtv /%s" %new_dir
+ runcmd(cmd)
+ cmd="chmod -R 775 /%s" %new_dir
+ runcmd(cmd)
+ print " %s - created" %y
+
+ print " Adding storage groups to DB"
+ if mmount is True:
+ sgweight=99
+ else:
+ sgweight=0
+
+ for key in SG_MAP.iterkeys():
+ gn=key
+ hn=host
+ dn="%s/%s" %(mount_point,SG_MAP[key])
+ with DB as c:
+ try:
+ c.execute("""insert into storagegroup (groupname,hostname,dirname) values (%s,%s,%s)""",(gn,hn,dn))
+ print " Added: %s to storagegroup %s" %(dn,gn)
+ except:
+ print " Skipping: %s exists" %dn
+ if sgweight > 0:
+ try:
+ sgw="SGweightPerDir:%s:%s" %(hn,dn)
+ if DB.settings[hn][sgw] == u'99':
+ print " Skipping: storage group weight DB entry exists"
+ else:
+ c.execute("""insert into settings (value,data,hostname) values (%s,%s,%s)""",(sgw,sgweight,hn))
+ print " Adding storage group weight of %s for %s\n" %(sgweight,gn)
+ except:
+ print " *Error setting storage group weight %s for %s\n" %(sgweight,gn)
+
+ else:
+ print "SGs Disabled for: " + mount_point
+ return
+
class reconstruct_path:
def __init__(self,conf_file):
self.conf_file = conf_file
@@ -841,7 +921,7 @@ class reconstruct_path:
print " Skipping symlink, /myth already exists"
def symlink_disk(self):
- print " Creating symlink for disk%s" %self.disk_num
+ print " Creating symlink for disk%s" %self.disk_num
disk_ln="%s/disk%s" %(self.top_mount_dir,self.disk_num)
cmd = "ln -s %s %s" %(self.mount_point,disk_ln)
runcmd(cmd)
@@ -897,6 +977,7 @@ class reconstruct_path:
self.config.set('storage','fstype',self.fstype)
self.config.set('storage','shareable','True')
self.config.set('storage','mmount',self.myth_mount)
+ self.config.set('storage','storage_groups',self.dir_sg)
self.config.set('storage','disk_num',self.disk_num)
print " %s" %self.conf_file
@@ -935,7 +1016,7 @@ def usage():
Scanned disks are ignored if they are mounted or have been
previously skipped by add_storage.py.
- The file system type for disks added by add_storage.py is
+ The file system type for disks added by add_storage.py is
automatically set to the type selected for the data partition
at install.
@@ -953,9 +1034,10 @@ def usage():
(if user enables MythTV Storage Groups)
Options:
- --add_sg: Create the MythTV Storage Group directories and
+ --add_sg: Create the MythTV Storage Group directories and
database entries for database backups, TV
- recordings, music, streaming, videos and artwork.
+ recordings, photos, music, streaming, videos
+ and artwork.
-h, --help: Show this help message.
--new_init: Erase the list of known disks and rescan.
--no_destruction: Will not partition or format the disk.
@@ -969,6 +1051,9 @@ def usage():
/data/storage/disk# symlink, and mount the disk.
--no_mount is the only option that works with
--reconstruct.
+ --reconstruct_sg: Recreate the MythTV Storage Group directories and
+ database entries if they don't exist.
+ No other options work with --reconstruct_sg.
--report: Scan disks and print new found disks.
'''
print help
@@ -985,6 +1070,7 @@ if __name__ == "__main__":
install_call = False
dir_sg = False
reconstruct = False
+ reconstruct_sg = False
try:
os.remove("/tmp/scan_report")
except:
@@ -1025,9 +1111,14 @@ if __name__ == "__main__":
if "--reconstruct" in sys.argv:
reconstruct = True
+ if "--reconstruct_sg" in sys.argv:
+ reconstruct_sg = True
+
if "--double_myth" in sys.argv:
myth_main(no_mount, install_call, dir_sg)
elif reconstruct == True:
reconstruct_mounts(no_mount)
+ elif reconstruct_sg == True:
+ reconstruct_storagegroups()
else:
- main(scan_only,destruction,no_mount, install_call, dir_sg)
+ main(scan_only, destruction, no_mount, install_call, dir_sg)
diff --git a/abs/core/LinHES-system/autostart.run b/abs/core/LinHES-system/autostart.run
new file mode 100644
index 0000000..278bc2b
--- /dev/null
+++ b/abs/core/LinHES-system/autostart.run
@@ -0,0 +1,7 @@
+#!/bin/bash
+# autostart.run runs after X has started.
+# Put startup commands for scripts and programs in this file.
+# Any files with execute permission in /etc/X11/autostart will also be run
+# when X starts.
+# Scripts and programs that don't require X can be started from
+# /etc/runit/1.local.
diff --git a/abs/core/LinHES-system/balance_storage_groups.py b/abs/core/LinHES-system/balance_storage_groups.py
new file mode 100755
index 0000000..27de6a9
--- /dev/null
+++ b/abs/core/LinHES-system/balance_storage_groups.py
@@ -0,0 +1,153 @@
+#!/usr/bin/python2
+
+import argparse, glob, operator, os, random, shutil, subprocess, sys, signal
+shouldQuit = False
+
+def getFreeSpaceForDir(dir):
+ stats = os.statvfs(dir)
+ return (stats.f_bavail * stats.f_frsize)
+
+def getFreePercentForDir(dir):
+ stats = os.statvfs(dir)
+ total = (stats.f_blocks)
+ avail = (stats.f_bavail)
+ return (total - avail) / float(total)
+
+def getFileSize(fullPath):
+ return os.path.getsize(fullPath)
+
+def sizeof_fmt(num, suffix='B'):
+ for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
+ if abs(num) < 1024.0:
+ return "%3.1f %s%s" % (num, unit, suffix)
+ num /= 1024.0
+ return "%.1f %s%s" % (num, 'Yi', suffix)
+
+def signal_handler(signal, frame):
+ print "\nWill quit when file has been moved.\nMoving File..."
+ global shouldQuit
+ shouldQuit = True
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-c', '--checkonly', action='store_true', help="Check only, don't move any files.")
+ parser.add_argument('-p', '--percent', type=int, default=7, help="The percentage difference between the most full dir and least full dir that will stop balancing.")
+ cmdargs = parser.parse_args()
+
+ SGDIRS = []
+ SGgrp = "Default"
+
+ signal.signal(signal.SIGINT, signal_handler)
+
+ print "\nBalance MythTV Storage Group Directories\nPress Ctrl+C to quit"
+
+ # Get Storage Groups from MythDB
+ try:
+ from MythTV import MythDB
+ mythDB = MythDB()
+ records = mythDB.getStorageGroup()
+ except:
+ print "Couldn't connect to MythTV database."
+ sys.exit(1)
+
+ # Get Storage Group directories
+ for record in records:
+ if record.groupname == SGgrp:
+ dirname = record.dirname
+ SGDIRS.append(dirname)
+
+ # If there are less than 2 directories defined bail as we can't move anything
+ if len(SGDIRS) < 2:
+ print "There are less than 2 directories defined. Exiting."
+ sys.exit(0)
+
+ while not shouldQuit:
+ SGDIRSdata = []
+ print "\n------------------------------------------------"
+ print "'" + SGgrp + "' Storage Group Directories - Percent Used:"
+ # Get percent free and size free
+ for directory in SGDIRS:
+ # Check if SG path exists
+ if not os.path.exists(directory):
+ print " " + directory + " - Not Mounted"
+ continue
+ freePcent = getFreePercentForDir(directory)
+ freeSize = getFreeSpaceForDir(directory)
+ SGDIRSdata.append([directory, freePcent, freeSize])
+ print " %s - %.2f%%" % (directory, freePcent * 100)
+
+ # Sort data on percent free
+ SGDIRSdata = sorted(SGDIRSdata, reverse=True, key=operator.itemgetter(1))
+ #print SGDIRSdata
+
+ # Check if SG has any ts, mpg or nuv files
+ i=0
+ for dir in SGDIRSdata:
+ mostFull = SGDIRSdata[i]
+ i=i+1
+ if len(glob.glob1(mostFull[0],"*.ts")) or len(glob.glob1(mostFull[0],"*.mpg")) or len(glob.glob1(mostFull[0],"*.nuv")):
+ break
+ else:
+ if i == 1:
+ print "------------------------------------------------"
+ print " " + mostFull[0] + " - NO files to move"
+
+ leastFull = SGDIRSdata[-1]
+
+ print "------------------------------------------------"
+ print "Most Used Storage Group Directory with files to move: "
+ print " %s - %.2f%%" % (mostFull[0], mostFull[1] * 100)
+ print "Least Used Storage Group Directory: "
+ print " %s - %.2f%%" % (leastFull[0], leastFull[1] * 100)
+
+ # Check if mostFull and leastFull are within the percent var of each other
+ if mostFull[1] - (float(cmdargs.percent) / 100) < leastFull[1]:
+ print "\nThe most used and least used storage group directories are\nwithin " + str(cmdargs.percent) + "% used of each other. No files will be moved."
+ sys.exit()
+
+ # Get random file from most used dir
+ fileToMove = random.choice([f for f in os.listdir(mostFull[0]) if f.endswith(".ts") or f.endswith(".mpg") or f.endswith(".nuv")])
+ filePathToMove = mostFull[0] + "/" + fileToMove
+
+ # Check that the file isn't too big for least used dir
+ fileSize = getFileSize(filePathToMove)
+ if (fileSize > getFreeSpaceForDir(leastFull[0])):
+ # Too big to move
+ print filePathToMove + " is too big to move to " + leastFull[0]
+ sys.exit()
+
+ print "------------------------------------------------"
+ print "Move File:"
+ print " " + filePathToMove
+ print " Size: " + sizeof_fmt(os.path.getsize(filePathToMove))
+ print "To:"
+ print " " + leastFull[0]
+ print " Available: " + sizeof_fmt(getFreeSpaceForDir(leastFull[0]))
+
+ # Move file
+ if cmdargs.checkonly:
+ print "------------------------------------------------"
+ print"Check Only option was used. No files were moved."
+ shouldQuit = True
+ else:
+ print "------------------------------------------------"
+ print "Checking System Status..."
+ if subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py", "-s"]):
+ print " System is busy. The file will not be moved."
+ sys.exit()
+ print "Moving File..."
+ try:
+ shutil.move(filePathToMove, leastFull[0])
+ # eg. src and dest are the same file
+ except shutil.Error as e:
+ print('Error: %s' % e)
+ except IOError as e:
+ print('Error: %s' % e.strerror)
+
+ # Remove png files
+ print "------------------------------------------------"
+ print "Removing png Files:"
+ pngFiles = glob.glob(filePathToMove + "*.png")
+ for p in pngFiles:
+ os.remove(p)
+ print " " + p
diff --git a/abs/core/LinHES-system/checkXFSfrag.sh b/abs/core/LinHES-system/checkXFSfrag.sh
index 74b73c4..709cdac 100755
--- a/abs/core/LinHES-system/checkXFSfrag.sh
+++ b/abs/core/LinHES-system/checkXFSfrag.sh
@@ -27,10 +27,11 @@
# Original Release: 2011 December 15 (Merry Christmas!)
# DO NOT ALTER HEADER FROM THIS LINE UP.
#
-e='/bin/echo -e' # Use the echo command, not built-in.
+e='/usr/bin/echo -e' # Use the echo command, not built-in.
xfsfsr=/usr/bin/xfs_fsr # Set variable with the path to xfs_fsr.
xfsdb=/usr/bin/xfs_db # Set variable with the path to xfs_db.
-pctmax=15 # Set maxiumum frag percent needed for defrag.
+ionice=/usr/bin/ionice # Set variable with the path to ionice.
+pctmax=12 # Set maxiumum frag percent needed for defrag.
# This is zero here for testing purposes only
# a higher number should be used in production.
array=`df -T|grep xfs|cut -f 1 --delim=" "` # Array of all XFS file systems.
@@ -48,7 +49,7 @@ do
$e "${i} is $percentage% fragmented. Running defragment on ${i}."
# Only uncomment one of the following two lines.
#$xfsfsr -v ${i} # Uncomment for verbose defrag.
- $xfsfsr ${i} # Uncomment for quiet defrag.
+ $ionice -c3 $xfsfsr ${i} # Uncomment for quiet defrag.
else
$e "${i} is $percent2% fragmented and is below the fragmentation threshold of $pctmax%. Skipping."
fi
diff --git a/abs/core/LinHES-system/empty_storage_groups.py b/abs/core/LinHES-system/empty_storage_groups.py
new file mode 100755
index 0000000..63adfe9
--- /dev/null
+++ b/abs/core/LinHES-system/empty_storage_groups.py
@@ -0,0 +1,195 @@
+#!/usr/bin/python2
+
+import argparse, glob, operator, os, random, shutil, subprocess, sys, signal
+shouldQuit = False
+
+def getFreeSpaceForDir(dir):
+ stats = os.statvfs(dir)
+ return (stats.f_bavail * stats.f_frsize)
+
+def getFreePercentForDir(dir):
+ stats = os.statvfs(dir)
+ total = (stats.f_blocks)
+ avail = (stats.f_bavail)
+ return (total - avail) / float(total)
+
+def getFileSize(fullPath):
+ return os.path.getsize(fullPath)
+
+def sizeof_fmt(num, suffix='B'):
+ for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
+ if abs(num) < 1024.0:
+ return "%3.1f %s%s" % (num, unit, suffix)
+ num /= 1024.0
+ return "%.1f %s%s" % (num, 'Yi', suffix)
+
+def signal_handler(signal, frame):
+ print "\nWill quit when file has been moved.\nMoving File..."
+ global shouldQuit
+ shouldQuit = True
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-c', '--checkonly', action='store_true', help="Check only, don't move any files.")
+ cmdargs = parser.parse_args()
+
+ SGs = []
+ SGDIRS = []
+ SGgrp = "Default"
+ SGselectdata = []
+
+ signal.signal(signal.SIGINT, signal_handler)
+
+ print "\nEmpty a MythTV Storage Group Directory\nPress Ctrl+C to quit"
+
+ # Get Storage Groups from MythDB
+ try:
+ from MythTV import MythDB
+ mythDB = MythDB()
+ records = mythDB.getStorageGroup()
+ recs = mythDB.getStorageGroup()
+ except:
+ print "Couldn't connect to MythTV database."
+ sys.exit(1)
+
+ # get list of non duplicate SGs
+ for record in records:
+ SGs.append(record.groupname)
+ SGs=list(set(SGs))
+ # Move Default to top of list
+ if "Default" in SGs:
+ SGs.remove("Default")
+ SGs.insert(0,"Default")
+
+ # ask user which SG to use
+ print "\n------------------------------------------------"
+ print "Storage Groups:"
+ for i,sg in enumerate(SGs):
+ print str(i+1) + ": " + sg
+
+ try:
+ SGselect=raw_input("\nEnter the number of the storage group to use (default 1): ") or 1
+ SGselect=int(SGselect)
+ if SGselect > len(SGs) or SGselect < 1:
+ SGselect=int("e")
+ except ValueError:
+ print "You must enter a number between 1 and " + str(len(SGs)) + ". Exiting."
+ sys.exit(0)
+
+ SGgrp=SGs[SGselect-1]
+
+ # Get Storage Group directories
+ for record in recs:
+ if record.groupname == SGgrp:
+ dirname = record.dirname
+ SGDIRS.append(dirname)
+
+ # If there are less than 2 directories defined bail as we can't move anything
+ if len(SGDIRS) < 2:
+ print "There are less than 2 directories defined. Exiting."
+ sys.exit(0)
+
+ while not shouldQuit:
+ SGDIRSdata = []
+ print "\n------------------------------------------------"
+ print "'" + SGgrp + "' Storage Group Directories - Percent Used:"
+ SGcnt=0
+ # Get percent free and size free
+ for directory in SGDIRS:
+ # Check if SG path exists
+ if not os.path.exists(directory):
+ print " " + directory + " - Not Mounted"
+ continue
+ # Check if SG has data files to move
+ if len(glob.glob1(directory,"*.ts")) or len(glob.glob1(directory,"*.mpg")) or len(glob.glob1(directory,"*.nuv")) or len(glob.glob1(directory,"*.jpg")):
+ freePcent = getFreePercentForDir(directory)
+ freeSize = getFreeSpaceForDir(directory)
+ SGDIRSdata.append([directory, freePcent, freeSize])
+ SGcnt=SGcnt+1
+ print "%s: %s - %.2f%%" % (SGcnt, directory, freePcent * 100)
+ else:
+ # Check if the selected SG dir has no data files exit
+ if SGselectdata and SGselectdata[0] == directory:
+ print "\n'" + SGgrp + "' Storage Group directories have no files to move. Exiting"
+ sys.exit(0)
+
+ # Exit if no SGs with data found
+ if SGcnt is 0:
+ print "\n'" + SGgrp + "' Storage Group directories have no files to move. Exiting."
+ sys.exit(0)
+
+ # Ask user to select which SG to empty if not already selected
+ if not SGselectdata:
+ try:
+ SGDIRselect=int(raw_input("\nEnter the number of the storage group directory to empty: "))
+ if SGDIRselect > SGcnt or SGDIRselect < 1:
+ SGDIRselect=int("e")
+ except ValueError:
+ print "You must enter a number between 1 and %s. Exiting." %SGcnt
+ sys.exit(0)
+
+ SGselectdata=SGDIRSdata[SGDIRselect-1]
+
+ # Sort data on percent free
+ SGDIRSdata = sorted(SGDIRSdata, reverse=True, key=operator.itemgetter(1))
+ leastFull = SGDIRSdata[-1]
+
+ # Make sure leastFull and SGselectdata are not the same dir
+ if leastFull[0] == SGselectdata[0]:
+ leastFull = SGDIRSdata[-2]
+
+ # Get random file from user selected dir
+ fileToMove = random.choice([f for f in os.listdir(SGselectdata[0]) if f.endswith(".ts") or f.endswith(".mpg") or f.endswith(".nuv") or f.endswith(".jpg")])
+ filePathToMove = SGselectdata[0] + "/" + fileToMove
+
+ # Check that the file isn't too big for least used dir
+ fileSize = getFileSize(filePathToMove)
+ if (fileSize > getFreeSpaceForDir(leastFull[0])):
+ # Too big to move
+ print filePathToMove + " is too big to move to " + leastFull[0]
+ sys.exit()
+
+ print "------------------------------------------------"
+ print "Move File:"
+ print " " + filePathToMove
+ print " Size: " + sizeof_fmt(os.path.getsize(filePathToMove))
+ print "To:"
+ print " " + leastFull[0]
+ print " Available: " + sizeof_fmt(getFreeSpaceForDir(leastFull[0]))
+
+ # Move file
+ if cmdargs.checkonly:
+ print "------------------------------------------------"
+ print"Check Only option was used. No files were moved."
+ shouldQuit = True
+ else:
+ print "------------------------------------------------"
+ print "Checking System Status..."
+ if subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py", "-s"]):
+ print " System is busy. The file will not be moved."
+ sys.exit()
+ print "Moving File..."
+ try:
+ shutil.move(filePathToMove, leastFull[0])
+ # eg. src and dest are the same file
+ except shutil.Error as e:
+ a=raw_input("\n%s. Overwrite destination (y/n)? " % e)
+ if a == "y" or a == "Y":
+ os.remove(leastFull[0] + "/" + fileToMove)
+ shutil.move(filePathToMove, leastFull[0])
+ else:
+ b=raw_input("\nRemove %s (y/n)? " % filePathToMove)
+ if b == "y" or b == "Y":
+ os.remove(filePathToMove)
+ # eg. source or destination doesn't exist
+ except IOError as e:
+ print('Error: %s' % e.strerror)
+
+ # Remove png files for Default & LiveTV SGs
+ if SGgrp == "Default" or SGgrp == "LiveTV":
+ print "------------------------------------------------"
+ print "Removing png Files:"
+ pngFiles = glob.glob(filePathToMove + "*.png")
+ for p in pngFiles:
+ os.remove(p)
+ print " " + p
diff --git a/abs/core/LinHES-system/etc_care.cron b/abs/core/LinHES-system/etc_care.cron
index 97e0283..ef405e8 100755
--- a/abs/core/LinHES-system/etc_care.cron
+++ b/abs/core/LinHES-system/etc_care.cron
@@ -4,7 +4,7 @@ MYTH_RUN_STATUS=1
KeepBackups=4
-for f in "/etc/lircd.conf" "/etc/lircrc" "/etc/wol-lircrc" "/etc/remote.run" "/etc/asound.conf"
+for f in "/etc/lircd.conf" "/etc/lircrc" "/etc/lirc/lircd.conf.d/remote_lircd.conf" "/etc/wol-lircrc" "/etc/remote.run" "/etc/asound.conf"
do
NumBackups=`ls -d $f-* | wc -l`
if [[ $NumBackups -gt $KeepBackups ]]
diff --git a/abs/core/LinHES-system/find_orphans.py b/abs/core/LinHES-system/find_orphans.py
index cdc03d4..b1d78de 100644
--- a/abs/core/LinHES-system/find_orphans.py
+++ b/abs/core/LinHES-system/find_orphans.py
@@ -12,7 +12,7 @@ def human_size(s):
while s > 1000:
s /= 1000
o += 1
- return str(round(s,1))+('B ','KB','MB','GB')[o]
+ return str(round(s,1))+('B ','KB','MB','GB','TB')[o]
class File( str ):
def __new__(self, host, group, path, name, size):
@@ -69,8 +69,9 @@ def populate(host=None):
hosts = [r[0] for r in c.fetchall()]
for host in hosts:
for sg in DB.getStorageGroup():
- if sg.groupname in ('Videos','Banners','Coverart',\
- 'Fanart','Screenshots','Trailers'):
+ if sg.groupname in ('Videos','Banners','Coverart','Fanart',\
+ 'Music','MusicArt', 'Photographs',\
+ 'Screenshots','Trailers'):
continue
try:
dirs,files,sizes = BE.getSGList(host, sg.groupname, sg.dirname)
@@ -97,7 +98,7 @@ def populate(host=None):
if name in f:
unfiltered.remove(f)
for f in list(unfiltered):
- if not (f.endswith('.mpg') or f.endswith('.nuv')):
+ if not (f.endswith('.mpg') or f.endswith('.nuv') or f.endswith('.ts')):
continue
orphvids.append(f)
unfiltered.remove(f)
@@ -120,7 +121,7 @@ def populate(host=None):
def delete_recs(recs):
printrecs('The following recordings will be deleted', recs)
- print 'Are you sure you want to continue?'
+ print 'Are you sure you want to continue? (yes/no)'
try:
res = raw_input('> ')
while True:
@@ -144,7 +145,7 @@ def delete_recs(recs):
def delete_files(files):
printfiles('The following files will be deleted', files)
- print 'Are you sure you want to continue?'
+ print 'Are you sure you want to continue? (yes/no)'
try:
res = raw_input('> ')
while True:
@@ -190,10 +191,15 @@ def main(host=None):
if len(unfiltered):
opts.append(['Delete other files', delete_files, unfiltered])
opts.append(['Refresh list', None, None])
- print 'Please select from the following'
+ print 'Please select from the following:'
for i, opt in enumerate(opts):
- print ' {0}. {1}'.format(i+1, opt[0])
+ if opt[0] == "Refresh list":
+ print ' R. {1}'.format(i+1, opt[0])
+ refreshNum=i+1
+ else:
+ print ' {0}. {1}'.format(i+1, opt[0])
+ print ' Q. Quit'
try:
inner = True
res = raw_input('> ')
@@ -201,10 +207,15 @@ def main(host=None):
try:
res = int(res)
except:
- res = raw_input('input number. ctrl-c to exit > ')
+ if res == "Q" or res == "q":
+ sys.exit(0)
+ elif res == "R" or res == "r":
+ res = refreshNum
+ else:
+ res = raw_input('Invalid selection > ')
continue
if (res <= 0) or (res > len(opts)):
- res = raw_input('input number within range > ')
+ res = raw_input('Invalid selection > ')
continue
break
opt = opts[res-1]
diff --git a/abs/core/LinHES-system/idle.py b/abs/core/LinHES-system/idle.py
index 4575e7d..05dedac 100755
--- a/abs/core/LinHES-system/idle.py
+++ b/abs/core/LinHES-system/idle.py
@@ -201,6 +201,22 @@ def userlogins_check(cmdargs):
else:
return True
+def sambafiles_check(cmdargs):
+ if (cmdargs.sambafiles):
+ msg(cmdargs," Checking if Samba files are in use...")
+ try:
+ smbstatus=subprocess.check_output(["smbstatus", "-L"])
+ except:
+ smbstatus="No locked files"
+ if "No locked files" in smbstatus:
+ msg(cmdargs," Samba files are NOT in use.")
+ return True
+ else:
+ msg(cmdargs," Samba files are in use.")
+ return False
+ else:
+ return True
+
def mythfe_check(cmdargs,cursor,mythDB):
#checks to see if a frontend is considered idle
# True means FE is idle
@@ -259,6 +275,7 @@ def usage():
determine if it is idle:
- (option -g) users are logged in return busy
ignores mythtv (:0) for busy
+ - (option -f) Samba files are in use return busy
- (option -l) mythshutdown is locked return busy
- (option -d) in a daily wake period or
about to start a daily wake period return busy
@@ -282,7 +299,8 @@ def usage():
def main(args=[False]):
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--daily', action='store_true', help='Include daily wake & about to start wake in system busy. (default: daily wake & about to start wake is system idle)')
- parser.add_argument('-g', '--logins', action='store_true', help='Include user logins in system busy. ignores mythtv (:0) in system busy.')
+ parser.add_argument('-g', '--logins', action='store_true', help='Include user logins in system busy. Ignores mythtv (:0) in system busy.')
+ parser.add_argument('-f', '--sambafiles', action='store_true', help='Include Samba files in use in system busy.')
parser.add_argument('-l', '--lock', action='store_true', help='Include mythshutdown lock in system busy. (default: mythshutdown lock is system idle)')
parser.add_argument('-r', '--runningfe', action='store_true', help='Include running mythfrontends in system busy. (default: running mythfrontends are system idle)')
parser.add_argument('-s', '--silent', action='store_true', help='Run without printing output. Recommended for use in cron jobs or scripts.')
@@ -303,6 +321,11 @@ def main(args=[False]):
else:
idle = False
+ if (idle and sambafiles_check(cmdargs)):
+ idle = True
+ else:
+ idle = False
+
try:
from MythTV import MythDB
mythDB = MythDB()
diff --git a/abs/core/LinHES-system/lh_system_backup_job b/abs/core/LinHES-system/lh_system_backup_job
index ca6800a..00ab5f6 100644
--- a/abs/core/LinHES-system/lh_system_backup_job
+++ b/abs/core/LinHES-system/lh_system_backup_job
@@ -81,6 +81,24 @@ function backup(){
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 ]
+ then
+ mkdir $BACKUPDIR/$DATE/plex
+ backup_status_check $?
+ fi
+ if [ -e /data/storage/disk0/media/plex/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
+ backup_status_check $?
+ fi
+ if [ -e /data/storage/disk0/media/plex/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
+ backup_status_check $?
+ fi
+
+ #create default backup_exclude.txt
if [ ! -f $MYTHHOME/backup_config/backup_exclude.txt ]
then
mkdir -p $MYTHHOME/backup_config/
@@ -88,7 +106,7 @@ function backup(){
chmod 777 $MYTHHOME/backup_config/backup_exclude.txt
fi
- for i in ".mythtv/themecache" ".mythtv/remotecache" ".mythtv/Cache-myth*" ".cache" "tmp" ".vnc/*log" ".vnc/*pid"
+ for i in ".mythtv/cache" ".mythtv/themecache" ".mythtv/remotecache" ".mythtv/Cache-myth*" ".cache" "tmp" ".vnc/*log" ".vnc/*pid" ".plexht/userdata/Thumbnails" ".plexht/userdata/ThemeMusicCache" ".kodi/userdata/Thumbnails"
do
grep -qF "$i" $MYTHHOME/backup_config/backup_exclude.txt
rc=$?
@@ -192,11 +210,28 @@ function remote_backup(){
fi
fi
else #do local copy to SECBACKUPLINK
- echo " Remote backup is not enabled, copying backup to $SECBACKUPLINK if it exists"
+ echo " Remote backup is not enabled, copying backup to another drive on this system."
SECBACKUPDISK=`readlink $SECBACKUPLINK`
- SECBACKUP=$SECBACKUPDISK/backup
+
+ if [ -z $SECBACKUPDISK ]
+ then
+ for dir in /data/storage/disk*
+ do
+ if [ $dir == /data/storage/disk0 ]
+ then
+ continue
+ fi
+ TESTDIR=`readlink $dir`
+ if [ -n $TESTDIR ]
+ then
+ SECBACKUPDISK=$TESTDIR
+ break
+ fi
+ done
+ fi
if [ -n "$SECBACKUPDISK" ]; then
+ SECBACKUP=$SECBACKUPDISK/backup
if [ `mountpoint -q -d $SECBACKUPDISK` ]; then
if [ ! -d "$SECBACKUP" ]; then
mkdir -p -m 775 $SECBACKUP
@@ -209,7 +244,7 @@ function remote_backup(){
echo " $SECBACKUPDISK isn't mounted."
fi
else
- echo " Link $SECBACKUPLINK doesn't exist."
+ echo " Could not find another drive on this system."
fi
fi
}
diff --git a/abs/core/LinHES-system/linhes_update.sh b/abs/core/LinHES-system/linhes_update.sh
index d563504..3ac2a56 100644
--- a/abs/core/LinHES-system/linhes_update.sh
+++ b/abs/core/LinHES-system/linhes_update.sh
@@ -9,17 +9,6 @@ usage () {
exit $1
}
-restart_mfe () {
- #check if started from mythfrontend-start and if so just kill mfe
- #otherwise reload mfe
- if [[ `pgrep -fx "/bin/bash /usr/LH/bin/mythfrontend-start"` ]]
- then
- killall mythfrontend
- else
- pkill -USR1 mythfrontend
- fi
-}
-
dsply () {
if grep -q "Updates Available" /usr/share/mythtv/themes/defaultmenu/linhes.xml
then
@@ -28,10 +17,10 @@ dsply () {
msg_client.py --kill
msg_client.py --msg "Updates available!\nGo to the Service Menu to install the updates.|middle"
else
- restart_mfe
+ killall mythfrontend
fi
echo " Updates available!"
- exit
+ exit
else
[ "$1" = false ] && { msg_client.py --msg "Checking for updates...|middle" --timeout 600 --tag "checkUpdates"; }
echo " Checking for updates..."
@@ -39,11 +28,11 @@ dsply () {
}
chck () {
- sudo pacman -Sy
+ sudo pacman -Sy
[ -f /tmp/to_be_upgraded ] && sudo rm /tmp/to_be_upgraded
- sudo pacman -Qu > /tmp/to_be_upgraded
- if [[ ! -s /tmp/to_be_upgraded ]]
- then
+ sudo pacman -Qu > /tmp/to_be_upgraded
+ if [[ ! -s /tmp/to_be_upgraded ]]
+ then
#hide LinHES update message on main menu
echo " Hiding update message in LinHES theme."
sudo sed -i '/LinHES UPDATE MESSAGE/c\ <!--LinHES UPDATE MESSAGE' /usr/share/mythtv/themes/LinHES/menu-ui.xml
@@ -51,33 +40,33 @@ chck () {
if [ "$1" = false ]; then
msg_client.py --clear --tag "checkUpdates"
msg_client.py --kill
- msg_client.py --msg "No updates available.\nReturning to Main Menu.|middle"
+ msg_client.py --msg "No updates available.\nReturning to Main Menu.|middle"
else
- restart_mfe
+ killall mythfrontend
fi
echo " No updates available."
- else
+ else
echo " Update menu to show Updates Available."
- mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp/linhes.xml.tmp
- sed -e '/\#Check/,/\#Check/d' < /tmp/linhes.xml.tmp > /usr/share/mythtv/themes/defaultmenu/linhes.xml
- mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp
- grep -v -e /mythmenu /tmp/linhes.xml > /tmp/linhes.xml.tmp
- echo "<!--#UpdatesAvailable-->" >> /tmp/linhes.xml.tmp
- echo " <button>" >> /tmp/linhes.xml.tmp
- echo " <type>UPGRADE</type>" >> /tmp/linhes.xml.tmp
- echo " <text>Updates Available</text>" >> /tmp/linhes.xml.tmp
- echo " <description>Updates for the LinHES system</description>" >> /tmp/linhes.xml.tmp
- echo " <action>MENU update2.xml</action>" >> /tmp/linhes.xml.tmp
- echo " </button>" >> /tmp/linhes.xml.tmp
- echo "<!--#UpdatesAvailable-->" >> /tmp/linhes.xml.tmp
- echo "</mythmenu>" >> /tmp/linhes.xml.tmp
- mv /tmp/linhes.xml.tmp /usr/share/mythtv/themes/defaultmenu/linhes.xml
+ mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp/linhes.xml.tmp
+ sed -e '/\#Check/,/\#Check/d' < /tmp/linhes.xml.tmp > /usr/share/mythtv/themes/defaultmenu/linhes.xml
+ mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp
+ grep -va '/mythmenu' /tmp/linhes.xml > /tmp/linhes.xml.tmp
+ echo "<!--#UpdatesAvailable-->" >> /tmp/linhes.xml.tmp
+ echo " <button>" >> /tmp/linhes.xml.tmp
+ echo " <type>UPGRADE</type>" >> /tmp/linhes.xml.tmp
+ echo " <text>Updates Available</text>" >> /tmp/linhes.xml.tmp
+ echo " <description>Updates for the LinHES system</description>" >> /tmp/linhes.xml.tmp
+ echo " <action>MENU update2.xml</action>" >> /tmp/linhes.xml.tmp
+ echo " </button>" >> /tmp/linhes.xml.tmp
+ echo "<!--#UpdatesAvailable-->" >> /tmp/linhes.xml.tmp
+ echo "</mythmenu>" >> /tmp/linhes.xml.tmp
+ mv /tmp/linhes.xml.tmp /usr/share/mythtv/themes/defaultmenu/linhes.xml
- echo "<mythmenu name=\"LH_UPDATE\">" > /tmp/update3.xml.tmp
+ echo "<mythmenu name=\"LH_UPDATE\">" > /tmp/update3.xml.tmp
#check for kernel update and warn reboot is required
if grep linux /tmp/to_be_upgraded || grep nvidia /tmp/to_be_upgraded
- then
+ then
echo "" >> /tmp/update3.xml.tmp
echo " <button>" >> /tmp/update3.xml.tmp
echo " <type>UPGRADE</type>" >> /tmp/update3.xml.tmp
@@ -85,10 +74,10 @@ chck () {
echo " <description>Some packages require a reboot</description>" >> /tmp/update3.xml.tmp
echo " <action>NONE</action>" >> /tmp/update3.xml.tmp
echo " </button>" >> /tmp/update3.xml.tmp
- fi
+ fi
#create menu items for each pkg to be upgraded
- while read line; do
+ while read line; do
echo "" >> /tmp/update3.xml.tmp
echo " <button>" >> /tmp/update3.xml.tmp
echo " <type>UPGRADE</type>" >> /tmp/update3.xml.tmp
@@ -104,9 +93,9 @@ chck () {
echo " Showing update message in LinHES theme."
sudo sed -i '/LinHES UPDATE MESSAGE/c\ <!--LinHES UPDATE MESSAGE-->' /usr/share/mythtv/themes/LinHES/menu-ui.xml
- dsply $1
- fi
- }
+ dsply $1
+ fi
+ }
# Command line argument handling
SILENT=false
@@ -123,4 +112,3 @@ shift $(($OPTIND - 1))
dsply $SILENT
chck $SILENT
-#pkill -USR1 mythfrontend
diff --git a/abs/core/LinHES-system/linhes_update2.sh b/abs/core/LinHES-system/linhes_update2.sh
index 5c05c99..6c249d3 100644
--- a/abs/core/LinHES-system/linhes_update2.sh
+++ b/abs/core/LinHES-system/linhes_update2.sh
@@ -4,14 +4,14 @@
if [[ "$1" = "install" ]]
then
msg_client.py --msg "Updating...|middle" --timeout 600 --tag "Updating"
- sudo pacman -Su --force --noconfirm
+ sudo pacman -Su --force --noconfirm
msg_client.py --clear --tag "Updating"
msg_client.py --kill
msg_client.py --msg "Updates complete.\nReturning to Main Menu.|middle"
- if grep linux /tmp/to_be_upgraded || grep nvidia /tmp/to_be_upgraded
- then
+ if grep linux /tmp/to_be_upgraded || grep nvidia /tmp/to_be_upgraded
+ then
msg_client.py --msg "Updates require a reboot.|middle"
- fi
+ fi
else
msg_client.py --msg "Updates canceled.|middle"
fi
@@ -20,32 +20,25 @@ sudo rm -fr /tmp/to_be_upgraded
if grep -q Updates\ Available /usr/share/mythtv/themes/defaultmenu/linhes.xml
then
- mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp/linhes.xml.tmp
- sed -e '/\#UpdatesAv/,/\#UpdatesAv/d' < /tmp/linhes.xml.tmp > /usr/share/mythtv/themes/defaultmenu/linhes.xml
- mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp
- grep -v -e /mythmenu /tmp/linhes.xml > /tmp/linhes.xml.tmp
- echo "<!--#Check for updates-->" >> /tmp/linhes.xml.tmp
- echo " <button>" >> /tmp/linhes.xml.tmp
- echo " <type>UPGRADE</type>" >> /tmp/linhes.xml.tmp
- echo " <text>Update LinHES</text>" >> /tmp/linhes.xml.tmp
- echo " <description>Update the LinHES system</description>" >> /tmp/linhes.xml.tmp
- echo " <action>MENU update.xml</action>" >> /tmp/linhes.xml.tmp
- echo " </button>" >> /tmp/linhes.xml.tmp
- echo "<!--#Check for updates-->" >> /tmp/linhes.xml.tmp
- echo "" >> /tmp/linhes.xml.tmp
- echo "</mythmenu>" >> /tmp/linhes.xml.tmp
- mv /tmp/linhes.xml.tmp /usr/share/mythtv/themes/defaultmenu/linhes.xml
+ mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp/linhes.xml.tmp
+ sed -e '/\#UpdatesAv/,/\#UpdatesAv/d' < /tmp/linhes.xml.tmp > /usr/share/mythtv/themes/defaultmenu/linhes.xml
+ mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp
+ grep -va '/mythmenu' /tmp/linhes.xml > /tmp/linhes.xml.tmp
+ echo "<!--#Check for updates-->" >> /tmp/linhes.xml.tmp
+ echo " <button>" >> /tmp/linhes.xml.tmp
+ echo " <type>UPGRADE</type>" >> /tmp/linhes.xml.tmp
+ echo " <text>Update LinHES</text>" >> /tmp/linhes.xml.tmp
+ echo " <description>Update the LinHES system</description>" >> /tmp/linhes.xml.tmp
+ echo " <action>MENU update.xml</action>" >> /tmp/linhes.xml.tmp
+ echo " </button>" >> /tmp/linhes.xml.tmp
+ echo "<!--#Check for updates-->" >> /tmp/linhes.xml.tmp
+ echo "" >> /tmp/linhes.xml.tmp
+ echo "</mythmenu>" >> /tmp/linhes.xml.tmp
+ mv /tmp/linhes.xml.tmp /usr/share/mythtv/themes/defaultmenu/linhes.xml
fi
#hide LinHES update message on main menu
sudo sed -i '/LinHES UPDATE MESSAGE/c\ <!--LinHES UPDATE MESSAGE' /usr/share/mythtv/themes/LinHES/menu-ui.xml
-#reload theme
-#check if started from mythfrontend-start and if so just kill mfe
-#otherwise reload mfe
-if [[ `pgrep -fx "/bin/bash /usr/LH/bin/mythfrontend-start"` ]]
-then
- killall mythfrontend
-else
- pkill -USR1 mythfrontend
-fi
+#reload mythfrontend
+killall mythfrontend
diff --git a/abs/core/LinHES-system/myth_mtc.cron b/abs/core/LinHES-system/myth_mtc.cron
index d3dc50a..6d70058 100755
--- a/abs/core/LinHES-system/myth_mtc.cron
+++ b/abs/core/LinHES-system/myth_mtc.cron
@@ -1,5 +1,6 @@
#!/bin/bash
MYTH_RUN_STATUS=1
+. /etc/systemconfig
. /etc/profile
date=`date +%Y-%m-%d`
@@ -16,9 +17,10 @@ fi
#check logfile for Finished and if not run myth_mtc.py
if ! grep -q "Finished Maintenance" $logFile
then
- if ! grep -q "Finished Optimize" $logFile
+
+ if ! grep -q "Finished checking size of MythTV home" $logFile
then
- MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --optimize | $log
+ MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --check_home | $log
if [ $? = 0 ]
then
echo "" | $log
@@ -28,6 +30,24 @@ then
fi
fi
+ if ! grep -q "Finished Optimize" $logFile
+ then
+ if [ $SystemType = Frontend_only ]
+ then
+ echo "Will not run Optimize on Frontend Only systems." | $log
+ echo "Finished Optimize" | $log
+ else
+ MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --optimize | $log
+ if [ $? = 0 ]
+ then
+ echo "" | $log
+ else
+ echo "Time Exceeded" | $log
+ exit
+ fi
+ fi
+ fi
+
if ! grep -q "Finished Backup" $logFile && grep -q "Finished Optimize" $logFile
then
MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --backup | $log
@@ -52,7 +72,7 @@ then
fi
fi
- if grep -q "Finished Optimize" $logFile && grep -q "Finished Backup" $logFile && grep -q "Finished Update" $logFile
+ if grep -q "Finished checking size of MythTV home" $logFile && grep -q "Finished Optimize" $logFile && grep -q "Finished Backup" $logFile && grep -q "Finished Update" $logFile
then
echo "Finished Maintenance" | $log
fi
diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py
index 8a08c05..e62592f 100755
--- a/abs/core/LinHES-system/myth_mtc.py
+++ b/abs/core/LinHES-system/myth_mtc.py
@@ -17,10 +17,35 @@ except:
def get_timestamp():
now = datetime.datetime.now()
-#date = "%s-%s-%s" %(now.year, now.month, now.day)
- date = (now.strftime('%Y-%m-%d %H:%M'))
+ date = (now.strftime('%Y-%m-%d %H:%M'))
return date
+def getFreePercentForDir(dir):
+ stats = os.statvfs(dir)
+ total = (stats.f_blocks)
+ avail = (stats.f_bavail)
+ return (total - avail) / float(total)
+
+def check_home():
+ #get the mythtv home dir
+ sys.path.append('/usr/MythVantage/bin/')
+ config_file = "mv_config"
+ data_config = __import__(config_file, globals(), locals(), [])
+
+ freePcent = getFreePercentForDir(data_config.MYTHHOME)
+ print " Home directory percent used: " + str(freePcent * 100) + "%"
+ if float(freePcent) > .9:
+ print " Home directory is greater than 90% used. Clearing MythTV caches..."
+ cmd = "/usr/bin/rm -rf " + data_config.MYTHHOME + "/.mythtv/{*cache,Cache-*}"
+ subprocess.call(["sh", "-c", cmd])
+ print " Restarting mythfrontend..."
+ subprocess.call(["killall", "mythfrontend"])
+ freePcent = getFreePercentForDir(data_config.MYTHHOME)
+ print " Home directory percent used: " + str(freePcent * 100) + "%"
+ else:
+ print " Home directory is less than 90% used. Not clearing MythTV caches."
+ return 0
+
def optimize():
try:
cursor = mythtv.db.cursor()
@@ -59,8 +84,28 @@ def bail_if_another_is_running():
def run_stuff():
print "\n%s" %get_timestamp()
- if not subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py"]):
- if ("--optimize" in sys.argv) or (len(sys.argv) == 1):
+
+ if (len(sys.argv) == 1) or ("--noidlecheck" in sys.argv) and (len(sys.argv) == 2):
+ runall = True
+ else:
+ runall = False
+
+ if ("--noidlecheck" in sys.argv):
+ print "No system idle check will be done."
+ idle = 0
+ else:
+ idle = subprocess.call(["/usr/bin/python2", "/usr/LH/bin/idle.py"])
+
+ if not idle:
+ if ("--check_home" in sys.argv) or runall:
+ print "\n#######################################"
+ print "\n%s Checking size of MythTV home" %(get_timestamp())
+ if not check_home():
+ print "\nFinished checking size of MythTV home"
+ else:
+ return True
+
+ if ("--optimize" in sys.argv) or runall:
print "\n#######################################"
print "\n%s Running Optimize" %(get_timestamp())
if not optimize():
@@ -68,13 +113,13 @@ def run_stuff():
else:
return True
- if ("--backup" in sys.argv) or (len(sys.argv) == 1):
+ if ("--backup" in sys.argv) or runall:
print "\n#######################################"
print "\n%s Running Backup" %(get_timestamp())
if not os.system('/usr/LH/bin/lh_system_backup_job'):
print "\nFinished Backup"
- if ("--update" in sys.argv) or (len(sys.argv) == 1):
+ if ("--update" in sys.argv) or runall:
print "\n#######################################"
print "\n%s Running System Update" %(get_timestamp())
if not os.system('/usr/LH/bin/lh_system_host_update'):
@@ -96,7 +141,7 @@ while ctin:
if ctin:
print "\n%s Waiting 10 minutes before trying again." %(get_timestamp())
time.sleep(600)
-
+
current_time=time.time()
if (current_time - starttime) > 3000 :
ctin = False
diff --git a/abs/core/LinHES-system/mythvidexport.py b/abs/core/LinHES-system/mythvidexport.py
index 9160f1d..ff2cb35 100755
--- a/abs/core/LinHES-system/mythvidexport.py
+++ b/abs/core/LinHES-system/mythvidexport.py
@@ -97,7 +97,7 @@ class VIDEO:
elif self.db.settings[host]['mythvideo.TVexportfmt']:
self.tfmt = self.db.settings[host]['mythvideo.TVexportfmt']
else:
- self.tfmt = 'Television/%TITLE%/Season %SEASON%/'+\
+ self.tfmt = '/Television/%TITLE%/Season %SEASON%/'+\
'%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%'
# Movie Format
@@ -106,7 +106,7 @@ class VIDEO:
elif self.db.settings[host]['mythvideo.MOVIEexportfmt']:
self.mfmt = self.db.settings[host]['mythvideo.MOVIEexportfmt']
else:
- self.mfmt = 'Movies/%TITLE%'
+ self.mfmt = '/Movies/%TITLE%'
# Generic Format
if self.opts.gformat:
@@ -114,7 +114,7 @@ class VIDEO:
elif self.db.settings[host]['mythvideo.GENERICexportfmt']:
self.gfmt = self.db.settings[host]['mythvideo.GENERICexportfmt']
else:
- self.gfmt = 'Videos/%TITLE%'
+ self.gfmt = '/Videos/%TITLE%'
def get_meta(self):
self.vid.hostname = self.db.gethostname()
@@ -230,7 +230,7 @@ class VIDEO:
self.log(MythLog.GENERAL|MythLog.FILE, MythLog.INFO, "Copying myth://%s@%s/%s"\
% (self.rec.storagegroup, self.rec.hostname, self.rec.basename)\
- +" to myth://Videos@%s/%s"\
+ +" to myth://Videos@%s%s"\
% (self.vid.host, self.vid.filename))
srcfp = self.rec.open('r')
dstfp = self.vid.open('w', nooverwrite=True)
@@ -293,9 +293,9 @@ class VIDEO:
def usage_format():
usagestr = """The default strings are:
-Television: Television/%TITLE%/Season %SEASON%/%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%
-Movie: Movies/%TITLE%
-Generic: Videos/%TITLE%
+Television: /Television/%TITLE%/Season %SEASON%/%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%
+Movie: /Movies/%TITLE%
+Generic: /Videos/%TITLE%
Available strings:
%TITLE%: series title
@@ -324,13 +324,13 @@ def print_format():
host = gethostname()
tfmt = db.settings[host]['mythvideo.TVexportfmt']
if not tfmt:
- tfmt = 'Television/%TITLE%/Season %SEASON%/%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%'
+ tfmt = '/Television/%TITLE%/Season %SEASON%/%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%'
mfmt = db.settings[host]['mythvideo.MOVIEexportfmt']
if not mfmt:
- mfmt = 'Movies/%TITLE%'
+ mfmt = '/Movies/%TITLE%'
gfmt = db.settings[host]['mythvideo.GENERICexportfmt']
if not gfmt:
- gfmt = 'Videos/%TITLE%'
+ gfmt = '/Videos/%TITLE%'
print "Current output formats:"
print " TV: "+tfmt
print " Movies: "+mfmt
diff --git a/abs/core/LinHES-system/stop_xss.sh b/abs/core/LinHES-system/stop_xss.sh
index b03169b..b73be85 100755
--- a/abs/core/LinHES-system/stop_xss.sh
+++ b/abs/core/LinHES-system/stop_xss.sh
@@ -3,7 +3,7 @@
while [ 1=1 ];
do
- if [ "$(pidof google-chrome)" -o "$(pidof huludesktop)" -o "$(pidof xbmc.bin)" ]
+ if [ "$(pidof google-chrome)" -o "$(pidof huludesktop)" -o "$(pidof kodi.bin)" -o "$(pidof plexhometheater)" ]
then
xscreensaver-command -deactivate
fi
diff --git a/abs/core/LinHES-system/system.install b/abs/core/LinHES-system/system.install
index 6975070..558a52a 100644
--- a/abs/core/LinHES-system/system.install
+++ b/abs/core/LinHES-system/system.install
@@ -22,8 +22,10 @@ post_install() {
# arg 1: the new package version
# arg 2: the old package version
pre_upgrade() {
+ msg_client.py --clear
msg_client.py --kill
sv stop msg_daemon
+ killall -9 msg_daemon.py
}
# arg 1: the new package version