diff options
author | Cecil <knoppmyth@gmail.com> | 2012-01-14 20:46:12 (GMT) |
---|---|---|
committer | Cecil <knoppmyth@gmail.com> | 2012-01-14 20:46:12 (GMT) |
commit | c321283760591e3c6e5d9ed415e9c422fee83d9e (patch) | |
tree | 4e482fdf514f477c7ac23e0da81ec82a51a53b39 /abs/core/LinHES-system | |
parent | e9948fef7a06dbb6b0c53e50df10c0a0dc2d941b (diff) | |
parent | d5525acd5a4054460b98930b46d9de5690c1fd36 (diff) | |
download | linhes_pkgbuild-c321283760591e3c6e5d9ed415e9c422fee83d9e.zip linhes_pkgbuild-c321283760591e3c6e5d9ed415e9c422fee83d9e.tar.gz linhes_pkgbuild-c321283760591e3c6e5d9ed415e9c422fee83d9e.tar.bz2 |
Merge branch 'testing' of ssh://cesman@linhes.org/mount/repository/linhes_pkgbuild into testing
Diffstat (limited to 'abs/core/LinHES-system')
-rwxr-xr-x | abs/core/LinHES-system/LinHES-session | 23 | ||||
-rw-r--r-- | abs/core/LinHES-system/LinHES.install | 12 | ||||
-rwxr-xr-x | abs/core/LinHES-system/PKGBUILD | 32 | ||||
-rw-r--r-- | abs/core/LinHES-system/fix_myth_mount.py | 51 | ||||
-rw-r--r-- | abs/core/LinHES-system/fix_myth_mount.sh | 22 | ||||
-rw-r--r-- | abs/core/LinHES-system/lh_system_all_host_update | 8 | ||||
-rw-r--r-- | abs/core/LinHES-system/lh_system_backup_job | 64 | ||||
-rw-r--r-- | abs/core/LinHES-system/lh_system_host_update | 56 | ||||
-rw-r--r-- | abs/core/LinHES-system/lh_system_restore_job | 76 | ||||
-rwxr-xr-x | abs/core/LinHES-system/myth_mtc.py | 59 | ||||
-rw-r--r-- | abs/core/LinHES-system/set_windowmanager.sh | 8 |
11 files changed, 369 insertions, 42 deletions
diff --git a/abs/core/LinHES-system/LinHES-session b/abs/core/LinHES-system/LinHES-session index 626d346..e4833fa 100755 --- a/abs/core/LinHES-system/LinHES-session +++ b/abs/core/LinHES-system/LinHES-session @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash . /etc/profile . /etc/systemconfig @@ -218,6 +218,7 @@ function first_configure_mv(){ then if [ -f ~/.configure ] then + msg "This is the first time starting MythTV.\nThe MythTV backend process will be stopped for setup." #for now skip these #autocard.py -g & #MythVantage -b @@ -227,11 +228,14 @@ function first_configure_mv(){ STATUS=$? if [ ! $STATUS = 2 ] then - /usr/bin/backend_control.sh stop BE 127.0.0.1 - /usr/local/bin/mythtv-setup - /usr/bin/backend_control.sh start BE 127.0.0.1 + /usr/MythVantage/bin/backend_control.sh stop BE 127.0.0.1 + msg "MythTV setup is starting.\nPlease follow the steps for adding tuners and guide data." + /usr/bin/taskset -c 0 /usr/bin/mythtv-setup + /usr/MythVantage/bin/backend_control.sh start BE 127.0.0.1 fi - rm ~/.configure + nice -n 19 mythfilldatabase --quiet & + msg "Guide data is being loaded. \nUntil this completes \nsome shows will appear as "unknown" \nin the program guide." + rm -f ~/.configure fi fi @@ -275,7 +279,14 @@ function run_myth(){ else killall -9 irexec /usr/bin/irexec -d - $STARTCMD 2>&1 & + + if [ x$STARTUP_STYLE = xmythvantage ] + then + $STARTCMD 2>&1 + else + $STARTCMD 2>&1 & + fi + fi fi } diff --git a/abs/core/LinHES-system/LinHES.install b/abs/core/LinHES-system/LinHES.install index 0f6689e..c9950f2 100644 --- a/abs/core/LinHES-system/LinHES.install +++ b/abs/core/LinHES-system/LinHES.install @@ -12,11 +12,14 @@ MVDIR=/usr/LH/bin # ln -s $MVDIR/backup_job /etc/cron.daily/backup_cron # ln -s $MVDIR/update_system /etc/cron.daily/xupdate_system_cron # ln -s $MVDIR/repo_sync.sh /etc/cron.daily/zrepo_sync.sh - if [ ! -e /etc/cron.daily/myth_mtc.sh ] + if [ ! -e /etc/cron.daily/myth_mtc ] then - ln -s $MVDIR/myth_mtc.sh /etc/cron.daily/myth_mtc.sh + ln -s $MVDIR/myth_mtc.sh /etc/cron.daily/myth_mtc + fi + if [ -e /etc/cron.daily/myth_mtc.sh ] + then + rm -f /etc/cron.daily/myth_mtc.sh fi - #LINE="mythtv ALL = NOPASSWD: /sbin/sv stop mythbackend" LINE="mythtv ALL=(ALL) NOPASSWD: ALL" LINE1="%wheel ALL=(ALL) NOPASSWD: ALL" @@ -55,6 +58,9 @@ sed -i.orig 's/^Mod1 x :.*xterm.*$/Mod1 x :ExecCommand tvterm.sh/g' \ ~mythtv/.fluxbox/keys pkill -HUP fluxbox + + + } # arg 1: the new package version diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index d0012c1..ef5b2e8 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,16 +1,26 @@ pkgname=LinHES-system pkgver=2 -pkgrel=13 +pkgrel=22 arch=('i686') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin install=LinHES.install pkgdesc="scripts and things related to having an automated system" -depends=(linhes-sounds xdotool fluxbox tilda keylaunch python_aosd) +depends=(linhes-sounds xdotool fluxbox tilda keylaunch python_aosd 'linhes-scripts>=7-24' 'runit-scripts>=2.1.1-43') backup=(etc/modprobe.d/alsa-base) -binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh LinHES-run firstboot.sh load-modules-mythvantage.sh unclutter-toggle.sh tvterm.sh myth_mtc.lr smolt.cron mythfrontend-start set_windowmanager.sh myth_status.py myth_status.sh xmsg.py install_supplemental_service.sh" +binfiles="LinHES-start optimize_mythdb.py + myth_mtc.py myth_mtc.sh LinHES-run + firstboot.sh load-modules-mythvantage.sh + unclutter-toggle.sh tvterm.sh smolt.cron + mythfrontend-start set_windowmanager.sh + myth_status.py myth_status.sh + xmsg.py install_supplemental_service.sh + lh_system_backup_job + lh_system_restore_job + lh_system_host_update + lh_system_all_host_update" -source=(LinHES-session LinHES-profile.sh $binfiles alsa-base) +source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr) build() { cd $startdir/src @@ -37,23 +47,27 @@ build() { mkdir $startdir/pkg/etc/logrotate.d cp $startdir/myth_mtc.lr $startdir/pkg/etc/logrotate.d } -md5sums=('989c22c2eae00501f5b46f215dbf5e59' +md5sums=('71a1fc9b01476b0b2c30596107eeff75' '5881bdb43d578ec3a79d1f77ea58a3db' 'a875ee97f86e46f34a741c2bc455f894' '76b2637cac0452b3acdbeeb4e8a5474b' - '6a42d3799fad2ebffac2fbf2411511ed' + 'd1f27cb422010077c841376526fe46ea' '2ef9f945e034119f77d9b6beb17e4fa5' 'f7ecc552a2823cae63d75f58dc7435c4' '18a884a73344ff6eb74f63b49745e0f5' 'dc3eef2a624754e16805d72bbe488b67' 'dc0be354ce77ba2b89868fc29b942c43' '542e670e78d117657f93141e9689f54d' - 'f1870a9522c79e6b248fcbf81dec3280' 'abe887472a170bd1a8e6da6a7b7e93e4' '752488eb8bfb672ce0e4c924f7faf3d1' - 'dae4dfb638b11c8c79fb1424a60b762a' + 'ba351b92e69bcaf26a9bf80417b09c3c' '361bf81a6a117d61c3bc32dda91c4cb9' 'ce72aad1fc66c575f863d4bfbf65ce16' 'd03aedeeeda0f5e9c1eb437411c88477' '94ce8f1d5085c0db7b267db8c2e9a3ff' - 'eb879fee9603a05d5420d4ce8ed9e450') + '3db82bd7b9234fc941e4a53b464e0d46' + '9c2294ccfd5359583497a6b03d918a27' + '859a80ddb4c234506379c605114c1343' + '47e093e8cfe4b5b96602358e1f540832' + 'eb879fee9603a05d5420d4ce8ed9e450' + 'f1870a9522c79e6b248fcbf81dec3280') diff --git a/abs/core/LinHES-system/fix_myth_mount.py b/abs/core/LinHES-system/fix_myth_mount.py new file mode 100644 index 0000000..9f3cc54 --- /dev/null +++ b/abs/core/LinHES-system/fix_myth_mount.py @@ -0,0 +1,51 @@ +#!/usr/bin/python2 +import os +import sys +cmd="cp -f /etc/fstab /etc/fstab.backup.pre_acl" +os.system(cmd) +f = open('/etc/fstab', 'r') +fstab=f.readlines() +f.close() +mp='/data/mnt/d1' + +def check_fstab_mount(): + #first check if media/d1 is in list, if not add it. + newfstab=[] + mnt_in_fstab=False + for line in fstab: + split_line=line.split() + try: + if split_line[1] == mp : + print "found mountpoint if fstab" + mnt_in_fstab = True + break + except: pass + return mnt_in_fstab + +def add_mnt_to_fstab(): + newfstab=[] + for line in fstab: + newfstab.append(line) + split_line=line.split() + try: + if split_line[1] == "/myth": + split_line[1] = mp + new_line='\t'.join(split_line)+"\n" + newfstab.append(new_line) + except: + pass + + return newfstab + + + +if check_fstab_mount() == False: + print "I need to add it" + newfstab=add_mnt_to_fstab() + f = open('/tmp/fstab', 'w') + for i in newfstab: + f.write(i) + #f.write("\n") + f.close() + + diff --git a/abs/core/LinHES-system/fix_myth_mount.sh b/abs/core/LinHES-system/fix_myth_mount.sh new file mode 100644 index 0000000..2ed9783 --- /dev/null +++ b/abs/core/LinHES-system/fix_myth_mount.sh @@ -0,0 +1,22 @@ +#!/bin/sh +function checkmount { + mounted=1 + for i in `cat /proc/mounts | cut -d' ' -f2`; do + if [ "x$1" = "x$i" ]; then + mounted=0 + break + fi + + done + return $mounted +} + +checkmount $1 +rc=$? + +if [ $rc == 0 ] +then + echo "fs is mounted" +else + echo "fs is not mounted" +fi
\ No newline at end of file diff --git a/abs/core/LinHES-system/lh_system_all_host_update b/abs/core/LinHES-system/lh_system_all_host_update new file mode 100644 index 0000000..98fe668 --- /dev/null +++ b/abs/core/LinHES-system/lh_system_all_host_update @@ -0,0 +1,8 @@ +#!/bin/bash +results=`cat /data/srv/xymon/server/etc/hosts.cfg|grep -v ^#|awk '{print $2}' ` +for i in $results +do + echo "$i" + echo "-------------------------------------------" + sudo /usr/bin/func $i call pacman update_system $1 +done diff --git a/abs/core/LinHES-system/lh_system_backup_job b/abs/core/LinHES-system/lh_system_backup_job new file mode 100644 index 0000000..3abd5f9 --- /dev/null +++ b/abs/core/LinHES-system/lh_system_backup_job @@ -0,0 +1,64 @@ +#!/bin/bash +#process that uses this system backup script +# - myth_mtc.py +# - supplemental web, process.py backup +# +echo "#########################################################" +echo "Starting backup " +. /etc/profile +. /etc/systemconfig +BACKUPDIR=/myth/system_backups +DATE=`date +%F_%H-%M` +mkdir -p $BACKUPDIR/$DATE + +#backup db +pacman -Q mysql 2>/dev/null +if [ $? = 0 ] +then + mysqldump mythconverg > $BACKUPDIR/$DATE/mythconverg + mysqldump ncid > $BACKUPDIR/$DATE/ncid +fi + +#backup etc +cp -rp /etc $BACKUPDIR/$DATE/etc +cp -rp /var/lib/oss $BACKUPDIR/$DATE/oss + +#backup func keys +cp -rp /data/srv/func $BACKUPDIR/$DATA/func + +#make_zip file +cd $BACKUPDIR +tar -zcvf $BACKUPDIR/backup.$DATE.tgz $DATE + +if [ -d $BACKUPDIR/$DATE ] +then + rm -rf $BACKUPDIR/$DATE +fi + +if [ -f /data/srv/hobbit/server/ext/hbnotes.py ] +then + /data/srv/hobbit/server/ext/hbnotes.py + chown nobody:nobody /data/srv/httpd/htdocs/hobbit/notes/* 2> /dev/null >/dev/null + + +fi + + +#Remote copy +if [ x$RemoteBackup = x1 ] +then + localRemoteCheck=`echo $RemoteBackupDir | cut -d: -f1` + if [ x$localRemoteCheck = xdir ] + then + localRemotedir=`echo $RemoteBackupDir | cut -d: -f2` + cmd="cp $BACKUPDIR/backup.$DATE.tgz $localRemotedir" + echo "copying$BACKUPDIR/backup.$DATE.tgz to $localRemotedir " + else + /usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/backup.$DATE.tgz --remotepath $BACKUPDIR/backup.$DATE.tgz + + echo "copying$BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:/data/database_backup/" + fi + $cmd +fi + +echo "#########################################################" diff --git a/abs/core/LinHES-system/lh_system_host_update b/abs/core/LinHES-system/lh_system_host_update new file mode 100644 index 0000000..1a4d714 --- /dev/null +++ b/abs/core/LinHES-system/lh_system_host_update @@ -0,0 +1,56 @@ +#!/bin/bash +# Process that call this script +# func update +# supplemental web +echo "#####################################################" +echo "Starting update" +. /etc/profile + +if [ x$1 = x ] +then + . /etc/systemconfig +else +Hostupdateplan=$1 +fi + + +case $Hostupdateplan in + "Myth_only") + echo "Updating 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 + mythlist="$mythlist $mythl$postfix" + done + + pacman -Sy + list=`pacman -Qu $pkg |grep Targets` + for pkg in LinHES-config LinHES-system mythinstall $mythlist + do + echo $list|grep -q $pkg + if [ $? = 0 ] + then + echo "Updating $pkg" + pacman --noconfirm -S $pkg + else + echo "$pkg is up to date" + fi + done + ;; + "All") + echo "" + echo "Updating ALL packages" + pacman -Sy + pacman --noconfirm -Sfu + ;; + "None") + echo "" + echo "Updating NO packages" + ;; + *) echo "" + echo "Unknown $Hostupdateplan, skipping updates" + ;; +esac + + +echo "##################################################################################" diff --git a/abs/core/LinHES-system/lh_system_restore_job b/abs/core/LinHES-system/lh_system_restore_job new file mode 100644 index 0000000..9c66e2a --- /dev/null +++ b/abs/core/LinHES-system/lh_system_restore_job @@ -0,0 +1,76 @@ +#!/bin/bash +# This script is used to perform a quick restore of a database that was backed up via the nightly system backup +# The restore only does the database it does NOT restore system files (even if they are in the backup file) +# +BACKUPDIR=/myth/system_backups +backupfile=$1 + +function usage(){ + echo "------------------------------------------------------" + echo "This program will restore the database from a system backup." + + echo "Files are expected to be in the $BACKUPDIR" + echo "usage:" + echo "" + echo "lh_system_restore_job \$filename [yes]" + echo "" + echo "example: lh_system_restore_job backup.2011-12-22_15-34.tgz " + echo "" + echo "" + + echo "If the script is passed a second argument, it will not cleanup the the restore dir." + echo "------------------------------------------------------" + + exit 1 + } + + + +if [ x$backupfile = x ] +then + usage +fi + +. /etc/profile + +RESTOREDIR=$BACKUPDIR/restore +DIR=`echo $backupfile |cut -d. -f2` +CSQL="create database mythconverg;" +DSQL="drop database mythconverg; " +MYSQL="mysql -u mythtv -pmythtv" + + + +mkdir -p $RESTOREDIR +cp $BACKUPDIR/$backupfile $RESTOREDIR +cd $RESTOREDIR && tar -xf $backupfile && cd $DIR + +if [ -f mythconverg ] +then + #drop the db + $MYSQL -e "$DSQL" + #create the db + $MYSQL -e "$CSQL" + #restore the database_backup + echo "Restoring the database $DIR" + $MYSQL mythconverg < mythconverg + if [ $? = 0 ] + then + echo "Done" + else + echo "An error occured" + fi + else + echo "Couldn't file a file to restore" +fi + + +#cleanup +if [ x$2 = x ] +then + echo "Cleaning up the restore dir" + rm -rf $RESTOREDIR/$DIR + rm -f $RESTOREDIR/$backupfile +else + echo "Not doing a cleanup of $RESTOREDIR" +fi diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py index 1ed6c88..6fd53a7 100755 --- a/abs/core/LinHES-system/myth_mtc.py +++ b/abs/core/LinHES-system/myth_mtc.py @@ -10,18 +10,22 @@ import datetime,time -#try: -from MythTV import MythBE -mythtv = MythBE() -#except: -# mythtv = None +try: + from MythTV import MythBE + mythtv = MythBE() +except: + mythtv = None #print mythtv.db.getSetting( 'Theme', socket.gethostname()) def optimize(): - cursor = mythtv.db.cursor() - cursor.execute("SHOW tables") - result = cursor.fetchall() + try: + cursor = mythtv.db.cursor() + cursor.execute("SHOW tables") + result = cursor.fetchall() + except: + print "Problem getting tables from database" + return ops=["REPAIR","OPTIMIZE","ANALYZE"] for row in result: ctable=row[0] @@ -32,7 +36,10 @@ def optimize(): def upcoming_check(): - upcoming = mythtv.getUpcomingRecordings() + try: + upcoming = mythtv.getUpcomingRecordings() + except: + return True try: show=str(upcoming[0]) show=show.strip() @@ -52,10 +59,14 @@ def upcoming_check(): def schemalock_check(): - c = mythtv.db.cursor() - c.execute("select count(*) from schemalock") - results=c.fetchone() - schemalock=results[0] + try: + c = mythtv.db.cursor() + c.execute("select count(*) from schemalock") + results=c.fetchone() + schemalock=results[0] + except: + return True + if schemalock == 0: return True else: @@ -63,9 +74,12 @@ def schemalock_check(): return False def job_check(): - c = mythtv.db.cursor() - c.execute("select count(*) from jobqueue where status = 4") - results=c.fetchone() + try: + c = mythtv.db.cursor() + c.execute("select count(*) from jobqueue where status = 4") + results=c.fetchone() + except: + return True jobs= results[0] if jobs == 0 : return True @@ -75,9 +89,12 @@ def job_check(): def in_use(): - c = mythtv.db.cursor() - c.execute("select count(*) from inuseprograms") - results=c.fetchone() + try: + c = mythtv.db.cursor() + c.execute("select count(*) from inuseprograms") + results=c.fetchone() + except: + return True prginuse=results[0] if prginuse == 0 : return True @@ -119,10 +136,10 @@ def run_stuff(): optimize() print "Running backup" - os.system('/usr/LH/bin/backup_job') + os.system('/usr/LH/bin/lh_system_backup_job') print "Running system_update" - os.system('/usr/LH/bin/update_system') + os.system('/usr/LH/bin/lh_system_host_update') continue_loop=False else: continue_loop=True diff --git a/abs/core/LinHES-system/set_windowmanager.sh b/abs/core/LinHES-system/set_windowmanager.sh index 5c1150d..3d0cdb2 100644 --- a/abs/core/LinHES-system/set_windowmanager.sh +++ b/abs/core/LinHES-system/set_windowmanager.sh @@ -20,7 +20,7 @@ if [ x$windowmanager = x ] then echo echo "Usage: " - echo " set_windowmanger.sh WINDOWMANAGER STARTUP_STYLE" + echo " set_windowmanager.sh WINDOWMANAGER STARTUP_STYLE" echo echo "Valid WINDOWMANAGER options are:" echo " default" @@ -36,9 +36,11 @@ then echo "If STARTUP_STYLE is not given, then the default will be used." echo echo "Example: " - echo " set_windowmanger.sh enlightenment mythvantage" + echo " set_windowmanager.sh enlightenment mythvantage" echo - + echo " " + echo "if using enlightenment or windowmaker, please ensure that the alt_wm group is installed" + echo "pacman -Sy alt_wm" exit 0 fi |