diff options
Diffstat (limited to 'abs/core/LinHES-system')
22 files changed, 665 insertions, 549 deletions
diff --git a/abs/core/LinHES-system/LinHES-run b/abs/core/LinHES-system/LinHES-run deleted file mode 100755 index 0de0feb..0000000 --- a/abs/core/LinHES-system/LinHES-run +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/sh -exit 0 -################################################################ -# WARNING THIS FILE IS DEPRECATED -# any changes to this file must also be made to LinHES-session -# -# -############################################################### -function msg(){ - echo -e "$1" | osd_cat --pos=middle --align=center --offset=200 --delay=5 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font & -} - -. /etc/profile -. /etc/systemconfig -. /etc/unclutter.cfg || { - idle=1 - jitter=200 -} -. /etc/osd_cat.cfg || { - color=yellow - outline=2 - outlinecolour=black - shadow=0 - shadowcolour=black - font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*" -} -#keylaunch & -#/usr/bin/tilda & - -lsmod |cut -f1 -d" " |grep -q nvidia -if [ $? = 0 ] -then - /usr/bin/nvidia-settings --load-config-only -fi - -#move mouse to corner -xdotool mousemove 0 0 -/usr/X11R6/bin/unclutter -root -idle $idle -jitter $jitter -noevents & -if [ x"$Screensavertype" = "xgscreensaver" ] -then - gnome-screensaver & -elif [ x"$Screensavertype" = "xxscreensaver" ] -then - xscreensaver -no-splash & -fi - -/usr/bin/xvattr -a XV_COLORKEY -v 0 -mtd & -#/usr/bin/nvidia-settings -l -#/usr/bin/nvidia-settings -a InitialPixmapPlacement=2 - -if [ x$ShowTips = "x1" ] -then - msg "Alt+h for help" & -fi - -# Run any scripting that applies to special hardware. These brand-specific commands that run -# after Tweaker will, of course, override generic or hardware-specific settings. -SpecialHardwareCommands() { - special_hardware_file=/myth/.special_hardware_type - special_hardware=`cat $special_hardware_file` - - case $special_hardware in - dragon*) - sudo -E twk_audio.pl --implement digital - sudo -E twk_dragon.pl --implement all - ;; - ausdragon*) - ;; - *) - # there are no brand-specific commands for configuring whatever - # special hardware the user chose - ;; - esac -} - -#update apple trailers -if [[ x$RunFrontend = x1 && -f ~/.configure ]] -then - /usr/bin/php -q /usr/bin/myth_trailers_grabber > /home/mythtv/appletrailer.xml && /usr/bin/fix_aple_url.sh 2>/dev/null & -fi - - -if [ ! $SystemType = "Frontend_only" ] -then - if [ -f ~/.configure ] - then - # Run Tweaker, which applies generic and hardware-specific settings - if [ ! -f ~/.no_meth ] - then - #remove tweaker cause it's broken and duplicates entries - #sudo -E tweaker.pl - #/bin/rm /tmp/fps # ??? clean up a temp file that will eventually be obsolete anyway - # Run any brand-specific commands, if necessary. - SpecialHardwareCommands - else - rm -f ~/.no_meth - fi - sudo pacman -R --noconfirm myth2ipod myt2xvid3 - sudo pacman -S --noconfirm myth2ipod myt2xvid3 -# sudo ln -s /usr/share/mythtv/mythexport /data/srv/httpd/htdocs - sudo sv stop mythbackend - /usr/LH/bin/dtheme.sh - xterm -fn *18* -e sudo taskset -c 0 /usr/bin/mythtv-setup - sudo sv start mythbackend - sudo sv stop mythexport - sudo pacman -R --noconfirm mythexport - sudo pacman -S --noconfirm mythexport - sudo chown -R mythtv.mythtv /home/mythtv - nice -n 19 mythfilldatabase --quiet & - msg "Guide data is being loaded. \n Until this completes\n some shows will appear as unknown \n in the program guide." - rm ~/.configure - fi -fi - - -if [ x"$UseMythWelcome" = "x1" ] -then - STARTCMD="/usr/bin/mythwelcome" -else - if pacman -Q mythtv | grep -q 0.24 - then - STARTCMD="/usr/bin/mythfrontend -d -l /var/log/mythtv/mythfrontend.log" - else - STARTCMD="/usr/bin/mythfrontend -d --syslog local6" - fi -fi - -echo "=====================================================================" -echo "Starting $STARTCMD" -firstboot.sh & - -if [ -f /tmp/nomfe ] -then - exit 0 -else - if [ -f /tmp/debug ] - then - echo "using gbd/debug" - gdb /usr/bin/mythfrontend -x $MV_ROOT/mfegdbcommands.txt - mv gdb.txt gdb.txt.mythfrontend - sleep 10 - else - killall -9 irexec - /usr/bin/irexec -d - $STARTCMD 2>&1 - fi -fi - diff --git a/abs/core/LinHES-system/LinHES-session b/abs/core/LinHES-system/LinHES-session index a8c8c09..c6d0b09 100755 --- a/abs/core/LinHES-system/LinHES-session +++ b/abs/core/LinHES-system/LinHES-session @@ -75,7 +75,7 @@ function start_x11vnc(){ . /etc/x11vnc.cfg x11vnc $x11vnc_options else - x11vnc -rfbport 5902 --passwd $xvncpassword + x11vnc -forever -rfbport 5902 --passwd $xvncpassword fi fi } @@ -286,12 +286,7 @@ function start_myth() { then STARTCMD="/usr/bin/mythwelcome" else - if pacman -Q mythtv | grep -q 0.24 - then - STARTCMD="/usr/bin/mythfrontend -d -l /var/log/mythtv/mythfrontend.log" - else - STARTCMD="/usr/bin/mythfrontend $MYTH_ARGS" - fi + STARTCMD="/usr/bin/mythfrontend $MYTH_ARGS" fi echo "=====================================================================" @@ -304,10 +299,16 @@ function start_myth() { while [ $rc -ne 0 ] do msg "Waiting for connection to MythBackend" + sleep 6 /usr/LH/bin/be_check.py rc=$? - sleep 6 + if [ $rc -eq 0 ] + then + msg "Successful Connection to MythBackend" + fi done + sleep 3 #give time for MBE to be fully operational + fi #continue on with starting mythtv diff --git a/abs/core/LinHES-system/LinHES-start b/abs/core/LinHES-system/LinHES-start index 3157a2e..88ecffb 100755 --- a/abs/core/LinHES-system/LinHES-start +++ b/abs/core/LinHES-system/LinHES-start @@ -12,6 +12,7 @@ # # $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $ . /etc/profile +MYTH_RUN_STATUS="1" unset DBUS_SESSION_BUS_ADDRESS unset SESSION_MANAGER diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 71c7ae1..b0b8ba7 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system -pkgver=8.0 -pkgrel=29 +pkgver=8.1 +pkgrel=10 arch=('i686' 'x86_64') install=system.install pkgdesc="Everything that makes LinHES an automated system" @@ -11,14 +11,14 @@ depends=('linhes-sounds' 'xdotool' 'tilda' 'keylaunch' 'ethtool' 'gnu-netcat' 'normalize' 'ttf-overlock' 'handbrake-cli' 'mkvtoolnix' 'mplayer') backup=('etc/modprobe.d/alsa-base.conf') -binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh - LinHES-run load-modules-mythvantage.sh unclutter-toggle.sh tvterm.sh +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 - switch_web.sh create_media_dirs.sh msg_client.py msg_daemon.py + create_media_dirs.sh msg_client.py msg_daemon.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 misc_upcoming_recordings.pl misc_which_recorder.pl @@ -28,9 +28,9 @@ binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh mythwelcome-config.py mythwelcome-set-alarm.sh mythwelcome-test-wakeup.sh" source=(LinHES-session LinHES-profile.sh $binfiles - alsa-base diskspace.cron cacheclean.cron xfs_defrag.cron + alsa-base cacheclean.cron myth_mtc.cron xfs_defrag.cron readme_is_xml readme_light add_storage.readme - system-sudo.rules ) + system-sudo.rules msg.cfg) package() { cd $srcdir @@ -61,8 +61,8 @@ package() { #cron files #install -m755 -D $srcdir/smolt.cron $pkgdir/etc/cron.weekly/smolt.cron install -m755 -D $srcdir/cacheclean.cron $pkgdir/etc/cron.weekly/cacheclean - install -m755 -D $srcdir/diskspace.cron $pkgdir/etc/cron.tenminutes/diskspace install -m755 -D $srcdir/xfs_defrag.cron $pkgdir/etc/cron.weekly/xfs_defrag + install -m755 -D $srcdir/myth_mtc.cron $pkgdir/etc/cron.hourly/myth_mtc #sudo rules mkdir -p $pkgdir/etc/sudoers.d/ @@ -70,36 +70,36 @@ package() { chown -R root:root $pkgdir/etc/sudoers.d install -o root -g root -m 0750 $srcdir/system-sudo.rules $pkgdir/etc/sudoers.d/system_sudo + #config file of msg_daemon + install -m755 -D $srcdir/msg.cfg $pkgdir/usr/MythVantage/etc/msg.cfg + } -md5sums=('5ee78704cab0e88ec58d1aab821fc1aa' +md5sums=('7f5624a2d965a4cd3ed6a37ebee13fd9' 'de32a1c50101265dd7f6ca5037f7a26a' - 'a875ee97f86e46f34a741c2bc455f894' + '301884fb60521627fffd1160b2cf5181' '76b2637cac0452b3acdbeeb4e8a5474b' - '781c977f8872543f033dad2caaf0458e' - '6f5b757524d905b5d2420519a88edc93' - '4b4585ccba30595cf958d202997c57f7' + '22807bd1e37d2a07bc0bd3f2a9fd2bb4' 'dc3eef2a624754e16805d72bbe488b67' '617af86b901538817ebdcaf646248dc5' '542e670e78d117657f93141e9689f54d' - '41951459ea9d2b0567be521b67e6285a' + '8da6a7f1703a002f84e66629e847d8a6' 'bb72ab230c7a71706285bd0f31a4fb1f' - '692563448cca1d49f45e7d1c8abcaa0c' + 'f8683caddf74dca1ea5cc3db4d748764' '962a3e9eaba2d1466251b7ab0956705d' '1758aed160de64abfafb28a3a8f3390e' '33fbebbd546672cedd3c5e7350ab414e' 'c773d8caacba8fbd4968e8afe5137bc6' '3edef50a49a47694bf8add39cc160add' - '5e17e0786afd891550a660f646076308' + 'b376c30f95892b8682fad84f81685f75' 'bc69a520add58ede9b060c73e67ace13' - '26fdd26e945f0c187f9fdcf98a7a5bef' + '2e5e1b3187f75154366bffe806ff8ae9' '47e093e8cfe4b5b96602358e1f540832' - 'a8e486f5d23913242b6edb862bf44c0e' + '4d6a6e88b519caf917ebe6c85c32c45b' '2c005d95312018bef80092136f80f254' '6519d209e151cdc39ae7e1091d189c3e' - '8f474e019d5fcb775497aca355d61b0b' - '4a3cd8f9b33b2b86fdba47a8f1fa2859' - '16f079dab35dde6efd55bf6cf4e2fb2f' + 'ca63946920ba33de1f15abda83e74e40' + '7f7c49d859abdaa0b5fca399241d4998' '3e60b17892e5b8214d47dcfddf5215a4' '57ec994cc3964a10c00580e89ebcae35' 'ea315f41dcd6c978e546c95fc05546cf' @@ -108,9 +108,9 @@ md5sums=('5ee78704cab0e88ec58d1aab821fc1aa' 'b7febd04f64fe21e8cfbb888219b0b31' '06a628469051237943b7c874f2e29b8a' '8fe86aa9109a285aedce3c8658952bbb' - '45f46d1f9193c8dde18e56369ec29a1e' + '3300ea8b02e4fb8bd3409df348de6e16' '145b1da6ce501b3ce38ea415a576bf2d' - '116b0f62ed4e8dd6e437930deeb6e49e' + 'b51c93ad9f3717a616d92899f6bfde76' '17f678d37187be0f12d67f64e40429c6' 'bacc813b48bafcc6fe906e5969930501' '8e02efe1ad0df9a179075147eebb05b9' @@ -119,8 +119,8 @@ md5sums=('5ee78704cab0e88ec58d1aab821fc1aa' '34fc1f58ad1eabf4eff4979d420760c0' 'c3ada01d3a739abe3f920b02d4ea3f6e' 'a94fe6d980f4b810f2e2ae5352084b39' - 'e1011e0df090372cccc03ecf9d6805c7' - '5727da2f13541b0cde2aea0ab94d4960' + 'f808e8614246913a7f633b51c7169c85' + '3fc3d584fadd47f82c5cfe8ac0f4322a' '503df99218373dfc75e7e7f5e449a44e' '4a1fda884dcd7d65fb2690fbdbd92a83' '2b7fe3b57592823a4c7e3ec132dcb7f4' @@ -128,10 +128,11 @@ md5sums=('5ee78704cab0e88ec58d1aab821fc1aa' '95c092f67036a361ef7a57436f44332e' '410795ef9039e4c6c0484e706ecfd567' 'eb879fee9603a05d5420d4ce8ed9e450' - '84492954db16740f949d795b74383189' '02c810c2f47b7c4495fdacaf54189473' + 'fae4162988de9525ba3f9341e17f9c52' '474d5c6883fcfffae4f199aceb3b1356' '36bdfa8d877cea20ca3870faf08e08d5' '59d0602bac7e06f11abba1894acc8bb0' 'da432d68962e109e09beb2b71c8c8571' - '366ccb097d1c221389709485c3b2d159') + '366ccb097d1c221389709485c3b2d159' + 'bdd37627c9effd745a051fd2d279975b') diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 1f166b1..61ce0ea 100644..100755 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -1,8 +1,9 @@ #!/usr/bin/python2 -#Program used to auto_add new storage to mythtv storage groups -#If it's a new disk it will erase the entire disk and reformat +#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. # -#Drives that are mount, in fstab, size < 5000 bytes, optical or have already been seen will not be presented as an option. +#Disks that are mounted, in fstab, size < 5000 bytes, optical or +#have already been seen will not be presented as an option. # @@ -23,29 +24,23 @@ storage_dir = "/etc/storage.d" pickle_file = "%s/storage.pkl" %storage_dir -SG_MAP_BE={ 'Default' :'media/tv', -'LiveTV' :'media/tv/live', -'DB Backups' :'backup/mythtv_backups/', -'Streaming' :'media/streaming'} - - -SG_MAP_FE={ - 'Videos' :'media/video', - 'Trailers' :'media/video_stuff/trailers', - 'Coverart' :'media/video_stuff/coverart', - 'Fanart' :'media/video_stuff/fanart', - 'Banners' :'media/video_stuff/banners', - 'Screenshots':'media/video_stuff/screenshots', - } - -FS_LIST_BE=[] -for key in SG_MAP_BE.keys(): - FS_LIST_BE.append(SG_MAP_BE[key]) - -FS_LIST_FE=[] -for key in SG_MAP_FE.keys(): - FS_LIST_FE.append(SG_MAP_FE[key]) - +SG_MAP={ + 'Default' :'media/tv', + 'LiveTV' :'media/tv/live', + 'DB Backups' :'backup/mythtv_backups/', + 'Music' :'media/music', + 'Streaming' :'media/streaming', + 'Videos' :'media/video', + 'Banners' :'media/artwork/banners', + 'Coverart' :'media/artwork/coverart', + 'Fanart' :'media/artwork/fanart', + 'Screenshots':'media/artwork/screenshots', + 'Trailers' :'media/artwork/trailers', + } + +FS_LIST=[] +for key in SG_MAP.keys(): + FS_LIST.append(SG_MAP[key]) class disk_device: def __init__(self,device,storage_dir): @@ -152,7 +147,7 @@ class disk_device: def partition_disk(self): - print " Creating new partiton table" + print " Creating new partition table" cmd = "parted -s -a optimal %s mklabel gpt" %self.block_path runcmd(cmd) cmd = "parted -s -a optimal %s mkpart primary \" 1 -1\"" %self.block_path @@ -189,20 +184,23 @@ class disk_device: break return fstype - - def format_disk(self): + def lookup_format(self): fstab = self.read_fstab() - #lookup format current_media_mount = self.find_options_type(fstab)[1] new_fstype = self.find_fstype(current_media_mount) #setting self.new_fstype so that it can be referenced when setting fstab self.new_fstype = new_fstype + return + + def format_disk(self): + #lookup format + #self.lookup_format() #do format - if new_fstype == "xfs": - cmd = "mkfs -t %s -f %s " %(new_fstype,self.block_partition) + if self.new_fstype == "xfs": + cmd = "mkfs -t %s -f %s " %(self.new_fstype,self.block_partition) else: - cmd = "mkfs -t %s %s " %(new_fstype,self.block_partition) - print " Formating %s with %s" %(self.block_partition,new_fstype) + cmd = "mkfs -t %s %s " %(self.new_fstype,self.block_partition) + print " Formatting %s with %s" %(self.block_partition,self.new_fstype) runcmd(cmd) return @@ -285,13 +283,20 @@ class disk_device: except: os.makedirs(self.new_mount_point) if no_mount == False: - cmd = "mount %s" %self.new_mount_point - runcmd(cmd) + if os.path.ismount(self.new_mount_point): + print " Disk already mounted, will not mount:\n %s" %self.new_mount_point + pass + else: + print " Mounting %s" %self.new_mount_point + cmd = "mount %s" %self.new_mount_point + runcmd(cmd) return def mkdirs(self,FS_LIST): - print " Creating Directory stucture" + print " Creating directory structure:" + print " %s" %self.new_mount_point for y in FS_LIST: + print " %s" %y new_dir="%s/%s" %(self.new_mount_point,y) try: os.stat(new_dir) @@ -319,7 +324,7 @@ class disk_device: with DB as c: try: c.execute("""insert into storagegroup (groupname,hostname,dirname) values (%s,%s,%s)""",(gn,hn,dn)) - print " Adding location: %s to storagegroup %s" %(dn,gn) + print " Adding location: %s to storagegroup %s" %(dn,gn) except: print " *Error inserting %s into storage groups" %dn @@ -339,10 +344,11 @@ class disk_device: return def write_config(self): - print " Writing out storage.d conf file" + print " Writing /etc/storage.d conf file" self.config.add_section('storage') self.config.set('storage','uuid',self.uuid) self.config.set('storage','mountpoint',self.new_mount_point) + 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','disk_num',self.disk_num) @@ -352,24 +358,25 @@ class disk_device: self.serial_number.replace(' ','')) configfile="/etc/storage.d/%s" %filename - print " %s" %configfile + print " %s" %configfile with open(configfile, 'wb') as configfile: self.config.write(configfile) return def symlink_disk(self): - print " Creating symlink for disk number" + 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) - print cmd runcmd(cmd) def symlink(self): pass - print " Creating symlink" - cmd = "ln -s %s/media /myth " %(self.new_mount_point) - runcmd(cmd) - + print " Creating symlink for /myth" + if not os.path.exists("/myth"): + cmd = "ln -s %s/media /myth " %(self.new_mount_point) + runcmd(cmd) + else: + print " Skipping symlink, /myth already exists" #end of class @@ -442,17 +449,16 @@ def prompt_to_add(current_drive,destruction = True): loop = True if destruction : prompt = ''' - Adding the drive will remove all contents on the drive. + ** Adding this disk will remove all contents on the disk. ** + This disk will be partitioned and formatted. - Do you wish enable this drive for MythTV storage(Y/N)?: - ''' + Enable this disk for storage (Y/N)?:''' else: prompt = ''' - ** Preserving existing data ** - will not format or partition + ** Preserving existing contents on the disk. ** + This disk will NOT be partitioned or formatted. - Do you wish enable this drive for MythTV storage(Y/N)?: - ''' + Enable this disk for storage (Y/N)?:''' while loop: str1 = raw_input(prompt) @@ -466,11 +472,17 @@ def prompt_to_add(current_drive,destruction = True): rc = False return rc -def prompt_to_continue(): +def prompt_to_continue(process_list): loop = True #while loop: - print "\n\n\n\n" - str1 = raw_input("\n Ready to add additional storage!\n Press Y to continue, anything else to abort:") + print "\n\n\n Ready to add additional storage!\n" + 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. **" + 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:") #if str1 in ['Y','N','y','n']: # loop = False @@ -480,47 +492,27 @@ def prompt_to_continue(): rc = True else: rc = False + print "\nCancelled: No disk(s) added to your system." print "-----" return rc -def prompt_sg(dir_be_sg,dir_fe_sg): - #check for backend storage groups - if dir_be_sg != True: +def prompt_sg(dir_sg): + #check for storage groups + print "*" * 60 + if dir_sg != True: loop = True - print "*" * 40 prompt_string=''' - Backend Storage Groups are used for things like - TV Recordings and database backups. + MythTV Storage Groups are used for artwork, database backups, + music, streaming, TV recordings, and videos. The content on these storage groups will only be available while the system is online. - Do you wish enable this system for Backend Storage Groups(Y/N)?:''' - - while loop: - str1 = raw_input(prompt_string) - if str1 in ['Y','N','y','n']: - loop = False - break - print "\n" - - if str1 == 'Y' or str1 == 'y': - dir_be_sg = True - print " ** Will add Backend Storage Groups!" - else: - print " ** Will NOT add Backend Storage Groups!" - dir_be_sg = False + Enabling MythTV Storage Groups will create the directories + on the disk(s) and add the paths to the MythTV database. - #now for frontend storage groups - if dir_fe_sg != True: - loop = True - print "+" * 20 - prompt_string=''' - Frontend Storage Groups are used for videos. - The content on these storage groups will - only be available while the system is online. + Enable MythTV Storage Groups (Y/N)?:''' - Do you wish enable this system for Frontend Storage Groups(Y/N)?:''' while loop: str1 = raw_input(prompt_string) if str1 in ['Y','N','y','n']: @@ -529,17 +521,21 @@ def prompt_sg(dir_be_sg,dir_fe_sg): print "\n" if str1 == 'Y' or str1 == 'y': - dir_fe_sg = True - print " ** Will add Frontend Storage Groups!" + dir_sg = True + print " ** Will add MythTV Storage Groups!" else: - dir_fe_sg = False - print " ** Will NOT add Frontend Storage Groups!" + print " ** Will NOT add MythTV Storage Groups!" + dir_sg = False + else: + dir_sg = True + print "\n --add_sg option used" + print " ** Will add MythTV Storage Groups!" - return dir_be_sg,dir_fe_sg + return dir_sg def remove_pickle(): try: - print "* Resetting list of known drives." + print "\n* Removing list of known disks.\n" os.remove(pickle_file) except: pass @@ -555,7 +551,7 @@ def last_disk_num(): return num_list[-1] #-------------------------------------------- -def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): +def main(scan_only, destruction, no_mount, install_call , dir_sg): global bus bus = dbus.SystemBus() @@ -565,6 +561,8 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): process_list=[] no_process_list=[] + print "-" * 60 + print " Scan for Disks" for i in system_drive_list: #print i.mount_path @@ -575,8 +573,17 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): #print "--" if search_for_match(i,known_drive_list) or i.in_use : + if search_for_match(i,known_drive_list) : + dstatus = " Ignoring - Disk has been previously skipped:" + if i.in_use : + dstatus = " Ignoring - Disk is mounted:" + if search_for_match(i,known_drive_list) and i.in_use : + dstatus = " Ignoring - Disk has been previously skipped and is mounted:" + print "\n" - print " Storage is already in use or previously skipped:%s" %i.model + print " --------------------------------------------------------" + print dstatus + print " model: %s" %i.model print " location: %s" %i.block_path print " size: %s" %i.device_size continue @@ -584,27 +591,35 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): else: if not scan_only: print "\n" - print "-------------------------------------------------------------" - print " Found new hard drive: %s" %i.model - print " location: %s" %i.block_path - print " size: %s " %i.device_size + print " --------------------------------------------------------" + print " Found New Disk:" + print " model: %s" %i.model + print " location: %s" %i.block_path + print " size: %s " %i.device_size if prompt_to_add(i,destruction) : - print "\n Disk will be added to the storage pool!" + print "\n %s will be added to your system!" %i.model process_list.append(i) else: no_process_list.append(i) else: process_list.append(i) - print " End of scan" - print "---------------------------------------" + print "\n" + print " Scan Finished" + print "-" * 60 if scan_only: if len(process_list) > 0: + print " Unknown or Unmounted Disks:" f = open('/tmp/scan_report', 'w') for i in process_list: - f.write("drive: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size)) - print "drive: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size) + f.write("disk: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size)) + print "\n" + print " ---------------------------------------------------------" + print " Found New Disk:" + print " model: %s" %i.model + print " location: %s" %i.block_path + print " size: %s " %i.device_size f.close() sys.exit(0) @@ -619,7 +634,7 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): system_drive_list.remove(y) write_known_drive_list(system_drive_list) else: - print "\nDid not find any new storage to add.\n" + print "\nThere are no disks to add to your system.\n\nFor more options: add_storage.py --help\n" write_known_drive_list(system_drive_list) #BE = MythBE(db=DB) @@ -630,15 +645,16 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): if len(process_list) > 0: - print " Will add %s disks to systems" %len(process_list) + print "\n Will add %s disk(s) to your system." %len(process_list) - dir_be_sg , dir_fe_sg = prompt_sg(dir_be_sg,dir_fe_sg) - if prompt_to_continue() == True: + dir_sg = prompt_sg(dir_sg) + if prompt_to_continue(process_list) == True: write_known_drive_list(system_drive_list) disk_num = last_disk_num() for i in process_list: - print " Drive: %s" %(i.get_name()) + print " Disk: %s" %(i.get_name()) disk_num = disk_num + 1 + i.lookup_format() if destruction == True: i.partition_disk() i.format_disk() @@ -646,10 +662,8 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): i.mount_disk(no_mount) #if destruction == True: - if dir_fe_sg == True: - i.mkdirs(FS_LIST_FE) - if dir_be_sg == True: - i.mkdirs(FS_LIST_BE) + if dir_sg == True: + i.mkdirs(FS_LIST) i.set_disk_num(disk_num) i.write_config() @@ -658,17 +672,15 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): i.symlink_disk() - if dir_fe_sg == True: - i.add_sg(DB,host,SG_MAP_FE) - if dir_be_sg == True: - i.add_sg(DB,host,SG_MAP_BE) + if dir_sg == True: + i.add_sg(DB,host,SG_MAP) print "-----" cmd = "systemconfig.py -m fileshare" runcmd(cmd) #i.add_sg(DB,host,SG_MAP) -def myth_main(no_mount,install_call,dir_fe_sg): +def myth_main(no_mount,install_call,dir_sg): global bus bus = dbus.SystemBus() #search for root @@ -713,19 +725,18 @@ def myth_main(no_mount,install_call,dir_fe_sg): host=gethostname() - print " Drive: %s" %(i.get_name()) + print " Disk: %s" %(i.get_name()) i.set_mmount(True) i.set_partition("7") i.set_disk_num(0) + i.lookup_format() i.add_fstab(True) #if not install_call: i.mount_disk(no_mount) i.write_config() #no need to make the sub directories because the install process has taken care of it. - if dir_fe_sg == True: - i.add_sg(DB,host,SG_MAP_FE,'99',install_call) - if dir_be_sg == True: - i.add_sg(DB,host,SG_MAP_BE,'99',install_call) + if dir_sg == True: + i.add_sg(DB,host,SG_MAP,'99',install_call) i.symlink() cmd = "systemconfig.py -m fileshare" @@ -736,7 +747,7 @@ class reconstruct_path: self.conf_file = conf_file parser = SafeConfigParser() parser.read(self.conf_file) - + self.config = ConfigParser.RawConfigParser() self.uuid = parser.get('storage', 'uuid') self.mount_point = parser.get('storage', 'mountpoint') @@ -745,9 +756,22 @@ class reconstruct_path: self.bind = self.myth_mount self.disk_num = parser.get('storage', 'disk_num') self.top_mount_dir = os.path.dirname(self.mount_point) + try: + self.fstype = parser.get('storage', 'fstype') + except: + self.fstype = self.get_fstype() + + def get_fstype(self): + cmd = "fsck -N UUID=%s" %self.uuid + tmpfstype = runcmd(cmd) + tmpfstype = tmpfstype[1].split('/sbin/fsck.') + tmpfstype = tmpfstype[1].split(' ') + self.fstype = tmpfstype[0] + self.write_config() + return self.fstype def get_conf(self): - return self.conf_file + return self.conf_file def get_uuid(self): return self.uuid @@ -809,30 +833,29 @@ class reconstruct_path: f.close() def symlink(self): - print " Creating symlink" + print " Creating symlink for /myth" if not os.path.exists("/myth"): cmd = "ln -s %s/media /myth " %(self.mount_point) runcmd(cmd) else: - print " Skipping symlink, path already present" + print " Skipping symlink, /myth already exists" def symlink_disk(self): - print " Creating symlink for disk number" + 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) - def add_fstab(self): #new_fstab_list=['UUID=', 'mount_point', 'auto', 'defaults', '0', '1'] - new_fstab_list=['UUID=', 'mount_point', self.new_fstype, 'defaults', '0', '1'] + new_fstab_list=['UUID=', 'mount_point', self.fstype, 'defaults', '0', '1'] fstab=self.read_fstab() if self.bind == "True": self.symlink() if self.check_in_fstab(fstab,self.uuid) == True: - print " Found storage in fstab, will not add it" + print " Found disk in fstab, will not add it" else: print " Adding storage to fstab" if self.bind == "True" : @@ -857,19 +880,39 @@ class reconstruct_path: except: os.makedirs(self.mount_point) if no_mount == False : - cmd = "mount %s" %self.mount_point - runcmd(cmd) + if os.path.ismount(self.mount_point): + print " Disk already mounted, will not mount:\n %s" %self.mount_point + pass + else: + print " Mounting %s" %self.mount_point + cmd = "mount %s" %self.mount_point + runcmd(cmd) + return + + def write_config(self): + print " Writing /etc/storage.d conf file" + self.config.add_section('storage') + self.config.set('storage','uuid',self.uuid) + self.config.set('storage','mountpoint',self.mount_point) + 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','disk_num',self.disk_num) + + print " %s" %self.conf_file + with open(self.conf_file, 'wb') as self.conf_file: + self.config.write(self.conf_file) return def reconstruct_mounts(no_mount): - print "Recreating devices based on contents of /etc/storage.d" + print "\nRecreating disks from contents of /etc/storage.d/" for conf_file in glob.glob('%s/*.conf' %storage_dir): print "\n" cf = reconstruct_path(conf_file) #print cf.get_conf() #print cf.get_uuid() - print " %s" %cf.get_mount_point() + print " Recreating %s" %cf.get_mount_point() #print cf.get_shareable() #print cf.get_is_myth_mount() #print cf.get_disk_num() @@ -879,30 +922,52 @@ def reconstruct_mounts(no_mount): cf.symlink_disk() cf.mount_disk(no_mount) + print "\n\nDone recreating disks.\n" pass def usage(): - help='''\n - Add storage is designed to find and setup new disks for mythtv usage. - It's a powerfull tool that could destroy data if not used correctly, so please be careful. - Normal operations include (in this order): + help=''' + add_storage.py finds and sets up disks for MythTV usage. + It's a powerful tool that could destroy data if not used correctly, + please be careful. + + 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 + automatically set to the type selected for the data partition + at install. + + Normal operations without options include (in this order): Partition the disk Format the disk Add disk to /etc/fstab Mount the disk - Create the directory - Write out the config file to /etc/storage.d - Add new locations to mythtv storage groups - - options: - - --no_mount : Do not mount the disk, only add it to /etc/fstab and create the dir. - --no_destruction: Will not partition or format the disk. This can be used to import disks from other systems. - --new_init : Erase the list of new disks and rescan. - --report : will scan the disks and print out if it found new storage. - --add_fe_sg : Will only create the storage group dir for videos..excludes tv - --add_be_sg : Will only create the storage group dir for TV, backups, streaming + Create the directories + (if user enables MythTV Storage Groups) + Write out the disk config file to /etc/storage.d/ + Create disk# symlink at /data/storage/ + Create /myth symlink (if applicable) + Create MythTV Storage Group paths in MythTV database + (if user enables MythTV Storage Groups) + + Options: + --add_sg: Create the MythTV Storage Group directories and + database entries for database backups, TV + recordings, 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. + All other normal operations will be performed. + Can be used to import disks from other systems. + --no_mount: Do not mount the disk. + All other normal operations will be performed. + --reconstruct: Recreate mount point, /myth symlink, fstab entry, + /data/storage/disk# symlink, and mount the disk. + --no_mount is the only option that works with + --reconstruct. + --report: Scan disks and print new found disks. ''' print help sys.exit(0) @@ -916,8 +981,7 @@ if __name__ == "__main__": no_mount = False destruction = True install_call = False - dir_fe_sg = False - dir_be_sg = False + dir_sg = False reconstruct = False try: os.remove("/tmp/scan_report") @@ -925,9 +989,9 @@ if __name__ == "__main__": pass if not os.geteuid()==0: - sys.exit("\nRoot access is required to run this program\n") + sys.exit("\nRoot access is required to run this program.\n") - if "--help" in sys.argv: + if "--help" in sys.argv or "-h" in sys.argv: usage() if "--install_call" in sys.argv: @@ -945,23 +1009,23 @@ if __name__ == "__main__": if "--report" in sys.argv : scan_only = True + if "--add_sg" in sys.argv: + dir_sg = True + + #there is no distinction between FE and BE sg anymore + #but leaving these for backwards compatibility if "--add_fe_sg" in sys.argv: - dir_fe_sg = True + dir_sg = True if "--add_be_sg" in sys.argv: - dir_be_sg = True - + dir_sg = True if "--reconstruct" in sys.argv: reconstruct = True if "--double_myth" in sys.argv: - myth_main(no_mount,install_call,dir_fe_sg) + myth_main(no_mount, install_call, dir_sg) elif reconstruct == True: reconstruct_mounts(no_mount) else: - main(scan_only,destruction,no_mount, install_call, dir_fe_sg, dir_be_sg) - - - - + main(scan_only,destruction,no_mount, install_call, dir_sg) diff --git a/abs/core/LinHES-system/create_media_dirs.sh b/abs/core/LinHES-system/create_media_dirs.sh index 9e64301..6af6eb7 100644 --- a/abs/core/LinHES-system/create_media_dirs.sh +++ b/abs/core/LinHES-system/create_media_dirs.sh @@ -52,11 +52,11 @@ media/tmp media/archive media/pretty media/streaming -media/video_stuff/trailers -media/video_stuff/coverart -media/video_stuff/fanart -media/video_stuff/screenshots -media/video_stuff/banners +media/artwork/trailers +media/artwork/coverart +media/artwork/fanart +media/artwork/screenshots +media/artwork/banners media/games/screenshots media/games/fanart media/games/boxart diff --git a/abs/core/LinHES-system/diskspace.cron b/abs/core/LinHES-system/diskspace.cron deleted file mode 100755 index ab3c91b..0000000 --- a/abs/core/LinHES-system/diskspace.cron +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -/usr/bin/nice -n19 /usr/LH/bin/diskspace.sh -osd diff --git a/abs/core/LinHES-system/lh_backend_control.sh b/abs/core/LinHES-system/lh_backend_control.sh index c116cdb..4b0f184 100644 --- a/abs/core/LinHES-system/lh_backend_control.sh +++ b/abs/core/LinHES-system/lh_backend_control.sh @@ -24,7 +24,7 @@ case $1 in then $MV_BEC stop $dbhost else - msg_client.py --msg "Stopping backend" + msg_client.py --msg "Stopping MythBackend" sudo sv stop mythbackend fi else @@ -41,7 +41,7 @@ case $1 in then $MV_BEC start $dbhost else - msg_client.py --msg "Starting backend" + msg_client.py --msg "Starting MythBackend" sudo sv start mythbackend fi else @@ -58,7 +58,7 @@ case $1 in then $MV_BEC restart $dbhost else - msg_client.py --msg "Restarting backend" + msg_client.py --msg "Restarting MythBackend" sudo sv restart mythbackend fi else @@ -71,5 +71,3 @@ case $1 in ;; esac - - diff --git a/abs/core/LinHES-system/lh_system_backup_job b/abs/core/LinHES-system/lh_system_backup_job index e095a97..3ac9de0 100644 --- a/abs/core/LinHES-system/lh_system_backup_job +++ b/abs/core/LinHES-system/lh_system_backup_job @@ -7,7 +7,8 @@ MYTH_RUN_STATUS="1" . /etc/profile . /etc/systemconfig BACKUPDIR=/data/storage/disk0/backup/system_backups -DELETE_DAYS=21 +SECBACKUPLINK=/data/storage/disk1 +KeepBackups=13 DATE=`date +%F_%H-%M` backup_status=0 # @@ -32,8 +33,7 @@ function backup_status_check(){ function backup(){ - echo "#######################################" - echo "Starting backup " + echo "Starting Backup" mkdir -p $BACKUPDIR/$DATE #backup database @@ -42,15 +42,19 @@ function backup(){ pacman -Q mysql 2>/dev/null if [ $? = 0 ] then + echo " mythconverg (mythtv database)" mysqldump -x mythconverg > $BACKUPDIR/$DATE/mythconverg backup_status_check $? - mysqldump -x ncid > $BACKUPDIR/$DATE/ncid + 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 backup_status_check $? @@ -112,19 +116,20 @@ function backup(){ echo echo "Created file:" echo " $BACKUPDIR/backup.$DATE.tgz" - echo "########################################" } function update_backup_status(){ + echo # Add Last backup status to menu item #if description not in the backup xml file, add it if [ $rc=0 ] then - COMPLETE_MSG="Last backup completed on `date '+%D @ %-I:%M %p'`" + COMPLETE_MSG="Last backup completed `date '+%D %-I:%M %p'`" else - COMPLETE_MSG="Last backup FAILED on `date '+%D @ %-I:%M %p'`" + COMPLETE_MSG="Last backup FAILED `date '+%D %-I:%M %p'`" fi - + echo "Updating menu with:" + echo " $COMPLETE_MSG" xmlfile="/usr/share/mythtv/themes/defaultmenu/mythbackup.xml" grep -q "<description>" $xmlfile >/dev/null @@ -132,19 +137,27 @@ function update_backup_status(){ if [ $desc_check = 0 ] then - sed -i "s_\<description\>.*\<description\>_description\>$COMPLETE_MSG\<\/description_" $xmlfile + sed -i "0,/<description\>.*\<description\>/s||\<description\>$COMPLETE_MSG<\/description|" $xmlfile + #sed -i "0,/\<description\>.*\<description\>/s//\<description\>$COMPLETE_MSG\<\/description/" $xmlfile else sed -i " /NONE/ i\ \<description\>$COMPLETE_MSG\<\/description\>" $xmlfile fi } function remove_old_backups(){ + #remove old backups - find $BACKUPDIR/backup*.tgz -type f -mtime +$DELETE_DAYS -delete + NumBackups=`ls $BACKUPDIR/backup*.tgz|wc -l` + if [[ $NumBackups -gt $KeepBackups ]]; then + numdel=$(($NumBackups-$KeepBackups)) + rm -f `ls $BACKUPDIR/backup*.tgz -tr1|head -$numdel` + fi } function remote_backup(){ + echo + echo "Remote backup" #Remote copy if [ x$RemoteBackup = x1 ] then @@ -152,7 +165,7 @@ function remote_backup(){ if [ x$localRemoteCheck = xdir ] then localRemotedir=`echo $RemoteBackupDir | cut -d: -f2` - echo "copying $BACKUPDIR/backup.$DATE.tgz to $localRemotedir " + echo " copying $BACKUPDIR/backup.$DATE.tgz to $localRemotedir " cp $BACKUPDIR/backup.$DATE.tgz $localRemotedir else /usr/bin/func ${RemoteBackupDir} ping| grep -q "FAILED" @@ -161,13 +174,33 @@ function remote_backup(){ then #this is here to mark failed copy of the backup. #There is a cron.hourly job that will attempt to retransfer the file - echo "Remote backup failed to ${RemoteBackupDir}" + echo " Remote backup failed to ${RemoteBackupDir}" echo backup.$DATE.tgz >> $BACKUPDIR/remote_backup_failed.txt else - echo "copying $BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:$BACKUPDIR/MBE_$DATE.tgz" + echo " copying $BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:$BACKUPDIR/MBE_$DATE.tgz" /usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/backup.$DATE.tgz --remotepath $BACKUPDIR/MBE_$DATE.tgz fi fi + else #do local copy to SECBACKUPLINK + echo " Remote backup is not enabled, copying backup to $SECBACKUPLINK if it exists" + SECBACKUPDISK=`readlink $SECBACKUPLINK` + SECBACKUP=$SECBACKUPDISK/backup + + if [ -n "$SECBACKUPDISK" ]; then + if [ `mountpoint -q -d $SECBACKUPDISK` ]; then + if [ ! -d "$SECBACKUP" ]; then + mkdir -p -m 775 $SECBACKUP + echo " Created $SECBACKUP" + chown mythtv:users $SECBACKUP + fi + echo " Copying system backups to $SECBACKUP" + rsync -au --delete $BACKUPDIR $SECBACKUP + else + echo " $SECBACKUPDISK isn't mounted." + fi + else + echo " Link $SECBACKUPLINK doesn't exist." + fi fi } @@ -180,10 +213,10 @@ function remote_transfer(){ then #this is here to mark a failed copy of the backup. #There is a cron.hourly job that will attempt to retransfer the file - echo "Remote backup failed to ${RemoteBackupDir}" + echo " Remote backup failed to ${RemoteBackupDir}" echo $transfer_file >> $BACKUPDIR/remote_backup_failed.txt else - echo "copying $BACKUPDIR/$transfer_file to ${RemoteBackupDir}:$BACKUPDIR/MBE_$transfer_file" + echo " copying $BACKUPDIR/$transfer_file to ${RemoteBackupDir}:$BACKUPDIR/MBE_$transfer_file" /usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/$transfer_file --remotepath $BACKUPDIR/MBE_$transfer_file fi } diff --git a/abs/core/LinHES-system/lh_system_host_update b/abs/core/LinHES-system/lh_system_host_update index 56a22e5..ca6aeff 100644 --- a/abs/core/LinHES-system/lh_system_host_update +++ b/abs/core/LinHES-system/lh_system_host_update @@ -2,8 +2,8 @@ # Process that call this script # func update # supplemental web -echo "#####################################################" -echo "Starting update" + +echo "Starting Update" MYTH_RUN_STATUS="1" . /etc/profile @@ -17,7 +17,7 @@ fi case $Hostupdateplan in "Myth_only") - echo "Updating myth packages" + echo "Updating only myth packages" postfix=`cat $INSTALL_DIR/usr/local/share/mythtv/.releasetype` for mythl in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather mythcontrols mythgallery mythmovietime mythmusic mythsmolt mythvideo mythweb mythtv do @@ -52,6 +52,3 @@ case $Hostupdateplan in echo "Unknown $Hostupdateplan, skipping updates" ;; esac - - -echo "##################################################################################" diff --git a/abs/core/LinHES-system/linhes_update.sh b/abs/core/LinHES-system/linhes_update.sh index 87ac8a1..76501fb 100644 --- a/abs/core/LinHES-system/linhes_update.sh +++ b/abs/core/LinHES-system/linhes_update.sh @@ -6,7 +6,7 @@ dsply () { then msg_client.py --clear --tag "checkUpdates" msg_client.py --kill - msg_client.py --msg "Updates available!\nExit and re-enter Service Menu\nto install the updates.|middle" + msg_client.py --msg "Updates available!\nGo to the Service Menu to install the updates.|middle" exit else msg_client.py --msg "Checking for updates...|middle" --timeout 600 --tag "checkUpdates" @@ -20,7 +20,7 @@ chck () { then msg_client.py --clear --tag "checkUpdates" msg_client.py --kill - msg_client.py --msg "No updates available.|middle" + msg_client.py --msg "No updates available.\nReturning to Main Menu.|middle" else 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 @@ -30,6 +30,7 @@ chck () { 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 @@ -45,6 +46,7 @@ chck () { echo " <button>" >> /tmp/update3.xml.tmp echo " <type>UPGRADE</type>" >> /tmp/update3.xml.tmp echo " <text>REBOOT REQUIRED</text>" >> /tmp/update3.xml.tmp + 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 @@ -55,6 +57,7 @@ chck () { echo " <button>" >> /tmp/update3.xml.tmp echo " <type>UPGRADE</type>" >> /tmp/update3.xml.tmp echo " <text>$line</text>" >> /tmp/update3.xml.tmp + echo " <description>$line</description>" >> /tmp/update3.xml.tmp echo " <action>NONE</action>" >> /tmp/update3.xml.tmp echo " </button>" >> /tmp/update3.xml.tmp done < "/tmp/to_be_upgraded" diff --git a/abs/core/LinHES-system/linhes_update2.sh b/abs/core/LinHES-system/linhes_update2.sh index fbdd36b..b26e762 100644 --- a/abs/core/LinHES-system/linhes_update2.sh +++ b/abs/core/LinHES-system/linhes_update2.sh @@ -28,6 +28,7 @@ then 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 diff --git a/abs/core/LinHES-system/misc_status_info.sh b/abs/core/LinHES-system/misc_status_info.sh index 14a972c..a75b144 100755 --- a/abs/core/LinHES-system/misc_status_info.sh +++ b/abs/core/LinHES-system/misc_status_info.sh @@ -12,7 +12,7 @@ # Get Encoder that was used for recordings from the backend log firstrun=1 -loglist=`find /var/log/ -name *_mythbackend.*.log*` +loglist=`find /var/log/ -name *_mythbackend*.log*` for i in `ls -t $loglist` do if [ $firstrun -eq 1 ]; then diff --git a/abs/core/LinHES-system/misc_which_recorder.pl b/abs/core/LinHES-system/misc_which_recorder.pl index 6952b3f..2ad91b0 100755 --- a/abs/core/LinHES-system/misc_which_recorder.pl +++ b/abs/core/LinHES-system/misc_which_recorder.pl @@ -47,20 +47,20 @@ if ($log_file =~ /\.gz$/) { # read top down # open($fh, "gunzip -c $log_file |") or die "Unable to open log file '$log_file', stopping:"; +# read bottom up open($fh, "gunzip -c $log_file |tac |") or die "Unable to open log file '$log_file', stopping:"; } else { # read top down # open($fh, "<$log_file") or die "Unable to open log file '$log_file', stopping:"; +# read bottom up open($fh, "tac $log_file |") or die "Unable to open log file '$log_file', stopping:"; } while (<$fh>) { -# Myth .24 regex to find start of recording -# if (/^(.*)(?:\d(?: I )?|I.* -) (?:Started|Tuning) recording: (.*): channel (\d+) on cardid (\d+), sourceid (\d+)/) -# Myth .25 regex to find start of recording for digital and analog MPEG +# Myth .25 & .27 regex to find start of recording for digital and analog MPEG if (/^(\d+-\d+-\d+T\d+\:\d+\:\d+)(?:.*) (?:Started|Tuning) recording: (.*): channel (\d+) on cardid (\d+), sourceid (\d+)/ || /^(\d+-\d+-\d+T\d+\:\d+\:\d+)(?:.*) \(UpdateRecStatus\) Updating status for (.*)() on cardid (\d+) \(Will Record => Recording\)()/) { if ($mode eq "--noheader") diff --git a/abs/core/LinHES-system/msg.cfg b/abs/core/LinHES-system/msg.cfg new file mode 100644 index 0000000..0d687c5 --- /dev/null +++ b/abs/core/LinHES-system/msg.cfg @@ -0,0 +1,23 @@ +[default] +font_color=#ebb81c +display_time=5000 +position=1 +font_type=Overlock SC 40 + +[middle] +font_color=#ebb81c +display_time=5000 +position=4 +font_type=Overlock SC 40 + +[bottom] +font_color=#ebb81c +display_time=5000 +position=7 +font_type=Overlock SC 40 + +[alert] +font_color=red +display_time=5000 +position=4 +font_type=Overlock SC 40 diff --git a/abs/core/LinHES-system/myth_mtc.cron b/abs/core/LinHES-system/myth_mtc.cron new file mode 100755 index 0000000..4f63dec --- /dev/null +++ b/abs/core/LinHES-system/myth_mtc.cron @@ -0,0 +1,23 @@ +#!/bin/bash +MYTH_RUN_STATUS=1 +. /etc/profile + +date=`date +%Y-%m-%d` +timestamp=`date +'%Y-%m-%d %H:%M'` +logFile="/var/log/$date/myth_mtc.log" + +if [ ! -f $logFile ]; then + touch $logFile +fi + +#check logfile for Finished and if not run myth_mtc.py +if ! grep -q "Finished" $logFile +then + MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py >> $logFile 2>&1 + if [ $? = 0 ] + then + echo "Finished $timestamp" >> $logFile + else + echo "Time Exceeded $timestamp" >> $logFile + fi +fi diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py index a5f02a0..7847313 100755 --- a/abs/core/LinHES-system/myth_mtc.py +++ b/abs/core/LinHES-system/myth_mtc.py @@ -5,6 +5,7 @@ import re import socket import os import datetime,time +import shlex try: from MythTV import MythBE @@ -14,24 +15,33 @@ except: #print mythtv.db.getSetting( 'Theme', socket.gethostname()) +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')) + return date + + def optimize(): + try: cursor = mythtv.db.cursor() cursor.execute("SHOW tables") result = cursor.fetchall() except: - print "Problem getting tables from database" + print " Problem getting tables from database" return ops=["REPAIR","OPTIMIZE","ANALYZE"] for row in result: ctable=row[0] for op in ops: - print op,ctable + print " %s %s" %(op,ctable) cmd= "%s table %s" %(op,ctable) cursor.execute(cmd) def upcoming_check(): + print " Checking for upcoming shows" try: upcoming = mythtv.getUpcomingRecordings() except: @@ -50,11 +60,12 @@ def upcoming_check(): if ( time_diff > 30) : return True else: - print show , "is upcoming in " , time_diff + print " %s is upcoming in %s" %(show,time_diff) return False def schemalock_check(): + print " Checking if schema is locked" try: c = mythtv.db.cursor() c.execute("select count(*) from schemalock") @@ -66,10 +77,11 @@ def schemalock_check(): if schemalock == 0: return True else: - print "schema is locked" + print " schema is locked" return False def job_check(): + print " Checking jobqueue" try: c = mythtv.db.cursor() c.execute("select count(*) from jobqueue where status = 4") @@ -80,11 +92,12 @@ def job_check(): if jobs == 0 : return True else: - print " jobs are running" + print " jobs are running" return False def in_use(): + print " Checking if programs are in use" try: c = mythtv.db.cursor() c.execute("select count(*) from inuseprograms") @@ -95,10 +108,11 @@ def in_use(): if prginuse == 0 : return True else: - print "programs in use" + print " Programs in use" return False def mfd_check(): + print " Checking is mythfilldatabase is running" ps = subprocess.Popen("ps ax -o pid= -o args= ", shell=True, stdout=subprocess.PIPE) ps_pid = ps.pid output = ps.stdout.read() @@ -110,50 +124,64 @@ def mfd_check(): if res: pid = int(res[0][0]) if proc_name in res[0][1] and pid != os.getpid() and pid != ps_pid: - print "mythfilldatabase is running" + print " mythfilldatabase is running" return False return True +def bail_if_another_is_running(): + cmd = shlex.split("pgrep -u {} -f {}".format(os.getuid(), __file__)) + pids = subprocess.check_output(cmd).strip().split('\n') + if len(pids) > 1: + pids.remove("{}".format(os.getpid())) + print "Exiting! Found {} is already running (pids): {}".format( + __file__, " ".join(pids)) + raise SystemExit(1) def idle_check(): + print "\n%s Checking Idle" %(get_timestamp()) if ( upcoming_check() and schemalock_check() and job_check() and in_use() and mfd_check() ): idle=True - print "Myth is idle" + print "\n%s Myth is idle" %(get_timestamp()) else: idle=False - print "Myth is NOT idle" + print "\n%s Myth is NOT idle" %(get_timestamp()) return idle def run_stuff(): if idle_check(): - print "Running optimize" + print "\n#######################################" + print "\n%s Running Optimize" %(get_timestamp()) optimize() - print "Running backup" + print "\n#######################################" + print "\n%s Running Backup" %(get_timestamp()) os.system('/usr/LH/bin/lh_system_backup_job') - print "Running system_update" - os.system('/usr/LH/bin/lh_system_host_update') + print "\n#######################################" + print "\n%s Running System Update" %(get_timestamp()) + os.system('/usr/LH/bin/lh_system_host_update') + + print "\n#######################################" continue_loop=False else: continue_loop=True return continue_loop #--------------------------------- +bail_if_another_is_running() starttime=time.time() ctin=True while ctin: ctin=run_stuff() if ctin: + print "\n%s Waiting 10 minutes before trying again." %(get_timestamp()) time.sleep(600) + current_time=time.time() - if (current_time - starttime) > 10800 : + if (current_time - starttime) > 3000 : ctin = False - print "time exceeded (3 hours)" + print "\n%s Time Exceeded 50 minutes. Quitting.)" %(get_timestamp()) exit(1) - - - diff --git a/abs/core/LinHES-system/myth_mtc.sh b/abs/core/LinHES-system/myth_mtc.sh deleted file mode 100755 index 7899daa..0000000 --- a/abs/core/LinHES-system/myth_mtc.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -MYTH_RUN_STATUS=1 -. /etc/profile - -date=`date +%Y-%m-%d` -logFile="/var/log/$date/myth_mtc.log" - -MYTHCONFDIR=/usr/share/mythtv myth_mtc.py > $logFile 2>&1 -if [ $? = 0 ] -then - echo "Finished $date" >> $logFile -else - echo "Time Exceede $date" >> $logFile -fi diff --git a/abs/core/LinHES-system/myth_status.py b/abs/core/LinHES-system/myth_status.py index 2e48024..40dd3b3 100644 --- a/abs/core/LinHES-system/myth_status.py +++ b/abs/core/LinHES-system/myth_status.py @@ -1,115 +1,263 @@ #!/usr/bin/python2 +#This program is called on login to display the status of mythtv tuners & recording status +#Also will display alerts generated by xymon. If the location of xymon changes, this script needs to be updated. + from MythTV import MythBE,MythDB,MythLog -import datetime,time,sys,subprocess -try: - be=MythBE() - db = MythDB() -except: - print "\nCouldn't connect to MythTV service for status" - sys.exit(1) - -cursor = db.cursor() -now = datetime.datetime.now() -farout=99999999 -next_start_diff=datetime.timedelta(farout) -num_upcoming=12 +import datetime,time,sys,subprocess,re +import os,glob +from socket import gethostname; def formatTD(td): - #print td days = td.days hours = td.seconds // 3600 minutes = (td.seconds % 3600) // 60 seconds = td.seconds % 60 - if days > 1: - day_string = "%s days" %days + if days == 0: + day_string = "" + elif days > 1: + day_string = "%s days, " %days else: - day_string = "%s day" %days + day_string = "%s day, " %days if hours > 1: - hour_string = "%s hours" %hours + hour_string = "%s hours, " %hours else: - hour_string = "%s hour" %hours + hour_string = "%s hour, " %hours if minutes > 1: - minute_string = "%s minutes" %minutes + minute_string = "%s minutes, " %minutes else: - minute_string = "%s minute" %minutes + minute_string = "%s minute, " %minutes if seconds > 1: second_string = "%s seconds" %seconds else: second_string = "%s second" %seconds - return_string = '%s, %s, %s, %s' % (day_string, hour_string, minute_string, second_string) + return_string = '%s%s%s%s' % (day_string, hour_string, minute_string, second_string) return return_string +def print_alerts(): + dir_name = "/home/xymon/var/login_alerts" + out_alert="" + try: + os.chdir(dir_name) + except: + pass + #print " myth_status: Couldn't change dir to %s" %dir_name + file_list=glob.glob("*") + + if len(file_list) == 0: + #print " myth_status: no alert files found" + pass + else: + for alert_file in file_list: + out_line='' + datahost = '' + dataservice = '' + datacolor = '' + datadown = '' + try: + #print " myth_staus: reading in %s" %alert_file + f=open(alert_file,'r') + lines=f.readlines() + f.close() + except: + #print " myth_status: Couldn't open %s for reading" %alert_file + continue + + for line in lines: + try: + data,value=line.split(":") + except: + continue #exception occured try the next line + + if data == 'HOST': + datahost = value.strip() + elif data == 'SERVICE': + dataservice = value.strip() + elif data == 'COLOR': + datacolor = value.strip() + elif data == 'DOWN': + datadown = value.strip() + sec=int(datadown) + td_sec = datetime.timedelta(seconds=sec) + td_sec_formated = formatTD(td_sec) + + out_line =" %s on %s %s for %s \n" %(dataservice, + datahost,datacolor.upper(), + td_sec_formated) + out_alert += out_line + + print "System Alerts:" + print "--------------" + if len(out_alert) > 0: + print out_alert + print " Go to http://%s and click Health & Maintenance for more information." %gethostname() + else: + print " All systems OK" -a=be.getRecorderList() -header="#"*60 -print header -print "" -print "Tuner Status: " -print "--------------" -for i in a: - cmd="select cardtype,hostname from capturecard where cardid=%s;" %i + return - cursor.execute(cmd) - results=cursor.fetchall() - type = results[0][0] - hostname = results[0][1] - id = i - try: - c=be.getCurrentRecording(i) - if c.title == None: - current_recording = "Idle" + +#------------------------------------------- + + +class tuner_recording_status: + def __init__ (self,num_upcoming): + + self.now = datetime.datetime.now() + self.farout=99999999 + self.next_start_diff=datetime.timedelta(self.farout) + self.num_upcoming=num_upcoming + self.tuner_status_list=[] + self.conflict_list=[] + self.upcoming_list=[] + self.ur=0 + self.db_connection_status = self.check_database_connection() + if self.db_connection_status == 0: + self.tuner_status() + self.conflicts() + self.upcoming_recordings() + + def get_db_check_status(self): + return self.db_connection_status + + def check_database_connection(self): + rc=0 + try: + self.be = MythBE() + self.db = MythDB() + self.cursor = self.db.cursor() + except: + print "\nCouldn't connect to MythTV service for status" + rc=1 + return rc +#----- + def tuner_status(self): + a=self.be.getRecorderList() + for i in a: + outline='' + cmd="select cardtype,hostname from capturecard where cardid=%s;" %i + self.cursor.execute(cmd) + results=self.cursor.fetchall() + type = results[0][0] + hostname = results[0][1] + id = i + try: + c=self.be.getCurrentRecording(i) + if c.title == None: + current_recording = "Idle" + else: + current_recording = "Recording %s" %c.title + outline = " Tuner %s (%s) on %s : %s " %(id, type, hostname, current_recording) + self.tuner_status_list.append(outline) + except: + outline = " Tuner %s (%s) on %s : %s " %(id, type, hostname, "Tuner Error") + self.tuner_status_list.append(outline) + + def get_tuner_status(self): + return self.tuner_status + + def print_tuner_status(self): + print "Tuner Status:" + print "-------------" + if len(self.tuner_status_list) > 0 : + for line in self.tuner_status_list: + print line else: - current_recording = "Recording %s" %c.title - print " Tuner %s (%s) on %s : %s " %(id, type, hostname, current_recording) - except: - print " Tuner %s (%s) on %s : %s " %(id, type, hostname, "Tuner Error") - -print "" -print "Upcoming Recordings (Next %s scheduled):" %(num_upcoming) -print "--------------------" -a=be.getUpcomingRecordings() -r=0 -for i in a: - r += 1 - if r > num_upcoming: - break - - title_chan="%s (%s)" %(i.title, i.channame) - print " %s - %s - %-50s " %(i.starttime,i.hostname, title_chan) - #start_time=time.strptime(str(i.starttime), "%Y-%m-%d %H:%M:%S") - diff = i.starttime - now - if diff < next_start_diff : - next_start_diff = diff - - -print "" -print "Conflicted Recordings:" -print "----------------------" -a=be.getConflictedRecordings() -c=0 -for i in a: - title_chan="%s (%s)" %(i.title, i.channame) - print " %s - %-50s " %(i.starttime,title_chan) - c=c+1 - -if c == 0: - print " No conflicts" - -print "" -print "" - - -if next_start_diff == datetime.timedelta(farout): - ur="No recordings are scheduled" -else: - ur=formatTD(next_start_diff) -print "The next recording starts in:\n %s" %(ur) -print "" -subprocess.call("/usr/LH/bin/diskspace.sh",shell=True) -print "" + print " No tuners found" + +#-------- + def upcoming_recordings(self): + + a=self.be.getUpcomingRecordings() + r=0 + for i in a: + r += 1 + if r > self.num_upcoming: + break + + title_chan="%s (%s)" %(i.title, i.channame) + #remove timezone + start_time=re.split("[-+]\d\d:\d\d",str(i.starttime))[0] + start_time_struct=datetime.datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S") + start_time_out=start_time_struct.strftime("%a %b %d %I:%M%p") + self.upcoming_list.append([start_time_out,i.hostname, title_chan]) + #print " %s - %s - %s" %(start_time_out,i.hostname, title_chan) + diff = start_time_struct - self.now + if diff < self.next_start_diff : + self.next_start_diff = diff + + if self.next_start_diff == datetime.timedelta(self.farout): + self.ur="No recordings are scheduled" + else: + self.ur=formatTD(self.next_start_diff) + + + def get_upcoming_recordings(self): + return self.upcoming_list + + def print_upcoming_recordings(self): + #print self.get_upcoming_recordings() + print "" + print "Upcoming Recordings (Next %s Scheduled):" %(self.num_upcoming) + print "----------------------------------------" + if len(self.get_upcoming_recordings()) > 0: + for i in self.get_upcoming_recordings(): + #print " %s - %s - %s" %(start_time_out,i.hostname, title_chan) + print " %s - %s - %s" %(i[0],i[1],i[2]) + else: + print " No upcoming recordings" + pass + + def get_next_start_time(self): + return self.ur + + def print_next_start_time(self): + print "" + print "The next recording starts in:" + print "-----------------------------" + print " %s" %(self.get_next_start_time()) + print "" + +#----- + + def conflicts(self): + a=self.be.getConflictedRecordings() + for i in a: + out_line='' + title_chan="%s (%s)" %(i.title, i.channame) + out_line=(i.starttime,title_chan) + self.conflict_list.append(out_line) + + def get_conflict_list(self): + return self.conflict_list + + def print_conflict_list(self): + print "" + print "Recording Conflicts:" + print "--------------------" + if len(self.get_conflict_list()) > 0: + for i in self.get_conflict_list(): + print " %s - %-50s " %(i[0],i[1]) + else: + print " No conflicts" + +#header="#"*60 + + +def go(): + tuner = tuner_recording_status(12) + if tuner.get_db_check_status() == 0: + tuner.print_tuner_status() + tuner.print_upcoming_recordings() + tuner.print_conflict_list() + tuner.print_next_start_time() + print_alerts() + + +if __name__ == "__main__": + go() diff --git a/abs/core/LinHES-system/mythfrontend-start b/abs/core/LinHES-system/mythfrontend-start index 5cfc9b7..320f960 100755 --- a/abs/core/LinHES-system/mythfrontend-start +++ b/abs/core/LinHES-system/mythfrontend-start @@ -3,12 +3,7 @@ PIDS=$(pidof mythfrontend) P_array=( $PIDS ) let "instances = ${#P_array[*]}" # Count elements. -if pacman -Q mythtv | grep -q 0.24 -then - STARTCMD="/usr/bin/mythfrontend -d -l /var/log/mythtv/mythfrontend.log" -else - STARTCMD="/usr/bin/mythfrontend -d --syslog local6" -fi +STARTCMD="/usr/bin/mythfrontend -d --syslog local6" if [ $instances -gt 0 ]; then diff --git a/abs/core/LinHES-system/switch_web.sh b/abs/core/LinHES-system/switch_web.sh deleted file mode 100644 index bf57764..0000000 --- a/abs/core/LinHES-system/switch_web.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -#This script is used to switch the default homepage between supplementalweb and -#the standard local webpage -. /etc/systemconfig -DATADIR=/data/srv/httpd/htdocs - -function rmindex { - if [ -L $DATADIR/index.html ] - then - rm -f $DATADIR/index.html - fi -} - -if [ $SystemType = Master_backend -o $SystemType = Standalone ] -then - if [ x$1 = xsupplemental ] - then - rmindex - ln -s $DATADIR/alt_index.html $DATADIR/index.html - else - rmindex - ln -s $DATADIR/index.htm $DATADIR/index.html - fi -else - echo "This service is only available for StandAlone or Master_backend LinHES systems" - -fi - - diff --git a/abs/core/LinHES-system/system.install b/abs/core/LinHES-system/system.install index ddad9e3..880ea02 100644 --- a/abs/core/LinHES-system/system.install +++ b/abs/core/LinHES-system/system.install @@ -8,17 +8,11 @@ pre_install() { # arg 1: the new package version post_install() { - MVDIR=/usr/LH/bin - #add myth_mtc to cron list - if [ ! -e /etc/cron.daily/myth_mtc ] - then - ln -s $MVDIR/myth_mtc.sh /etc/cron.daily/myth_mtc + #remove daily myth_mtc link + if [ -h /etc/cron.daily/myth_mtc ]; then + rm -f /etc/cron.daily/myth_mtc fi - # Add db entry for misc status in MythWeb - # not needed in R8 because it's in the DB, may be removed - #/usr/LH/bin/misc_status_config.py - sv restart msg_daemon } |