diff options
Diffstat (limited to 'abs/core/LinHES-system')
30 files changed, 1748 insertions, 323 deletions
diff --git a/abs/core/LinHES-system/LinHES-session b/abs/core/LinHES-system/LinHES-session index ea22344..0c61c6f 100755 --- a/abs/core/LinHES-system/LinHES-session +++ b/abs/core/LinHES-system/LinHES-session @@ -13,6 +13,9 @@ xset -dpms s off export MALLOC_CHECK_=0 +MYTH_ARGS="-d --syslog local6" +[ -f /etc/conf.d/mythfrontend ] && . /etc/conf.d/mythfrontend + # # Run any scripting that applies to special hardware. These brand-specific commands that run @@ -46,25 +49,25 @@ export MALLOC_CHECK_=0 # font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*" # } # -function delay_osd(){ - if [ x$STARTUP_STYLE = xmythvantage ] - then - cmd="ps -ef | grep -v grep | grep -q xmsg.py" - else - cmd="ps -ef | grep -v grep | grep -q osd_cat" - fi - - eval $cmd - - rc=$? - while [ $rc = 0 ] - do - eval $cmd - rc=$? - done - - - } +# function delay_osd(){ +# if [ x$STARTUP_STYLE = xenhanced ] +# then +# cmd="ps -ef | grep -v grep | grep -q xmsg.py" +# else +# cmd="ps -ef | grep -v grep | grep -q osd_cat" +# fi +# +# eval $cmd +# +# rc=$? +# while [ $rc = 0 ] +# do +# eval $cmd +# rc=$? +# done +# +# +# } # # function msg_osd(){ # 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 @@ -75,13 +78,8 @@ function delay_osd(){ # } function msg(){ -# if [ x$STARTUP_STYLE = xmythvantage ] -# then -# msg_pyosd "$1" -# else -# msg_osd "$1" -# fi - /usr/LH/bin/lh_message.sh "$1" + #/usr/LH/bin/lh_message.sh "$1" + /usr/LH/bin/msg_client.py --msg "$1" } @@ -94,7 +92,7 @@ function unclutter(){ jitter=200 fi - /usr/X11R6/bin/unclutter -root -idle $idle -jitter $jitter -noevents & + /usr/bin/unclutter -root -idle $idle -jitter $jitter -noevents & } function keylaunch(){ @@ -180,12 +178,11 @@ function show_help_tip(){ if [ x$ShowTips = "x1" ] then - msg "Alt+h for help" & + msg "Alt+h for help" fi } function notify_scan(){ - delay_osd if [ -e /tmp/scan_report ] then msg "\nNew storage found. \nRun add_storage.py for details" @@ -193,6 +190,17 @@ function notify_scan(){ } +function auto_start(){ + asdir="/etc/X11/autostart" + for i in `ls $asdir/*` + do + if [ -x $i ] + then + echo "Starting $i" + $i & + fi + done + } function update_apple_trailers(){ #update apple trailers @@ -204,7 +212,7 @@ function update_apple_trailers(){ function first_configure(){ - if [ x$STARTUP_STYLE = xmythvantage ] + if [ x$STARTUP_STYLE = xenhanced ] then first_configure_mv else @@ -231,7 +239,6 @@ function first_configure_default(){ fi 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 chown -R mythtv.mythtv /home/mythtv @@ -260,6 +267,7 @@ function first_configure_mv(){ then /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." + run_wmctrl & /usr/bin/taskset -c 0 /usr/bin/mythtv-setup /usr/MythVantage/bin/backend_control.sh start BE 127.0.0.1 fi @@ -280,17 +288,17 @@ function start_myth() { then STARTCMD="/usr/bin/mythfrontend -d -l /var/log/mythtv/mythfrontend.log" else - STARTCMD="/usr/bin/mythfrontend -d --syslog local6" + STARTCMD="/usr/bin/mythfrontend $MYTH_ARGS" fi fi echo "=====================================================================" echo "Starting $STARTCMD" - firstboot.sh & + #firstboot.sh & #continue on with starting mythtv - if [ x$STARTUP_STYLE = xmythvantage ] + if [ x$STARTUP_STYLE = xenhanced ] then start_myth_mv else @@ -299,6 +307,28 @@ function start_myth() { } +function run_wmctrl(){ + done="False" + for i in `seq 60` + do + for name in "MythTV Frontend" "MythTV Setup" "mythwelcome" + do + xwininfo -name "$name" + rc=$? + if [ $rc = 0 ] + then + wmctrl -r "$name" -b remove,fullscreen + done="True" + fi + if [ $done = "True" ] + then + break + fi + done + sleep 5 + done + +} function run_myth(){ if [ -f /tmp/nomfe ] @@ -315,8 +345,10 @@ function run_myth(){ killall -9 irexec /usr/bin/irexec -d - if [ x$STARTUP_STYLE = xmythvantage ] + if [ x$STARTUP_STYLE = xenhanced ] then + + run_wmctrl & $STARTCMD 2>&1 else $STARTCMD 2>&1 & @@ -340,10 +372,10 @@ function set_background() { echo "Setting the background" - } +} -if [ x$WM = "x" ] +if [ x"$WM" = "x" ] then # fluxbox > /var/log/fluxbox.log 2>&1 WM=fluxbox @@ -355,24 +387,26 @@ $WM & pid=$! mouse_move keylaunch -set_background +#set_background unclutter load_nvidia_settings run_tilda start_screensaver -show_help_tip notify_scan & +auto_start & update_apple_trailers first_configure +show_help_tip start_myth # wait for the windowmanger #This will make the session wait on the WM to exit. -if [ x$STARTUP_STYLE != xmythvantage ] +if [ x$STARTUP_STYLE != xenhanced ] then wait $pid fi +wmctrl -r "MythTV Frontend" -b remove,fullscreen diff --git a/abs/core/LinHES-system/LinHES-system.install b/abs/core/LinHES-system/LinHES-system.install new file mode 100644 index 0000000..f2185cd --- /dev/null +++ b/abs/core/LinHES-system/LinHES-system.install @@ -0,0 +1,12 @@ +## arg 1: the new package version +post_install() { + /usr/LH/bin/misc_status_config.py +} + +## arg 1: the new package version +## arg 2: the old package version +post_upgrade() { + /usr/LH/bin/misc_status_config.py +} + +# vim:set ts=2 sw=2 et: diff --git a/abs/core/LinHES-system/LinHES.install b/abs/core/LinHES-system/LinHES.install deleted file mode 100644 index 7ae0616..0000000 --- a/abs/core/LinHES-system/LinHES.install +++ /dev/null @@ -1,99 +0,0 @@ -# This is a default template for a post-install scriptlet. You can -# remove any functions you don't need (and this header). - -# arg 1: the new package version -pre_install() { -/bin/true -} - -# arg 1: the new package version -post_install() { -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 ] - then - 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" - - -for i in "$LINE" "$LINE1" "$LINE2" "$LINE3" "$LINE4" "$LINE5" "$LINE7" "$LINE8" "$LINE9" "$LINE10" "$LINE11" "$LINE12" "$LINE13" "$LINE14" "$LINE15" "$LINE16" -do - cp /etc/sudoers /etc/sudoers.bak - grep -q "$i" /etc/sudoers - if [ $? != 0 ] - then - echo "$i" >> /etc/sudoers - visudo -cf /etc/sudoers - if [ ! $? = 0 ] - then - cp /etc/sudoers.bak /etc/sudoers - echo $i - echo "Error adding files" - exit 1 - fi - fi -done - -REALTIME="session required pam_limits.so" -grep -q "pam_limits.so" /etc/pam.d/su - if [ $? != 0 ] - then - echo "$REALTIME" >> /etc/pam.d/su - - fi - - -# Add db entry for misc status in MythWeb -/usr/LH/bin/misc_status_config.py - - -} - -# arg 1: the new package version -# arg 2: the old package version -pre_upgrade() { - if [ -e /etc/cron.daily/backup_cron ] - then - rm -f /etc/cron.daily/backup_cron - fi - if [ -e /etc/cron.daily/xupdate_system_cron ] - then - rm -f /etc/cron.daily/xupdate_system_cron - fi - - if [ -e /etc/cron.daily/myth_mtc.py ] - then - rm -f /etc/cron.daily/myth_mtc.py - fi - - -} - -# arg 1: the new package version -# arg 2: the old package version -post_upgrade() { - post_install -} - -# arg 1: the old package version -pre_remove() { - /bin/true -} - -# arg 1: the old package version -post_remove() { - /bin/true -} - -op=$1 -shift -$op $* diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 3a82b87..f1fe894 100644..100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,35 +1,43 @@ pkgname=LinHES-system pkgver=2 -pkgrel=62 -arch=('i686') +pkgrel=118 +arch=('i686' 'x86_64') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin -install=LinHES.install +install=system.install pkgdesc="scripts and things related to having an automated system" -depends=(linhes-sounds xdotool fluxbox tilda keylaunch python_aosd 'linhes-scripts>=7-24' 'runit-scripts>=2.1.1-43' 'udisks' 'LinHES-config>=2.3-59') +depends=(linhes-sounds xdotool tilda keylaunch python_aosd 'linhes-scripts>=7-24' 'udisks' 'LinHES-config>=2.3-59' 'sudo' 'python2-dbus' 'unclutter' 'wmctrl' 'archlinux-xdg-menu') 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 + load-modules-mythvantage.sh unclutter-toggle.sh tvterm.sh mythfrontend-start set_windowmanager.sh myth_status.py myth_status.sh - xmsg.py install_supplemental_service.sh + install_supplemental_service.sh lh_system_backup_job lh_system_restore_job lh_system_host_update lh_system_all_host_update add_storage.py diskspace.sh - cacheclean lh_message.sh switch_web.sh + cacheclean lh_backend_control.sh switch_web.sh + create_media_dirs.sh + msg_client.py msg_daemon.py gen_is_xml.py gen_lib_xml.py misc_recent_recordings.pl misc_status_config.py misc_status_info.sh misc_upcoming_recordings.pl - misc_which_recorder.pl" + misc_which_recorder.pl + change_channel.sh change_channel_wrapper.sh" + +source=(LinHES-session + LinHES-profile.sh $binfiles + alsa-base myth_mtc.lr + diskspace cacheclean.cron + readme_is_xml add_storage.readme + system-sudo.rules ) -source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr - diskspace smolt.cron cacheclean.cron) build() { cd $startdir/src install -m755 -D LinHES-session $startdir/pkg/etc/X11/Sessions/LinHES @@ -39,7 +47,7 @@ build() { do item=$i install -m755 -D $item $MVDIR/bin/$item - echo $item + echo "installing $item to $MVDIR" done cd $startdir/bin @@ -47,49 +55,67 @@ build() { do item=$i install -m755 -D $item $MVDIR/bin/$item - echo $item - done + echo "bin stuff: $item" + done install -m644 -D $startdir/src/alsa-base $startdir/pkg/etc/modprobe.d/alsa-base.conf - install -m755 -D $startdir/src/smolt.cron $startdir/pkg/etc/cron.weekly/smolt.cron + install -m644 -D $startdir/src/readme_is_xml $startdir/pkg/etc/gen_is_xml.d/readme_is_xml + install -m644 -D $startdir/src/readme_is_xml $startdir/pkg/etc/gen_lib_xml.d/readme_gen_xml + install -m644 -D $startdir/src/add_storage.readme $startdir/pkg/etc/storage.d/readme + # install -m755 -D $startdir/src/smolt.cron $startdir/pkg/etc/cron.weekly/smolt.cron install -m755 -D $startdir/src/cacheclean.cron $startdir/pkg/etc/cron.weekly/cacheclean.cron install -m755 -D $startdir/src/diskspace $startdir/pkg/etc/cron.tenminutes/diskspace - mkdir $startdir/pkg/etc/logrotate.d - cp $startdir/myth_mtc.lr $startdir/pkg/etc/logrotate.d + install -m644 -D $startdir/src/myth_mtc.lr $startdir/pkg/etc/logrotate.d/myth_mtc + + + #sudo rules + mkdir -p $startdir/pkg/etc/sudoers.d/ + chmod 750 $startdir/pkg/etc/sudoers.d/ + chown -R root:root $startdir/pkg/etc/sudoers.d + install -o root -g root -m 0750 $startdir/src/system-sudo.rules $startdir/pkg/etc/sudoers.d/system_sudo + + } -md5sums=('5da7d6eed87d4a65f6a48e22fd8b1cce' +md5sums=('5bd4938cf41b63787aa4cdfd76423e09' '5881bdb43d578ec3a79d1f77ea58a3db' 'a875ee97f86e46f34a741c2bc455f894' '76b2637cac0452b3acdbeeb4e8a5474b' - 'd1f27cb422010077c841376526fe46ea' - '2ef9f945e034119f77d9b6beb17e4fa5' + '781c977f8872543f033dad2caaf0458e' + '6f5b757524d905b5d2420519a88edc93' '4b4585ccba30595cf958d202997c57f7' - 'cbe4cba14fa9d01a62e2196edc1bd98b' 'dc3eef2a624754e16805d72bbe488b67' 'dc0be354ce77ba2b89868fc29b942c43' '542e670e78d117657f93141e9689f54d' '41951459ea9d2b0567be521b67e6285a' - 'ba351b92e69bcaf26a9bf80417b09c3c' + '659c0a55b0b375c48fcd751252dd2102' '309638acf596ce3c790aa2bf5c7c9880' '962a3e9eaba2d1466251b7ab0956705d' - 'd03aedeeeda0f5e9c1eb437411c88477' - '94ce8f1d5085c0db7b267db8c2e9a3ff' - '16a2a3347961517fe7d95a2956a091a6' - '9c2294ccfd5359583497a6b03d918a27' - '859a80ddb4c234506379c605114c1343' + '1758aed160de64abfafb28a3a8f3390e' + '5510042c80283522f480e95d6242495c' + 'ceec78815ed01af733cdbca14cb0942b' + '1be1d3dfc83f828eede93055713882ae' '47e093e8cfe4b5b96602358e1f540832' - '6faeba0aeb38e772121f751cabda8683' - '68e3e87571f3b0fa4a48a10df50dc220' - '9603b0ca6e090eff31e76482a3c335e7' - 'b798ee0796d1b760a2998f90eb8ce9cc' + '9f08fb2e821297841f1849c6221b87cb' + 'b9b0a8370f46f0b5e144a66897e8eefb' + '6519d209e151cdc39ae7e1091d189c3e' + '8f474e019d5fcb775497aca355d61b0b' '4a3cd8f9b33b2b86fdba47a8f1fa2859' + '4d5a2441fe681c85986c5626c2944a3d' + '0e76cd8f320a852a162931450a1fb8b7' + '55b33e6a08eeea2a5280da0100f2c33c' + 'ea315f41dcd6c978e546c95fc05546cf' + 'ac61cc460d9e97ba1f5ef69e92cdfbe5' '06a628469051237943b7c874f2e29b8a' '54ebcc024db2e0ebe8121305d8926767' '45f46d1f9193c8dde18e56369ec29a1e' 'a8edbe7bc37e9932e8749d9f5f89c16f' '116b0f62ed4e8dd6e437930deeb6e49e' + '0ca244610ab1f68f70a8af0ddefee277' + 'bacc813b48bafcc6fe906e5969930501' 'eb879fee9603a05d5420d4ce8ed9e450' - 'f1870a9522c79e6b248fcbf81dec3280' + '6782771960c495aeb597893f37d1e5ee' '84492954db16740f949d795b74383189' - 'abe887472a170bd1a8e6da6a7b7e93e4' - '02c810c2f47b7c4495fdacaf54189473') + '02c810c2f47b7c4495fdacaf54189473' + '1e2ca4dd872a50df6b70528e06df558a' + 'da432d68962e109e09beb2b71c8c8571' + '366ccb097d1c221389709485c3b2d159') diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 28d679c..93a67c7 100644 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -11,40 +11,55 @@ import pickle import commands import sys,os import random, string +import ConfigParser +from ConfigParser import SafeConfigParser +import glob + from MythTV import MythDB, MythBE, Recorded, MythError from socket import timeout, gethostname +storage_dir = "/etc/storage.d" +pickle_file = "%s/storage.pkl" %storage_dir + -pickle_file="/usr/LH/etc/storage.pkl" +SG_MAP_BE={ 'Default' :'media/tv', +'LiveTV' :'media/tv/live', +'DB Backups' :'backup/mythtv_backups/'} +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', + } -SG_MAP={ 'Default' :'tv', - 'LiveTV' :'live_tv', - 'Videos' :'video', - 'Trailers' :'video/trailers', - 'Coverart' :'video/converart', - 'Fanart' :'video/fanart', - 'Banners' :'video/banners', - 'Screenshots':'video/screenshots', - 'DB Backups' :'db_backups'} -FS_LIST=[] -for key in SG_MAP.keys(): - FS_LIST.append(SG_MAP[key]) +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]) class disk_device: - def __init__(self,device): + def __init__(self,device,storage_dir): device_obj = bus.get_object("org.freedesktop.UDisks", device) device_props = dbus.Interface(device_obj, dbus.PROPERTIES_IFACE) + self.storage_dir = storage_dir + self.top_mount_dir = "/data/storage" + self.config = ConfigParser.RawConfigParser() self.fs_map = self.get_fsmap() self.is_device = self.get_is_device(device_props) self.vendor = self.get_vendor(device_props) self.model = self.get_model(device_props) - self.mount_path = self.get_mounts(device_props) + self.mmount = False + self.f = self.get_mounts(device_props) self.is_mounted = self.get_is_mounted(device_props) self.parition_size = self.get_partition_size(device_props) @@ -57,7 +72,18 @@ class disk_device: self.device_file_path = self.get_device_file_path(device_props) self.block_partition="%s1" %self.block_path self.in_use = self.get_in_use() + self.uuid='' + self.new_mount_point='' + self.disk_num='' + + def set_partition(self,partition): + self.block_partition = "%s%s" %(self.block_path,partition) + def set_mmount(self,flag): + self.mmount = flag + + def set_disk_num(self,num): + self.disk_num=num def get_is_device(self,device_props): return device_props.Get('org.freedesktop.UDisks.Device', "DeviceIsDrive") @@ -74,6 +100,11 @@ class disk_device: def get_is_mounted(self,device_props): return device_props.Get('org.freedesktop.UDisks.Device', "DeviceIsMounted") + def get_name(self): + filename="%s_%s" %(self.model.replace(' ',''), + self.serial_number.replace(' ','')) + return filename + def get_in_use(self): in_use = False for i in self.fs_map: @@ -82,7 +113,6 @@ class disk_device: break return in_use - def get_partition_size(self,device_props): return device_props.Get('org.freedesktop.UDisks.Device', "PartitionSize") @@ -150,8 +180,8 @@ class disk_device: return fs_map def find_fstype(self,moutpoint): - fstype="ext3" - mp=['/myth', '/data/media'] + fstype="xfs" + mp=['/myth', '/data/storage/disk0'] for i in self.fs_map: if i[1] in mp: fstype = i[2] @@ -166,7 +196,10 @@ class disk_device: new_fstype = self.find_fstype(current_media_mount) #do format - cmd = "mkfs -t %s %s " %(new_fstype,self.block_partition) + if new_fstype == "xfs": + cmd = "mkfs -t %s -f %s " %(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) runcmd(cmd) return @@ -181,7 +214,7 @@ class disk_device: if uuid == '': print "Could not find a UUID for device: %s" %partition sys.exit(1) - + self.uuid = uuid.strip() return uuid.strip() def read_fstab(self): @@ -191,7 +224,7 @@ class disk_device: return fstab def find_options_type(self,fstab): - mp=['/myth', '/data/media'] + mp=['/myth', '/data/storage/disk0'] for i in fstab: split_line=i.split() try: @@ -206,24 +239,30 @@ class disk_device: return options,i - def add_fstab(self): + def add_fstab(self,bind=False): new_fstab_list=['UUID=', 'mount_point', 'auto', 'defaults', '0', '1'] fstab=self.read_fstab() + #determine mount_path - self.new_mount_point="/data/media/%s_%s" %(self.model.replace(' ',''),self.serial_number.replace(' ','')) + self.new_mount_point="%s/%s_%s" %(self.top_mount_dir,self.model.replace(' ',''),self.serial_number.replace(' ','')) + if bind: + new_fstab_list=["/data/storage/disk0" , self.new_mount_point , "none" , "rw,bind", '0', '0'] + uuid=self.find_uuid(self.block_partition) + else: #determine options - new_options = self.find_options_type(fstab)[0] - #find blkid - self.block_partition="%s1" %self.block_path - uuid=self.find_uuid(self.block_partition) + new_options = self.find_options_type(fstab)[0] + + #find blkid + #self.block_partition="%s1" %self.block_path + uuid=self.find_uuid(self.block_partition) - #construct new line - new_fstab_list[0]="UUID=%s" %uuid - new_fstab_list[1]=self.new_mount_point - new_fstab_list[3]=new_options + #construct new line + new_fstab_list[0]="UUID=%s" %uuid + new_fstab_list[1]=self.new_mount_point + new_fstab_list[3]=new_options new_fstab_line='\t'.join(new_fstab_list) new_fstab_line="%s\n" %new_fstab_line @@ -238,13 +277,14 @@ class disk_device: f.close() return - def mount_disk(self): + def mount_disk(self,no_mount=False): try: os.stat(self.new_mount_point) except: os.makedirs(self.new_mount_point) - cmd = "mount %s" %self.new_mount_point - runcmd(cmd) + if no_mount == False: + cmd = "mount %s" %self.new_mount_point + runcmd(cmd) return def mkdirs(self,FS_LIST): @@ -260,25 +300,77 @@ class disk_device: cmd="chmod -R 775 /%s" %self.new_mount_point runcmd(cmd) - def add_sg(self,DB,host,SG_MAP): + def add_sg(self,DB,host,SG_MAP,weight='0',install_call=False): print " Adding to storage groups" + sgweight=int(weight) for key in SG_MAP.iterkeys(): #print key," : ", SG_MAP[key] - #try: - gn=key - hn=host - dn="%s/%s" %(self.new_mount_point,SG_MAP[key]) - #print dn - #print gn - #print hn + gn=key + hn=host + dn="%s/%s" %(self.new_mount_point,SG_MAP[key]) + #print dn + #print gn + #print hn + if install_call == True : + print "Will write SG for stuff after the fact" + else: 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) except: - print " Error inserting %s into storage groups" %dn + print " *Error inserting %s into storage groups" %dn + + if sgweight > 0: + try: + #("SGweightPerDir:server2:/mnt/video", 99, "server2"); + sgw="SGweightPerDir:%s:%s" %(hn,dn) + #print sgw + #print sgweight + #print hn + + 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) + return + def write_config(self): + print " Writing out 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','shareable','True') + self.config.set('storage','mmount',self.mmount) + self.config.set('storage','disk_num',self.disk_num) + + + filename="%s_%s.conf" %(self.model.replace(' ',''), + self.serial_number.replace(' ','')) + + configfile="/etc/storage.d/%s" %filename + print " %s" %configfile + with open(configfile, 'wb') as configfile: + self.config.write(configfile) + return + + def symlink_disk(self): + print " Creating symlink for disk number" + 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) + + + +#end of class def runcmd(cmd): @@ -300,7 +392,7 @@ def scan_system(): ud_manager = dbus.Interface(ud_manager_obj, 'org.freedesktop.UDisks') current_drive_list=[] for dev in ud_manager.EnumerateDevices(): - drive = disk_device(dev) + drive = disk_device(dev,storage_dir) if drive.is_device and drive.device_size > 5000 and not drive.is_optical : current_drive_list.append(drive) @@ -333,7 +425,7 @@ def search_for_match(system_drive,known_drive_list): y_drive_hash = "%s_%s_%s" %(y.model,y.parition_size,y.device_file_path) if system_drive_hash == y_drive_hash : match_drive = True - print "No serial number was found, matched using hash method: %s" %system_drive.model + print "\n* No serial number was found, matched using hash method: %s" %system_drive.model break elif y.serial_number == system_drive.serial_number: @@ -347,7 +439,7 @@ def search_for_match(system_drive,known_drive_list): def prompt_to_add(current_drive): loop = True while loop: - str1 = raw_input(" Adding the drive will remove all contents on the drive. \n\nDo you wish enable this drive for MythTV storage(Y/N)?:") + str1 = raw_input("\n Adding the drive will remove all contents on the drive. \n Do you wish enable this drive for MythTV storage(Y/N)?:") if str1 in ['Y','N','y','n']: loop = False @@ -359,18 +451,42 @@ def prompt_to_add(current_drive): rc = False return rc +def prompt_to_continue(): + loop = True + #while loop: + str1 = raw_input("\n Ready to start, press Y to continue, anything else to abort:") + + #if str1 in ['Y','N','y','n']: + # loop = False + # break + #print "\n" + if str1 == 'Y' or str1 == 'y': + rc = True + else: + rc = False + return rc + + + def remove_pickle(): try: - print "Resetting list of known drives." - + print "* Resetting list of known drives." os.remove(pickle_file) except: pass - +def last_disk_num(): + parser = SafeConfigParser() + num_list = [] + for conf_file in glob.glob('%s/*.conf' %storage_dir): + parser.read(conf_file) + disk_num = parser.get('storage', 'disk_num') + num_list.append(int(disk_num)) + num_list.sort() + return num_list[-1] #-------------------------------------------- -def main(scan_only): +def main(scan_only, destruction, no_mount, install_call , dir_fe_only): global bus bus = dbus.SystemBus() @@ -378,7 +494,7 @@ def main(scan_only): known_drive_list=[] known_drive_list = read_known_list() process_list=[] - + no_process_list=[] for i in system_drive_list: @@ -390,23 +506,29 @@ def main(scan_only): #print "--" if search_for_match(i,known_drive_list) or i.in_use : - print " Storage is already in use or previously skipped: %s location: %s size: %s" %(i.model,i.block_path,i.device_size) + print "\n" + print " Storage is already in use or previously skipped:%s" %i.model + print " location: %s" %i.block_path + print " size: %s" %i.device_size continue else: - print "\n" if not scan_only: print "\n" print "-------------------------------------------------------------" - - print "Found new hard drive: %s location: %s size: %s \n" %(i.model,i.block_path,i.device_size) + print " Found new hard drive: %s" %i.model + print " location: %s" %i.block_path + print " size: %s " %i.device_size if prompt_to_add(i) : - print "\nDisk will be added to the storage pool!" + print "\n Disk will be added to the storage pool!" process_list.append(i) + else: + no_process_list.append(i) else: process_list.append(i) - + print " End of scan" + print "---------------------------------------" if scan_only: if len(process_list) > 0: f = open('/tmp/scan_report', 'w') @@ -416,31 +538,309 @@ def main(scan_only): f.close() sys.exit(0) + for i in no_process_list: + system_drive_list.append(i) + if len(process_list) > 0: DB = MythDB() host=gethostname() + for y in process_list: + system_drive_list.remove(y) + write_known_drive_list(system_drive_list) else: print "\nDid not find any new storage to add.\n" + write_known_drive_list(system_drive_list) #BE = MythBE(db=DB) #save new list to disk_device - write_known_drive_list(system_drive_list) + #write_known_drive_list(system_drive_list) + #disk_num = last_disk_num() + + + if len(process_list) > 0: + print "\n Adding storage: \n" + if prompt_to_continue() == True: + write_known_drive_list(system_drive_list) + disk_num = last_disk_num() + for i in process_list: + print " Drive: %s" %(i.get_name()) + disk_num = disk_num + 1 + if destruction == True: + i.partition_disk() + i.format_disk() + i.add_fstab() + i.mount_disk(no_mount) + if destruction == True: + if dir_fe_only != True: + i.mkdirs(FS_LIST_BE) + i.mkdirs(FS_LIST_FE) + i.set_disk_num(disk_num) + i.write_config() + system_drive_list.append(i) + write_known_drive_list(system_drive_list) + + i.symlink_disk() + #always create the FE groups(video)..do not need to create Be + if dir_fe_only != True: + i.add_sg(DB,host,SG_MAP_BE) + + i.add_sg(DB,host,SG_MAP_FE) + + print "-----" + cmd = "systemconfig.py -m fileshare" + runcmd(cmd) + #i.add_sg(DB,host,SG_MAP) + +def myth_main(no_mount,install_call,dir_fe_only): + global bus + bus = dbus.SystemBus() + #search for root + f = open('/etc/fstab', 'r') + fstab=f.readlines() + f.close() + for i in fstab: + split_line=i.split() + if not split_line: + continue + + try: + if split_line[1] == "/" : + uuid_device = split_line[0] + break + except: + print "Couldn't find / in fstab" + sys.exit(1) + if uuid_device.startswith("UUID"): + uuid_device = uuid_device.split("=")[1] + cmd = "blkid -U %s" %uuid_device + device = runcmd(cmd)[1] + else: + device = uuid_device.strip() + #should have something like /dev/sda1 + #remove all the digits + device = ''.join([letter for letter in device if not letter.isdigit()]) + + + system_drive_list = scan_system() + for i in system_drive_list: + if i.block_path == device: + break + else: + print "Could'nt find root device in block list" + sys.exit(1) + if not install_call == True: + DB = MythDB() + host=gethostname() + else: + DB = None + host=gethostname() + + + print " Drive: %s" %(i.get_name()) + i.set_mmount(True) + i.set_partition("7") + i.set_disk_num(0) + i.add_fstab(True) + #if not install_call: + i.mount_disk(no_mount) + i.write_config() + #always create the FE groups(video)..do not need to create Be + if dir_fe_only != True: + i.add_sg(DB,host,SG_MAP_BE,'99',install_call) - for i in process_list: - i.partition_disk() - i.format_disk() - i.add_fstab() - i.mount_disk() - i.mkdirs(FS_LIST) - i.add_sg(DB,host,SG_MAP) + i.add_sg(DB,host,SG_MAP_FE,'99',install_call) + + i.symlink() + cmd = "systemconfig.py -m fileshare" + runcmd(cmd) + +class reconstruct_path: + def __init__(self,conf_file): + self.conf_file = conf_file + parser = SafeConfigParser() + parser.read(self.conf_file) + + + self.uuid = parser.get('storage', 'uuid') + self.mount_point = parser.get('storage', 'mountpoint') + self.shareable = parser.get('storage', 'shareable') + self.myth_mount = parser.get('storage', 'mmount') + self.bind = self.myth_mount + self.disk_num = parser.get('storage', 'disk_num') + self.top_mount_dir = os.path.dirname(self.mount_point) + + def get_conf(self): + return self.conf_file + + def get_uuid(self): + return self.uuid + + def get_mount_point(self): + return self.mount_point + + def get_shareable(self): + return self.shareable + + def get_is_myth_mount(self): + return self.myth_mount + + def get_disk_num(self): + return self.disk_num + + def create_mount_point(self): + try: + os.stat(self.mount_point) + except: + os.makedirs(self.mount_point) + + def find_options_type(self,fstab): + mp=['/myth', '/data/storage/disk0'] + for i in fstab: + split_line=i.split() + try: + if split_line[1] in mp: + options = split_line[3] + break + else: + options = "defaults" + mount_point = i + except: + options = "defaults" + return options,i + + def read_fstab(self): + f = open('/etc/fstab', 'r') + fstab=f.readlines() + f.close() + return fstab + + def check_in_fstab(self,fstab,check_path): + + for line in fstab: + if line.find(check_path) > -1: + return True + return False + + def append_fstab(self,line): + new_fstab_line='\t'.join(line) + new_fstab_line="%s\n" %new_fstab_line + + f = open('/etc/fstab', 'a') + #f = open('/tmp/fstab', 'a') + f.write(new_fstab_line) + f.write("\n") + f.close() + + def symlink(self): + print " Creating symlink" + if not os.path.exists("/myth"): + cmd = "ln -s %s/media /myth " %(self.mount_point) + runcmd(cmd) + else: + print " Skipping symlink, path already present" + + def symlink_disk(self): + print " Creating symlink for disk number" + 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'] + 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" + else: + print " Adding storage to fstab" + if self.bind == "True" : + print " Bind mount" + new_fstab_list=["/data/storage/disk0" , self.mount_point , "none" , "rw,bind", '0', '0'] + if self.check_in_fstab(fstab,self.mount_point) == False: + self.append_fstab(new_fstab_list) + else: + print " Found bind storage in fstab, will not add it" + + else: + #construct new line + new_options = self.find_options_type(fstab)[0] + new_fstab_list[0]="UUID=%s" %self.uuid + new_fstab_list[1]=self.mount_point + new_fstab_list[3]=new_options + self.append_fstab(new_fstab_list) + + def mount_disk(self,no_mount=False): + try: + os.stat(self.mount_point) + except: + os.makedirs(self.mount_point) + if no_mount == False : + cmd = "mount %s" %self.mount_point + runcmd(cmd) + return + +def reconstruct_mounts(no_mount): + print "Recreating devices based on 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 cf.get_shareable() + #print cf.get_is_myth_mount() + #print cf.get_disk_num() + + cf.create_mount_point() + cf.add_fstab() + cf.symlink_disk() + cf.mount_disk(no_mount) + + pass + + +def usage(): + help='''\n + Add storage is designed to find and setup new disks for mythtv usage. + It's a powerfull that could destroy data if not used correctly, so please be careful. + Normal operations 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 + --new_init : Erase the list of new disks and rescan. + --report : will scan the disks and print out if it found new storage. + --fe_only : Will only create the storage group dir for videos..excludes tv + ''' + print help + sys.exit(0) if __name__ == "__main__": scan_only = False + myth_mount = False + no_mount = False + destruction = True + install_call = False + dir_fe_only = False + reconstruct = False try: os.remove("/tmp/scan_report") except: @@ -449,13 +849,36 @@ if __name__ == "__main__": if not os.geteuid()==0: sys.exit("\nRoot access is required to run this program\n") + if "--help" in sys.argv: + usage() + + if "--install_call" in sys.argv: + install_call = True + + if "--no_mount" in sys.argv : + no_mount = True + + if "--no_destruction" in sys.argv: + destruction = False + if "--new_init" in sys.argv : remove_pickle() if "--report" in sys.argv : scan_only = True - main(scan_only) + if "--fe_only" in sys.argv: + dir_fe_only = True + + if "--reconstruct" in sys.argv: + reconstruct = True + + if "--double_myth" in sys.argv: + myth_main(no_mount,install_call,dir_fe_only) + elif reconstruct == True: + reconstruct_mounts(no_mount) + else: + main(scan_only,destruction,no_mount, install_call, dir_fe_only) diff --git a/abs/core/LinHES-system/add_storage.readme b/abs/core/LinHES-system/add_storage.readme new file mode 100644 index 0000000..226b14d --- /dev/null +++ b/abs/core/LinHES-system/add_storage.readme @@ -0,0 +1,3 @@ +Files here are autogenerated by add_storage.py. +They will be used by systemconfig to generate nfs,smb and mountpoint recovery. + diff --git a/abs/core/LinHES-system/cacheclean b/abs/core/LinHES-system/cacheclean index d32d16b..cfc8d58 100755 --- a/abs/core/LinHES-system/cacheclean +++ b/abs/core/LinHES-system/cacheclean @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """cacheclean - a simple python script to clean up the /data/var/cache/pacman/pkg directory. More versatile than 'pacman -Sc' in that you can select how many old versions to keep. diff --git a/abs/core/LinHES-system/change_channel.sh b/abs/core/LinHES-system/change_channel.sh new file mode 100755 index 0000000..3337785 --- /dev/null +++ b/abs/core/LinHES-system/change_channel.sh @@ -0,0 +1,166 @@ +#!/bin/bash +# Maintained by CommandIR Support mini at commandir.com - Comments / Suggestions Welcome. +# Modified for LinHES specifics + +echo $@ > /tmp/change_channel.log +. /etc/systemconfig +LOCKFILE=/tmp/lirclock +export PATH=/bin:/usr/bin:/usr/local/bin + + + + +function change_channel() { + touch $LOCKFILE + irsend SET_TRANSMITTERS $TRANSMITTER + sleep .15 + case $cmd in + [0-9]*) + for digit in $(echo $cmd | sed -e 's/./& /g') + do + irsend SEND_ONCE $REMOTE_NAME $digit + sleep $DELAY + done + if [ x$SENDKEY != "x" ] + then + irsend SEND_ONCE $REMOTE_NAME $SENDKEY + fi + + ;; + + *) + irsend SEND_ONCE $REMOTE_NAME $cmd + ;; + esac +} + +function showhelp(){ + echo "IR Control Script for LIRC + Includes support for CommandIR transmitter selection and lockfile. + The remote codes will be specific to the transmitter number and matched via /etc/systemconfig + Usage: + $0 -d delay -c channel -n transmitter_number -s Enter + + -d delay in tenths of a seconds - + -c channel or cmd + -n transmitter_number + -s Key to send after executing change channel command (optional) + + Sends an IR command or sequence of numbers using via emitter TRANSMITTER_NUM. + DELAY ( in 10th of seconds) is waited between sending IR commands. + + Example: Change to channel 123 using emitter 2 with a 0.3s pause between digits: + $0 -n1 -c123 -d3 + + " + exit 1 + + +} + +function testvars() { + if [ x$DELAY = "x" ] + then + tdelay="HostTransmitDelay_$TRANSMITTER" + d=${!tdelay} + DELAY=$(echo "scale=2; $d / 10" | bc) + fi + + + if [ x$cmd = "x" ] + then + echo "-c is mandatory" + exit 1 + fi + + + if [ x$TRANSMITTER = "x" ] + then + echo "-n is mandatory" + exit 1 + fi + echo "delay is $DELAY" + + +# echo "channel or button name is $cmd" +# echo "Using transmitter $TRANSMITTER" +# echo "Remote name is $REMOTE_NAME" +# echo "Will send key $SENDKEY after numbers" +} + + +#-----------------------------Main Program----------------------- + +while getopts ":d:c:n:hs:" opt; do + case $opt in + h) showhelp + ;; + d) DELAY=$(echo "scale=2; $OPTARG / 10" | bc) + ;; + + c) cmd=$OPTARG + ;; + + n) TRANSMITTER=$OPTARG + tname="HostTransmitproto_$TRANSMITTER" + REMOTE_NAME=${!tname} + if [ x$REMOTE_NAME = "xnone" ] + then + echo "Please define Transmitters in /etc/systemconfig" + exit 1 + fi + if [ x$REMOTE_NAME = "x" ] + then + echo "Please define Transmitters in /etc/systemconfig" + exit 1 + fi + + ;; + + s) SENDKEY=$OPTARG + ;; + + \?) + echo + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +testvars +while [ -f $LOCKFILE ] +do + echo "Waiting for change channel lock file..." + sleep .1 +done + +change_channel +rm -f /tmp/lirclock + + + + + + + + + + + + + + + + + + + + + + diff --git a/abs/core/LinHES-system/change_channel_wrapper.sh b/abs/core/LinHES-system/change_channel_wrapper.sh new file mode 100755 index 0000000..c84529a --- /dev/null +++ b/abs/core/LinHES-system/change_channel_wrapper.sh @@ -0,0 +1,2 @@ +#!/bin/bash +/usr/LH/bin/change_channel.sh $@ & diff --git a/abs/core/LinHES-system/create_media_dirs.sh b/abs/core/LinHES-system/create_media_dirs.sh new file mode 100644 index 0000000..96aa5ea --- /dev/null +++ b/abs/core/LinHES-system/create_media_dirs.sh @@ -0,0 +1,70 @@ +#!/bin/bash +#script to create the media directories +#call it like so +#create_media_dirs.sh /top_level_path + +topdir=$1 + +if [ x$topdir = "x" ] +then + echo "Top level dir is empty" + exit 1 +fi + +if [ ! -d "$topdir" ] +then + echo "$topdir is not a dir or does not exist" + exit 2 +fi + + + +while read dirname +do + mkdir -p "${topdir}/${dirname}" + touch "${topdir}/${dirname}/.media" + chown mythtv:users "${topdir}/${dirname}" + chmod 775 "${topdir}/${dirname}" + chmod 775 "${topdir}/${dirname}/.media" +done <<EOF +media/tv +media/tv/live +media/gallery +media/music +media/games/nes/roms +media/games/nes/screens +media/games/nes +media/games/pc/screens +media/games/pc +media/games/snes/roms +media/games/snes/screens +media/games/snes +media/games/xmame/cabs +media/games/xmame/flyers +media/games/xmame/hiscores +media/games/xmame/history +media/games/xmame/roms +media/games/xmame/screens +media/games/xmame +media/games +media/video +media/tmp +media/archive +media/pretty +media/video_stuff/trailers +media/video_stuff/coverart +media/video_stuff/fanart +media/video_stuff/screenshots +media/video_stuff/banners +media/games/screenshots +media/games/fanart +media/games/boxart +backup +backup/system_backups +backup/system_backups +backup/user_backups +backup/mythtv_backups +EOF + +chown -R mythtv:users ${topdir} +chmod -R 775 ${topdir} diff --git a/abs/core/LinHES-system/diskspace.sh b/abs/core/LinHES-system/diskspace.sh index 2173c6e..635a972 100755 --- a/abs/core/LinHES-system/diskspace.sh +++ b/abs/core/LinHES-system/diskspace.sh @@ -11,12 +11,13 @@ ALERT=90 # free space percentage to trigger an alert # Static Binary Paths # DF='/bin/df' -GREP='/bin/grep' -AWK='/bin/awk' -CUT='/bin/cut' -HOSTNAME='/bin/hostname' +GREP='/usr/bin/grep' +AWK='/usr/bin/awk' +CUT='/usr/bin/cut' +HOSTNAME='/usr/bin/hostname' DATE='/bin/date' OSD_CAT='/usr/bin/osd_cat' +MSG_CLIENT='/usr/LH/bin/msg_client.py --msg' export DISPLAY=:0.0 # # Static System Variables @@ -72,7 +73,8 @@ $DF -HPl | $GREP -E "^/dev/" | $AWK '{ print $5 " " $6 " " $1 }' | while read OU else echo "WARNING: ${PARTITION} (${DEVICE}) is ${USED_PCENT}% full on ${THIS_HOST}." #| if [ $OSD = true ] && [ ${PARTITION} = / ]; then - echo "WARNING: The root (${PARTITION}) partition is ${USED_PCENT}% full on ${THIS_HOST}." | $OSD_CAT --pos=top --offset=40 --align=center --delay=10 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font & + #echo "WARNING: The root (${PARTITION}) partition is ${USED_PCENT}% full on ${THIS_HOST}." | $OSD_CAT --pos=top --offset=40 --align=center --delay=10 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font & + $MSG_CLIENT "WARNING: The root (${PARTITION}) partition is ${USED_PCENT}% full on ${THIS_HOST}." fi fi fi diff --git a/abs/core/LinHES-system/firstboot.sh b/abs/core/LinHES-system/firstboot.sh index c405df8..2b974a2 100755 --- a/abs/core/LinHES-system/firstboot.sh +++ b/abs/core/LinHES-system/firstboot.sh @@ -55,7 +55,7 @@ then fb_status=4 while [ $fb_status != 0 ] do - fix_lirc_socket +# fix_lirc_socket # try_smolt if [ $fb_status != 0 ] then diff --git a/abs/core/LinHES-system/gen_is_xml.py b/abs/core/LinHES-system/gen_is_xml.py new file mode 100755 index 0000000..c7525a1 --- /dev/null +++ b/abs/core/LinHES-system/gen_is_xml.py @@ -0,0 +1,56 @@ +#! /usr/bin/python2 +#Helper program that generates gen_is.xml thats custom to linhes. +#Contents of gen_is.xml are read from /etc/gen_is_xml.d +#This script should be run everytime a is.xml entry is added or removed + + +import os, sys +import glob + +def read_snippets(dir_name): + xml_snippets="" + try: + os.chdir(dir_name) + except: + print " gen_is_xml: Couldn't change dir to %s" %dir_name + print " Exiting" + sys.exit(0) + file_list=glob.glob("*.conf") + for conf_file in file_list: + try: + print " gen_is_xml: reading in %s" %conf_file + f=open(conf_file,'r') + lines=f.readlines() + f.close() + except: + print " gen_is_xml: Couldn't open %s for reading" %conf_file + print " Exiting" + sys.exit(1) + for line in lines: + xml_snippets+=line + if len(file_list) == 0: + print " gen_is_xml: no conf files found" + xml_snippets="" + + return xml_snippets + + +def write_xml(xml,filename): + try: + f=open(filename, 'w') + except: + print " gen_is_xml: Couldn't open %s" %(filename) + print " Exiting" + sys.exit(2) + f.write(xml) + f.close() + +def main(): + filename="/usr/share/mythtv/gen_is.xml" + is_xml_dir="/etc/gen_is_xml.d/" + xml_snippets=read_snippets(is_xml_dir) + xml='''<mythmenu name="Internet Steams">\n\n%s\n</mythmenu>\n''' %xml_snippets + write_xml(xml,filename) + +if __name__ == "__main__": + main()
\ No newline at end of file diff --git a/abs/core/LinHES-system/gen_lib_xml.py b/abs/core/LinHES-system/gen_lib_xml.py new file mode 100644 index 0000000..320a84d --- /dev/null +++ b/abs/core/LinHES-system/gen_lib_xml.py @@ -0,0 +1,117 @@ +#! /usr/bin/python2 +#Helper program that generates library.xml thats custom to linhes. +#Contents are read from /etc/gen_lib_xml.d +#This script should be run everytime an entry is added or removed + + +import os, sys +import glob + +class Gen_lib_xml: + def __init__(self,snippit_dir,orig_theme_file): + self.snippit_dir = snippit_dir + self.orig_theme_file = orig_theme_file + self.xml_snippets=[] + self.orig_theme_xml=[] + self.new_xml=[] + + def get_new_xml(self): + return self.new_xml + def get_orig_xml(self): + return self.orig_theme_xml + def get_snippits(self): + return self.xml_snippets + + def read_snippets(self): + xml_snippets="" + try: + os.chdir(self.snippit_dir) + except: + print " gen_lib_xml: Couldn't change dir to %s" %self.snippit_dir + print " Exiting" + sys.exit(0) + file_list=glob.glob("*.conf") + for conf_file in file_list: + try: + print " gen_lib_xml: reading in %s" %conf_file + f=open(conf_file,'r') + lines=f.readlines() + f.close() + except: + print " gen_lib_xml: Couldn't open %s for reading" %conf_file + print " Exiting" + sys.exit(0) + + if len(file_list) == 0: + print " gen_lib_xml: no conf files found" + lines = [] + self.xml_snippets = lines + + def read_orig_xml(self): + try: + print " gen_lib_xml: reading in %s" %self.orig_theme_file + f=open(self.orig_theme_file,'r') + lines=f.readlines() + f.close() + + except: + print " gen_lib_xml: Couldn't open %s for reading" %self.orig_theme_file + print " Exiting" + sys.exit(2) + #print lines + for i in lines: + if i.strip() == "</mythmenu>": + lines.remove(i) + print " gen_lib_xml: Removing /mythmenu tag " + break + self.orig_theme_xml=lines + + def make_new_xml(self): + self.new_xml = self.orig_theme_xml + self.xml_snippets + self.new_xml.append("</mythmenu>\n") + pass + + + + + + + + +def write_xml(xml,filename): + try: + f=open(filename, 'w') + except: + print " gen_lib_xml: Couldn't open %s" %(filename) + print " Exiting" + sys.exit(2) + print " gen_lib_xml: Writing %s" %(filename) + for i in xml: + f.write(i) + f.close() + +def main(): + sys.path.append('/usr/MythVantage/bin/') + config_file = "mv_config" + data_config = __import__(config_file, globals(), locals(), []) + + filename="%s/.mythtv/library.xml" %data_config.MYTHHOME + #filename="/tmp/library.xml" + orig_theme_file="/usr/share/mythtv/themes/defaultmenu/library.xml" + lib_xml_dir="/etc/gen_lib_xml.d/" + + lib_xml = Gen_lib_xml(lib_xml_dir,orig_theme_file) + lib_xml.read_snippets() + lib_xml.read_orig_xml() + lib_xml.make_new_xml() + lib_xml.make_new_xml() + new_xml = lib_xml.get_new_xml() + + #a = lib_xml.get_new_xml() + #b = lib_xml.get_orig_xml() + #c = lib_xml.get_snippits() + + write_xml(new_xml,filename) + +if __name__ == "__main__": + main()
\ No newline at end of file diff --git a/abs/core/LinHES-system/install_supplemental_service.sh b/abs/core/LinHES-system/install_supplemental_service.sh index d33cb18..c474447 100644 --- a/abs/core/LinHES-system/install_supplemental_service.sh +++ b/abs/core/LinHES-system/install_supplemental_service.sh @@ -2,7 +2,8 @@ . /etc/systemconfig if [ $SystemType = Master_backend -o $SystemType = Standalone ] then - pacman -S --noconfirm supplemental-web + pacman -S --noconfirm xymonserver + pacman -S --noconfirm supplemental-web add_service.sh certmaster add_service.sh funcd add_service.sh xymon-server diff --git a/abs/core/LinHES-system/lh_backend_control.sh b/abs/core/LinHES-system/lh_backend_control.sh new file mode 100644 index 0000000..c116cdb --- /dev/null +++ b/abs/core/LinHES-system/lh_backend_control.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# This script is used to start stop the backend. +# Intended to be used via hotkeys. + + +MYTH_RUN_STATUS="1" +. /etc/profile +. /etc/systemconfig + + +if [ -e /etc/X11/WINDOWMANAGER ] +then + . /etc/X11/WINDOWMANAGER +fi + +MV_BEC="/usr/MythVantage/bin/backend_control.sh" + +case $1 in + stop) + if [ x$STARTUP_STYLE = xenhanced ] + then + #/usr/MythVantage/bin/mythbeselect -stop + if [ -e $MV_BEC ] + then + $MV_BEC stop $dbhost + else + msg_client.py --msg "Stopping backend" + sudo sv stop mythbackend + fi + else + #linhes style + sudo sv stop mythbackend + fi + ;; + + start) + if [ x$STARTUP_STYLE = xenhanced ] + then + #/usr/MythVantage/bin/mythbeselect -stop + if [ -e $MV_BEC ] + then + $MV_BEC start $dbhost + else + msg_client.py --msg "Starting backend" + sudo sv start mythbackend + fi + else + #linhes style + sudo sv start mythbackend + fi + ;; + + restart) + if [ x$STARTUP_STYLE = xenhanced ] + then + #/usr/MythVantage/bin/mythbeselect -stop + if [ -e $MV_BEC ] + then + $MV_BEC restart $dbhost + else + msg_client.py --msg "Restarting backend" + sudo sv restart mythbackend + fi + else + #linhes style + sudo sv restart mythbackend + fi + ;; + + *) echo "options are: stop start restart" + ;; + +esac + + diff --git a/abs/core/LinHES-system/lh_message.sh b/abs/core/LinHES-system/lh_message.sh index 203d127..3ac8132 100644 --- a/abs/core/LinHES-system/lh_message.sh +++ b/abs/core/LinHES-system/lh_message.sh @@ -1,4 +1,8 @@ #!/bin/bash +# This script is called by msd_daemon.py and used to display messages on the osd_cat +# May be called directly but best used through msg_daemon + + MYTH_RUN_STATUS="1" . /etc/profile . /etc/systemconfig @@ -19,36 +23,16 @@ fi font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*" } -function delay_osd(){ - if [ x$STARTUP_STYLE = xmythvantage ] - then - cmd="ps -ef | grep -v grep | grep -q xmsg.py" - else - cmd="ps -ef | grep -v grep | grep -q osd_cat" - fi - - eval $cmd - - rc=$? - while [ $rc = 0 ] - do - eval $cmd - rc=$? - done - - - } - function msg_osd(){ DISPLAY=127.0.0.1:0 echo -e "$1" | DISPLAY=127.0.0.1:0 osd_cat --pos=middle --align=center --offset=200 --delay=5 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font } function msg_pyosd(){ - DISPLAY=127.0.0.1:0 /usr/LH/bin/xmsg.py -m "$1" + DISPLAY=127.0.0.1:0 /usr/LH/bin/msg_osd.py -m "$1" } function msg(){ - if [ x$STARTUP_STYLE = xmythvantage ] + if [ x$STARTUP_STYLE = xenhanced ] then msg_pyosd "$1" else @@ -59,7 +43,7 @@ function msg(){ if [ x"${@}" = x ] then - print "nothing to display" + echo "nothing to display" else msg "${@}" fi diff --git a/abs/core/LinHES-system/lh_system_backup_job b/abs/core/LinHES-system/lh_system_backup_job index 61b05d7..99838be 100644 --- a/abs/core/LinHES-system/lh_system_backup_job +++ b/abs/core/LinHES-system/lh_system_backup_job @@ -5,9 +5,10 @@ # echo "#########################################################" echo "Starting backup " +MYTH_RUN_STATUS="1" . /etc/profile . /etc/systemconfig -BACKUPDIR=/myth/system_backups +BACKUPDIR=/data/storage/disk0/backup/system_backups DELETE_DAYS=21 DATE=`date +%F_%H-%M` mkdir -p $BACKUPDIR/$DATE @@ -36,9 +37,9 @@ then rm -rf $BACKUPDIR/$DATE fi -if [ -f /data/srv/hobbit/server/ext/hbnotes.py ] +if [ -f /home/xymon/server/ext/hbnotes.py ] then - /data/srv/hobbit/server/ext/hbnotes.py + /home/xymon/server/ext/hbnotes.py chown nobody:nobody /data/srv/httpd/htdocs/hobbit/notes/* 2> /dev/null >/dev/null fi @@ -56,7 +57,7 @@ then 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 diff --git a/abs/core/LinHES-system/lh_system_host_update b/abs/core/LinHES-system/lh_system_host_update index 1a4d714..75fe548 100644 --- a/abs/core/LinHES-system/lh_system_host_update +++ b/abs/core/LinHES-system/lh_system_host_update @@ -4,6 +4,7 @@ # supplemental web echo "#####################################################" echo "Starting update" +MYTH_RUN_STATUS="1" . /etc/profile if [ x$1 = x ] diff --git a/abs/core/LinHES-system/lh_system_restore_job b/abs/core/LinHES-system/lh_system_restore_job index 9c66e2a..6446e6d 100644 --- a/abs/core/LinHES-system/lh_system_restore_job +++ b/abs/core/LinHES-system/lh_system_restore_job @@ -2,7 +2,7 @@ # 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 +BACKUPDIR=/data/storage/disk0/backup/system_backups backupfile=$1 function usage(){ @@ -30,7 +30,7 @@ if [ x$backupfile = x ] then usage fi - +MYTH_RUN_STATUS="1" . /etc/profile RESTOREDIR=$BACKUPDIR/restore diff --git a/abs/core/LinHES-system/msg_client.py b/abs/core/LinHES-system/msg_client.py new file mode 100755 index 0000000..54c2e54 --- /dev/null +++ b/abs/core/LinHES-system/msg_client.py @@ -0,0 +1,102 @@ +#!/usr/bin/python2 +#client for msg_daemon + +import socket +import sys +import argparse +import pickle +import time +# Create a UDS socket +sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + +# Connect the socket to the port where the server is listening +server_address = '/run/msg_socket' +def send_message(message): + #print >>sys.stderr, 'connecting to %s' % server_address + try: + sock.connect(server_address) + except socket.error, msg: + print >>sys.stderr, msg + sys.exit(1) +#try: + sock.sendall(message) + #amount_received = 0 + #amount_expected = len(message) + print "Waiting for response..." + data = sock.recv(1024) + print data + +#finally: + #print >>sys.stderr, 'error occured closing socket' + + sock.close() +def usage(): + line = ''' + Help screen: + msg_client.py is used to add,remove, or list items in the queue of messages that + will be displayed on screen. Optionaly messages can be given an identifier or "tag". + This identifier does not have to be unique. + + Items are processed in the order they arrive, based off their slot number. + The lowest slot number will be displayed first. + After the message is displayed it is removed from the queue. + + + ADD: + To add items to the queue: + msg_client.py --msg "My first message" --tag "tag1" + + REMOVE: + Removing items are based off the tag. + To remove all items from the queue that match the tag "tag1": + msg_client.py --clear --tag tag1 + + To remove all items from the queue: + msg_client.py --clear + + + Listing items in the queue or to get the total count: + msg_client.py --print_list + > ------------- + > msg : slot 1 + > slot : 1 + > cmd : msg + > tag : None + > timeout : None + + + To immediately stop displaying the current message, use the kill command. + msg_client.py --kill + + ''' + print line + sys.exit(0) +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument('--tag', action='store', dest='tag',help='message tag') + parser.add_argument('--timeout', action='store', dest='timeout',help='time to display message') + action = parser.add_mutually_exclusive_group(required=True) + action.add_argument('--msg', action='store', dest='msg', help='Add message to the queue') + action.add_argument('--clear', action='store_true', help='Remove message from queue that match tag') + action.add_argument('--kill', action='store_true', help='Kill current msg thats displayed') + action.add_argument('--print_list', action='store_true', help='Print current queue') + action.add_argument('--usage', action='store_true', help='Print help screen') + + results = parser.parse_args() + resultsdict = vars(results) + + if results.msg : + cmd = "msg" + elif results.clear: + cmd = "clear" + elif results.kill: + cmd = "kill" + elif results.print_list: + cmd = "list" + elif results.usage: + usage() + + arg_dict = {'cmd':cmd , 'msg':resultsdict['msg'] , 'tag':resultsdict['tag'] , 'timeout':resultsdict['timeout']} + send_message(pickle.dumps(arg_dict)) + #sys.exit(0) diff --git a/abs/core/LinHES-system/msg_daemon.py b/abs/core/LinHES-system/msg_daemon.py new file mode 100755 index 0000000..0e54824 --- /dev/null +++ b/abs/core/LinHES-system/msg_daemon.py @@ -0,0 +1,360 @@ +#!/usr/bin/python2 +#MythVantage osd message deamon. +#Use the client to send messages to localhost +import socket +import sys +import os +import pickle +import operator +import threading +import time +import aosd +import ConfigParser +import multiprocessing +import subprocess,signal + +sys.path.append('/etc') + +server_address = '/run/msg_socket' +class msg_aosd(): + def scroll(self,osd, width, height, display_time,position): + pos = position + step = 1 + + osd.set_position(pos, width, height) + (x, y, _, _) = osd.get_geometry() + osd.set_position_offset(width, height) + osd.show() + + x -= 1 + y += height - 1; + for i in range(1, height + 1, step): + osd.loop_for(5) + y -= step + osd.set_geometry(x, y, width, i) + + osd.set_position(pos, width, height) + osd.set_position_offset(-1, -1) + (x, y, _, _) = osd.get_geometry() + #time to display + osd.loop_for(display_time) + for i in range(height, 0, -step): + y += step + osd.set_geometry(x, y, width, i); + osd.loop_for(1); + + osd.hide(); + + def setup(self,font_color,font_type): + osd = aosd.AosdText() + osd.set_transparency(aosd.TRANSPARENCY_COMPOSITE) + if osd.get_transparency() != aosd.TRANSPARENCY_COMPOSITE: + osd.set_transparency(aosd.TRANSPARENCY_NONE) + + osd.geom_x_offset = 10 + osd.geom_y_offset = 0 + + osd.back_color = "white" + osd.back_opacity = 50 + + osd.shadow_color = "black" + osd.shadow_opacity = 127 + osd.shadow_x_offset = 2 + osd.shadow_y_offset = 2 + + osd.fore_color = font_color + osd.fore_opacity = 255 + + osd.set_font(font_type) + osd.wrap = aosd.PANGO_WRAP_WORD_CHAR + osd.alignment = aosd.PANGO_ALIGN_LEFT + osd.set_layout_width(osd.get_screen_wrap_width()) + return osd + + def set_string(self, osd, text): + osd.set_text(text) + return osd.get_text_size() + + def setup_config(self): + module_config = ConfigParser.RawConfigParser() + try: + module_config.read('/usr/MythVantage/etc/msg.cfg') + except: + pass + return module_config + + + + def display (self,flags,display_time=-1): + """ + parse the msg for display. + """ + try: + text,config_section=flags.split("|") + if config_section == '': + config_section="default" + except: + text=flags + config_section="default" + + module_config = self.setup_config() + + position=6 + font_color="green" + font_type="Times New Roman Italic 36" + + if display_time <= 0 : + try: + display_time = int(module_config.get(config_section,"display_time")) + except: + display_time = 5000 + pass + try: + position = int(module_config.get(config_section,"position")) + except: + pass + try: + font_color = module_config.get(config_section,"font_color") + except: + pass + try: + font_type = module_config.get(config_section,"font_type") + except: + pass + + #this bit of code converts a \n to EOL/BREAK + textline=text.split('\\n') + try: + textline.remove(' ') + except: + pass + text=chr(10).join(textline) + + #cmd = sub_process.Popen("/usr/bin/wall %s" % text,stdout=sub_process.PIPE,shell=True) + #data = cmd.communicate()[0] + osd = self.setup(font_color, font_type) + width, height = self.set_string(osd, text) + self.scroll(osd, width, height, display_time, position) + + return ("Message delivered") + + +class msg_xosd(): + """Crude wrapper for xosd_cat""" + def __init__ (self): + pass + + def set_default_values(self): + self.color="yellow" + self.outline="2" + self.outlinecolour="black" + self.shadow="0" + self.shadowcolour="black" + self.font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*" + return + + def set_parameters(self): + xosd_cfg={} + file_name = "/etc/osd_cat.cfg" + try: + config_file = open(file_name) + except: + set_default_values() + return + + for line in config_file: + line = line.strip() + if line and line[0] is not "#" and line[-1] is not "=": + var, val = line.rsplit("=", 1) + val = val.split("#")[0] + val = val.strip('"') + xosd_cfg[var.strip()] = val.strip() + self.color = xosd_cfg['color'] + self.outline = xosd_cfg['outline'] + self.outlinecolour = xosd_cfg['outlinecolour'] + self.shadow = xosd_cfg['shadow'] + self.shadowcolour = xosd_cfg['shadowcolour'] + self.font = xosd_cfg['font'] + + def display(self,msg,display_time): + self.set_parameters() + cmd = "echo -e \"%s\" | DISPLAY=127.0.0.1:0 osd_cat --pos=middle --align=center --offset=200 --delay=%s --color=%s --outline=%s --outlinecolour=%s --shadow=%s --shadowcolour=%s --font=\"%s\"" %(msg,display_time,self.color,self.outline,self.outlinecolour,self.shadow,self.shadowcolour,self.font) + #set a process group on the OS, so that the kill gets them all. No one survives or becomes a zombie + self.p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,preexec_fn=os.setsid) + self.processID = self.p.pid + stdout,stderr = self.p.communicate() + + def kill(self): + try: + os.killpg(self.processID,signal.SIGTERM) + except: + pass + +class Msg_Queue(): + def __init__(self): + self.msglist=[] + self.msg_slot = 0 + + def get_msg(self): + return self.msglist.pop(0) + pass + + def add_msg(self,cmddict): + #print "Adding msg to msg queue" + self.inc_last_msg_slot() + cmddict['slot'] = self.msg_slot + self.msglist.append(cmddict) + + + def clear_msg(self,msg_tag): + #print "Clearing out list of %s" %msg_tag + #loop over list in reverse + for i in xrange(len(self.msglist) - 1, -1, -1): + #access list by index, look at the key tag + if self.msglist[i]['tag'] == msg_tag: + del self.msglist[i] + + def clear(self): + #print "Clearing out entire queue" + del self.msglist[:] + + def sort(self,keyvalue): + self.msglist.sort(key=operator.itemgetter(keyvalue)) + + def search(self,key,value): + pass + + def get_queue(self): + return self.msglist + + def get_last_msg_slot(self): + return self.msg_slot + + def inc_last_msg_slot(self): + self.msg_slot = self.msg_slot + 1 + + +class msg_queue_runner(threading.Thread): + """Threaded Queue runner for testing things""" + def __init__(self, msg_queue): + threading.Thread.__init__(self) + self.msg_queue = msg_queue + self.out_msg = msg_aosd() + self.out_xosd = msg_xosd() + + def get_current_style(self): + style = "default" + if os.path.exists('/etc/X11/WINDOWMANAGER'): + command = ['bash', '-c', 'source /etc/X11/WINDOWMANAGER && echo $STARTUP_STYLE'] + proc = subprocess.Popen(command, stdout = subprocess.PIPE) + + for line in proc.stdout: + if line.strip() == "": + style = "default" + else: + style = line.strip() + break + proc.communicate() + else: + style = "default" + return style + + + def kill_current(self): + style = self.get_current_style() + #print "Killing current display" + if style == "enhanced": + self.p.terminate() + elif style == "default": + #self.p.terminate() + self.out_xosd.kill() + + def run(self): + while True: + try: + msgdict = self.msg_queue.get_msg() + style = self.get_current_style() + if msgdict['timeout'] == None: + display_time = 3 + + # display message here + msgtext = msgdict['msg'] + if style == "enhanced": + display_time = display_time * 1000 + self.p = multiprocessing.Process(target=self.out_msg.display, args=(msgtext,display_time)) + self.p.start() + self.p.join() + elif style == "default": + #display_time = int(msgdict['timeout']) + self.out_xosd.display(msgtext,display_time) + + except: + time.sleep(1) + continue + + +msg_queue = Msg_Queue() + + +if __name__ == "__main__": + # Make sure the socket does not already exist + try: + os.unlink(server_address) + except OSError: + if os.path.exists(server_address): + raise + # Create a UDS socket + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + # Bind the socket to the port + #print >>sys.stderr, 'starting up on %s' % server_address + sock.bind(server_address) + #change permissions of socket + os.chmod(server_address,0777) + + # Listen for incoming connections + sock.listen(2) + #start msg display thread + msgthread = msg_queue_runner(msg_queue) + msgthread.setDaemon(True) + msgthread.start() + + #main loop that reads in the cmddict, never exits + while True: + # Wait for a connection + connection, client_address = sock.accept() + try: + #sf = connection.makefile("r+b", bufsize=0) + data = connection.recv(1024) + cmddict = (pickle.loads(data)) + connection.send(" Server acknowledged client \n") + if cmddict['cmd'] == "msg": + #add to msg_queue + msg_queue.add_msg(cmddict) + + elif cmddict['cmd'] == 'clear': + if cmddict['tag'] == '' or cmddict['tag'] == None : + msg_queue.clear() + else: + msg_queue.clear_msg(cmddict['tag']) + + elif cmddict['cmd'] == 'kill': + msgthread.kill_current() + + elif cmddict['cmd'] == 'list': + q = msg_queue.get_queue() + for i in q: + line="-------------\n" + connection.send(line) + for k,v in i.iteritems(): + line=" %s : %s\n" %(k,v) + connection.send(line) + line = "Number of messages in queue: %s \n" %(len(q)) + connection.send(line) + #connection.send(pickle.dumps(q)) + + + finally: + # Clean up the connection + connection.close() + + diff --git a/abs/core/LinHES-system/xmsg.py b/abs/core/LinHES-system/msg_osd.py index 669a796..669a796 100644 --- a/abs/core/LinHES-system/xmsg.py +++ b/abs/core/LinHES-system/msg_osd.py diff --git a/abs/core/LinHES-system/myth_mtc.lr b/abs/core/LinHES-system/myth_mtc.lr index 23f8711..2b2fbba 100644 --- a/abs/core/LinHES-system/myth_mtc.lr +++ b/abs/core/LinHES-system/myth_mtc.lr @@ -1,7 +1,7 @@ /var/log/mythtv/myth_mtc.log { copytruncate daily - size 10M + #size 1M missingok rotate 7 compress diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py index 6fd53a7..a5f02a0 100755 --- a/abs/core/LinHES-system/myth_mtc.py +++ b/abs/core/LinHES-system/myth_mtc.py @@ -1,6 +1,4 @@ -#!/usr/bin/python - - +#!/usr/bin/python2 import sys, subprocess import optparse import re @@ -8,8 +6,6 @@ import socket import os import datetime,time - - try: from MythTV import MythBE mythtv = MythBE() diff --git a/abs/core/LinHES-system/myth_mtc.sh b/abs/core/LinHES-system/myth_mtc.sh index 12486c4..7899daa 100755 --- a/abs/core/LinHES-system/myth_mtc.sh +++ b/abs/core/LinHES-system/myth_mtc.sh @@ -1,7 +1,9 @@ #!/bin/bash +MYTH_RUN_STATUS=1 . /etc/profile -logFile='/var/log/mythtv/myth_mtc.log' + date=`date +%Y-%m-%d` +logFile="/var/log/$date/myth_mtc.log" MYTHCONFDIR=/usr/share/mythtv myth_mtc.py > $logFile 2>&1 if [ $? = 0 ] diff --git a/abs/core/LinHES-system/readme_is_xml b/abs/core/LinHES-system/readme_is_xml new file mode 100644 index 0000000..d2af0f6 --- /dev/null +++ b/abs/core/LinHES-system/readme_is_xml @@ -0,0 +1 @@ +Files ending in .conf will be read by gen_is_xml.py or gen_lib_xml.py and output xml as appropriate diff --git a/abs/core/LinHES-system/set_windowmanager.sh b/abs/core/LinHES-system/set_windowmanager.sh index 3d0cdb2..b159fbf 100644 --- a/abs/core/LinHES-system/set_windowmanager.sh +++ b/abs/core/LinHES-system/set_windowmanager.sh @@ -5,6 +5,7 @@ # windowmanager="$1" style="$2" +configdir=/usr/share/wm_data function outmsg(){ @@ -16,6 +17,70 @@ function stylemsg(){ echo "Startup path will use $1 style" } +function set_wm(){ + case ${windowmanager} in + + default) + outmsg "default/fluxbox" + outline="default" + echo "" > /etc/X11/WINDOWMANAGER + ;; + + enlightenment) + outmsg "enlightenment" + outline="e16 -P $configdir/e16_config_dir/" + ;; + + windowmaker) + outmsg "window maker" + outline_2="export GNUSTEP_USER_ROOT=$configdir/GNUstep" + outline="wmaker" + ;; + + *) + outline=$windowmanager + outmsg "$outline" + ;; + + esac + + + + case ${style} in + + enhanced) + STYLE="enhanced" + HSTYLE="1" + stylemsg enhanced + myth_settings_wrapper.sh -c load -t custom 1 HOSTSupplemental + ;; + + *) + if [ x$style != x ] + then + stylemsg "** Unknown style..using default" + STYLE="" + else + STYLE="$style" + stylemsg "Default" + fi + HSTYLE=0 + ;; + esac + + + + echo WM=\"${outline}\" > /etc/X11/WINDOWMANAGER + echo "STARTUP_STYLE=$STYLE" >> /etc/X11/WINDOWMANAGER + echo ${outline_2} >> /etc/X11/WINDOWMANAGER + + myth_settings_wrapper.sh -c load -t custom "${windowmanager}" HostWindowManager + myth_settings_wrapper.sh -c load -t custom "${HSTYLE}" HostEnhancedWMStyle + + + } + + if [ x$windowmanager = x ] then echo @@ -31,12 +96,12 @@ then echo echo "Valid STARTUP_STYLE options are:" echo " default" - echo " mythvantage" + echo " enhanced" echo echo "If STARTUP_STYLE is not given, then the default will be used." echo echo "Example: " - echo " set_windowmanager.sh enlightenment mythvantage" + echo " set_windowmanager.sh enlightenment enhanced" echo echo " " echo "if using enlightenment or windowmaker, please ensure that the alt_wm group is installed" @@ -45,55 +110,32 @@ then exit 0 fi +set_wm -case ${windowmanager} in - - default) - outmsg "default/fluxbox" - outline="fluxbox" - echo "" > /etc/X11/WINDOWMANAGER - exit 0 - ;; - - enlightenment) - outmsg "enlightenment" - outline="e16 -P /data/e16_config_dir/" - ;; - - windowmaker) - outmsg "window maker" - outline_2="export GNUSTEP_USER_ROOT=/data/GNUstep" - - outline="wmaker" - ;; - - *) - outline=$windowmanager - outmsg "$outline" - ;; +if [ x$outline = "xdefault" ] +then + exit 0 +fi -esac +WM_CHECK=`echo $outline|cut -d" " -f1 |tr -dc '[:alnum:]'` +which $WM_CHECK 2>/dev/null +rc=$? +if [ $rc != 0 ] +then + echo " ***Window manager $WM_CHECK does not look like it is present" + echo " ***setting windowmanger to windowmaker" + echo " " + windowmanager="windowmaker" + set_wm +fi -case ${style} in - mythvantage) - STYLE="mythvantage" - stylemsg MythVantage - ;; - *) - STYLE="$style" - stylemsg "Default" - ;; -esac -echo WM=\"${outline}\" > /etc/X11/WINDOWMANAGER -echo "STARTUP_STYLE=$STYLE" >> /etc/X11/WINDOWMANAGER -echo ${outline_2} >> /etc/X11/WINDOWMANAGER diff --git a/abs/core/LinHES-system/system-sudo.rules b/abs/core/LinHES-system/system-sudo.rules new file mode 100644 index 0000000..86e1b72 --- /dev/null +++ b/abs/core/LinHES-system/system-sudo.rules @@ -0,0 +1 @@ +mythtv ALL=(ALL) NOPASSWD: ALL diff --git a/abs/core/LinHES-system/system.install b/abs/core/LinHES-system/system.install new file mode 100644 index 0000000..662e271 --- /dev/null +++ b/abs/core/LinHES-system/system.install @@ -0,0 +1,47 @@ +# This is a default template for a post-install scriptlet. You can +# remove any functions you don't need (and this header). + +# arg 1: the new package version +pre_install() { + /bin/true +} + +# 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 + 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 +} + +# arg 1: the new package version +# arg 2: the old package version +pre_upgrade() { + /bin/true +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + post_install +} + +# arg 1: the old package version +pre_remove() { + /bin/true +} + +# arg 1: the old package version +post_remove() { + /bin/true +} + +op=$1 +shift +$op $* |