diff options
Diffstat (limited to 'abs/core/LinHES-system')
23 files changed, 1123 insertions, 214 deletions
diff --git a/abs/core/LinHES-system/LinHES-session b/abs/core/LinHES-system/LinHES-session index 918406d..902962f 100755 --- a/abs/core/LinHES-system/LinHES-session +++ b/abs/core/LinHES-system/LinHES-session @@ -46,25 +46,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 +75,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 "$1" } @@ -94,7 +89,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 +175,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 +187,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 +209,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 +236,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 +264,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 @@ -286,11 +291,11 @@ function start_myth() { 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 +304,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 +342,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 +369,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 +384,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/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index eb53138..2999796 100644..100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,35 +1,38 @@ pkgname=LinHES-system pkgver=2 -pkgrel=61 -arch=('i686') +pkgrel=98 +arch=('i686' 'x86_64') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin -install=LinHES.install +#install=LinHES-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 + msg_osd.py 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_message.sh 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" -source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr - diskspace smolt.cron cacheclean.cron) +source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr + diskspace cacheclean.cron readme_is_xml add_storage.readme) + build() { cd $startdir/src install -m755 -D LinHES-session $startdir/pkg/etc/X11/Sessions/LinHES @@ -48,41 +51,49 @@ build() { item=$i install -m755 -D $item $MVDIR/bin/$item echo $item - done + 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 } -md5sums=('d1a5963c5a440a608031c6d750232633' +md5sums=('a941af97fe534731a507b1d57c0c2aed' '5881bdb43d578ec3a79d1f77ea58a3db' 'a875ee97f86e46f34a741c2bc455f894' '76b2637cac0452b3acdbeeb4e8a5474b' - 'd1f27cb422010077c841376526fe46ea' + '781c977f8872543f033dad2caaf0458e' '2ef9f945e034119f77d9b6beb17e4fa5' '4b4585ccba30595cf958d202997c57f7' - 'cbe4cba14fa9d01a62e2196edc1bd98b' 'dc3eef2a624754e16805d72bbe488b67' 'dc0be354ce77ba2b89868fc29b942c43' '542e670e78d117657f93141e9689f54d' '41951459ea9d2b0567be521b67e6285a' - 'ba351b92e69bcaf26a9bf80417b09c3c' - '309638acf596ce3c790aa2bf5c7c9880' + 'ee6b9d277843e7047f46bdd83e1377ec' + '4545eb39213d40b5a2bdeda5e066cdc4' '962a3e9eaba2d1466251b7ab0956705d' 'd03aedeeeda0f5e9c1eb437411c88477' - '94ce8f1d5085c0db7b267db8c2e9a3ff' - '16a2a3347961517fe7d95a2956a091a6' - '9c2294ccfd5359583497a6b03d918a27' + '1758aed160de64abfafb28a3a8f3390e' + '6a56efa9abcf914ebe380178749cf7ce' + 'ceec78815ed01af733cdbca14cb0942b' '859a80ddb4c234506379c605114c1343' '47e093e8cfe4b5b96602358e1f540832' - '6faeba0aeb38e772121f751cabda8683' - '68e3e87571f3b0fa4a48a10df50dc220' - '9603b0ca6e090eff31e76482a3c335e7' - 'b798ee0796d1b760a2998f90eb8ce9cc' + '9f08fb2e821297841f1849c6221b87cb' + 'b8f0414427c5d9afdc32ceb3ae56f82a' + '6519d209e151cdc39ae7e1091d189c3e' + 'd1cdf28fcb1c88f0e504905771dd6040' + '88c669b8eeb988106bd26c9cf8277df2' '4a3cd8f9b33b2b86fdba47a8f1fa2859' + '4d5a2441fe681c85986c5626c2944a3d' + 'a182af47a7d373b2a63a27e1bb7485b2' + '5148fe4c6ac27fff8152c819c4d2b47a' + 'ea315f41dcd6c978e546c95fc05546cf' + 'ac61cc460d9e97ba1f5ef69e92cdfbe5' '06a628469051237943b7c874f2e29b8a' '54ebcc024db2e0ebe8121305d8926767' '45f46d1f9193c8dde18e56369ec29a1e' @@ -91,5 +102,6 @@ md5sums=('d1a5963c5a440a608031c6d750232633' 'eb879fee9603a05d5420d4ce8ed9e450' 'f1870a9522c79e6b248fcbf81dec3280' '84492954db16740f949d795b74383189' - 'abe887472a170bd1a8e6da6a7b7e93e4' - '02c810c2f47b7c4495fdacaf54189473') + '02c810c2f47b7c4495fdacaf54189473' + '1e2ca4dd872a50df6b70528e06df558a' + 'da432d68962e109e09beb2b71c8c8571') 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/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..4064df2 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' 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..b15ca35 --- /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 "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 "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 "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..65eb723 100644 --- a/abs/core/LinHES-system/lh_system_backup_job +++ b/abs/core/LinHES-system/lh_system_backup_job @@ -7,7 +7,7 @@ echo "#########################################################" echo "Starting backup " . /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 +36,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 +56,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_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..3c53857 --- /dev/null +++ b/abs/core/LinHES-system/msg_client.py @@ -0,0 +1,42 @@ +#!/usr/bin/python2 +#client for msg_daemon + +import socket +import sys + +# 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) + + #while amount_received < amount_expected: + # data = sock.recv(16) + # amount_received += len(data) + # print >>sys.stderr, 'received "%s"' % data + + finally: + #print >>sys.stderr, 'closing socket' + print "message sent" + sock.close() + + +if __name__ == "__main__": + if len(sys.argv) == 2: + send_message(sys.argv[1]) + else: + print "Unknown command" + print "usage: %s msg to display" % sys.argv[0] + sys.exit(2) + 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..5ca5b09 --- /dev/null +++ b/abs/core/LinHES-system/msg_daemon.py @@ -0,0 +1,46 @@ +#!/usr/bin/python2 +#MythVantage osd message deamon. +#Use the client to send messages to localhost +import socket +import sys +import os +from subprocess import call + +server_address = '/run/msg_socket' + +# 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(1) + +while True: + # Wait for a connection + connection, client_address = sock.accept() + try: + #print >>sys.stderr, 'connection from', client_address + msg="" + # Receive the data in small chunks and retransmit it + while True: + data = connection.recv(16) + msg+=data + if data: + continue + else: + call(["/usr/LH/bin/lh_message.sh", msg]) + break + + 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.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/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..75c4cee 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,71 @@ function stylemsg(){ echo "Startup path will use $1 style" } +function set_wm(){ + case ${windowmanager} in + + default) + outmsg "default/fluxbox" + outline="fluxbox" + echo "" > /etc/X11/WINDOWMANAGER + exit 0 + ;; + + 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 +97,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 +111,27 @@ 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" - ;; - -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/LinHES.install b/abs/core/LinHES-system/system.install index 7ae0616..7ae0616 100644 --- a/abs/core/LinHES-system/LinHES.install +++ b/abs/core/LinHES-system/system.install |