From 4989e79abe0bd9b8c7e364953158e66578f0b0d4 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 15 Aug 2012 11:13:51 -0500 Subject: LinHES-config: fixed several install problems - new grub install - fix detection of ip in python scripts - fix xscreensaver not starting after install - fix force umount of /new_boot --- abs/core/LinHES-config/09_mythvantge_runit_grub | 46 +++++++++++++++++++++++++ abs/core/LinHES-config/LinHES-release | 2 +- abs/core/LinHES-config/PKGBUILD | 22 ++++++------ abs/core/LinHES-config/issue | 1 - abs/core/LinHES-config/mv_common.py | 10 ++++++ abs/core/LinHES-config/mv_hostype.py | 30 ++++++++++------ abs/core/LinHES-config/mv_install.py | 38 ++++++++++++++++---- abs/core/LinHES-config/mv_network.py | 43 ++++++++++++++++------- abs/core/LinHES-config/mv_screensaver.py | 22 +++++++++++- abs/core/LinHES-config/systemconfig.py | 16 ++++++--- 10 files changed, 183 insertions(+), 47 deletions(-) create mode 100644 abs/core/LinHES-config/09_mythvantge_runit_grub diff --git a/abs/core/LinHES-config/09_mythvantge_runit_grub b/abs/core/LinHES-config/09_mythvantge_runit_grub new file mode 100644 index 0000000..ec20282 --- /dev/null +++ b/abs/core/LinHES-config/09_mythvantge_runit_grub @@ -0,0 +1,46 @@ +#!/bin/sh +prefix="/usr" +exec_prefix="${prefix}" +datarootdir="/usr/share" +. "${datarootdir}/grub/grub-mkconfig_lib" +if [ -z "$boot_device_id" ]; then +boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" +fi + +gettext_printf "Found LinHES runit: \n" >&2 +echo " +menuentry 'LinHES' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-$boot_device_id' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 $boot_device_id + else + search --no-floppy --fs-uuid --set=root $boot_device_id + fi + echo 'Loading Linux core repo kernel ...' + linux /boot/vmlinuz-linux root=UUID=$boot_device_id ro quiet init=/sbin/runit + echo 'Loading initial ramdisk ...' + initrd /boot/initramfs-linux.img + } +menuentry 'LinHES --no-splash' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-$boot_device_id' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 $boot_device_id + else + search --no-floppy --fs-uuid --set=root $boot_device_id + fi + echo 'Loading Linux core repo kernel ...' + linux /boot/vmlinuz-linux root=UUID=$boot_device_id ro init=/sbin/runit + echo 'Loading initial ramdisk ...' + initrd /boot/initramfs-linux.img +} +" diff --git a/abs/core/LinHES-config/LinHES-release b/abs/core/LinHES-config/LinHES-release index 3939edc..747db47 100644 --- a/abs/core/LinHES-config/LinHES-release +++ b/abs/core/LinHES-config/LinHES-release @@ -1 +1 @@ -LinHES R7.3 (Crave) +LinHES 8.0 (Trip the bits) diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD index 077064c..0666eac 100644 --- a/abs/core/LinHES-config/PKGBUILD +++ b/abs/core/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=2.3 -pkgrel=78 +pkgrel=79 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config ) pkgdesc="Install and configure your system" depends=('bc' 'libstatgrab' 'mysql-python' 'expect' 'curl' 'dnsutils' 'parted' @@ -10,7 +10,7 @@ depends=('bc' 'libstatgrab' 'mysql-python' 'expect' 'curl' 'dnsutils' 'parted' #LinHES-timezone arch=('i686' 'x86_64') -source=(mv_install.py +source=(mv_install.py 09_mythvantge_runit_grub mv_config.py myth_user_call file_time_offset.py @@ -24,7 +24,6 @@ source=(mv_install.py timezip.py soundconfig.sh LinHES-release - issue MythVantage.sh create_master.sh build_diskless.sh @@ -55,6 +54,8 @@ install=config.install build() { mkdir -p $startdir/pkg/etc mkdir -p $startdir/pkg/usr/share/mythtv/themes/default + install -D -m0755 09_mythvantge_runit_grub $startdir/pkg/etc/grub.d/09_mythvantge_runit_grub + MVDIR=$startdir/pkg/usr/MythVantage mkdir $startdir/pkg/etc/profile.d @@ -107,10 +108,10 @@ build() { 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 config-sudo.rules $startdir/pkg/etc/sudoers.d/config-sudo.rules + install -o root -g root -m 0750 config-sudo.rules $startdir/pkg/etc/sudoers.d/config_sudo } -md5sums=('4ef6a2f04f5cb1777ac3772eeccdc78f' +md5sums=('5d40d7ce4cd99fae059cac37cef9440f' + '8aec4b2310e4c5375e32df37d37964dd' '16b98fcb3753ef6cfc35075c326d30e4' '2596460462cf6c889cf8f95485537b20' '985891a43f7c4c983eb2a362162f1a0f' @@ -123,8 +124,7 @@ md5sums=('4ef6a2f04f5cb1777ac3772eeccdc78f' '960017a34d9cc78af6298f45aad6eb8e' 'ecf9e5df20683a769c4a8a8f2d65de85' '6d32a88e76b0a97b0ce67d37ef6394aa' - '40d28d5f5009971c507e94c9639be4a1' - '6aff504ed5e860adc1b7317cd0780900' + '8ba06c2ce6129371548cc360ccca27f8' '55fccb1da0417a896b724f7cfc32dd5a' 'ab2aa42c2947148c2b1cac0ade6d1d55' 'd429b59d3cfb37b0624c6a4a71a7c2c0' @@ -133,16 +133,16 @@ md5sums=('4ef6a2f04f5cb1777ac3772eeccdc78f' '3d1e4a119f38cff0498bf8a67e94e4b3' '71fd2d0d448fc2fcd15415a1beed7109' '61ccbf573ee196e3edf53a512820b431' - 'e1715bbbabd42e7419755b09f60734aa' + 'd66c0e470e54a1551bdf60d8df85108d' 'b845de3e05c1734cce4b9ac5e8f1baaf' '6801f87992b44118a12b6dfe6ea68127' '5e69839659d65ddda35b8a9982dc29e9' '3afd18517bb765d1680f4fcc8d08c9cc' - 'ec6a9961e4d1b53ec1240c5979efff11' + '824e49d9b01fed295c704ab68908b464' 'fe5e31b833cc6707209e9d656b6eb53c' 'ecb52b9b7a9ac0c8988093c1dfdda635' '23d0e12b7ca1cc6ea6b993c1d7ff20b9' - '0b5b9e5385c7ae77e561812e96ce8161' + 'fd2414d9b0e611a95e858cae5736ccad' '755c05b833aca6c5be130972af052e8b' 'd8f80e5686d02555f044363f1ac17d97' '2596460462cf6c889cf8f95485537b20' diff --git a/abs/core/LinHES-config/issue b/abs/core/LinHES-config/issue index 00d4abd..8b13789 100644 --- a/abs/core/LinHES-config/issue +++ b/abs/core/LinHES-config/issue @@ -1,2 +1 @@ -LinHes diff --git a/abs/core/LinHES-config/mv_common.py b/abs/core/LinHES-config/mv_common.py index e4bef48..fa610b6 100755 --- a/abs/core/LinHES-config/mv_common.py +++ b/abs/core/LinHES-config/mv_common.py @@ -162,6 +162,16 @@ def restart_service(daemon): cmd = "sv restart %s" %daemon runcmd(cmd) +def check_service(daemon): + logging.info(" Checking status of service %s",daemon) + cmd = "sv status %s" %daemon + results = runcmd_output(cmd) + status = results.split()[0] + if status == "run:": + return True + else: + return False + def hup_service(daemon): logging.info(" hup service %s",daemon) cmd = "sv hup %s" %daemon diff --git a/abs/core/LinHES-config/mv_hostype.py b/abs/core/LinHES-config/mv_hostype.py index 59b05b6..2f2ceab 100755 --- a/abs/core/LinHES-config/mv_hostype.py +++ b/abs/core/LinHES-config/mv_hostype.py @@ -260,7 +260,7 @@ def hostypeprint(systemconfig): daemon_list='' daemon_remove_list='' run_mysqlnetwork = False - + restart_mbe = False profile_status="/etc/profile.d/z_myth_status.sh" myth_status="/usr/LH/bin/myth_status.sh" @@ -271,9 +271,12 @@ def hostypeprint(systemconfig): EnableNetwork = False run_mysqlnetwork = True if systemconfig.get("hostypec"): - setup_db() + logging.info(" Host type change detected, queuing restart of backend") + restart_mbe = True + + install_list=["nss-mdns", "mysql", "mythdb-initial", "avahi", "rpcbind", "nfs-utils", "local-website", "myth2ipod", "mythtv-status"] - daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd"] + daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd" ,"msg_daemon"] mv_common.link_file(myth_status,profile_status) @@ -290,7 +293,7 @@ def hostypeprint(systemconfig): setup_ntp(False,"null") setup_avahi(systemconfig.get("TEMPLATES")) install_list=["nss-mdns", "mysql", "mythdb-initial", "avahi", "rpcbind", "nfs-utils", "local-website", "myth2ipod", "mythtv-status"] - daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd"] + daemon_list=["mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs", "lighttpd" ,"msg_daemon"] EnableNetwork = True run_mysqlnetwork = True mv_common.link_file(myth_status,profile_status) @@ -303,6 +306,9 @@ def hostypeprint(systemconfig): install_list.append('certmaster') daemon_list.append('certmaster') + if systemconfig.get("hostypec"): + logging.info(" Host type change detected, queuing restart of backend") + restart_mbe = True elif systemconfig.get("SystemType") == "Slave_backend": logging.info("Slave backend system being configured") @@ -310,10 +316,8 @@ def hostypeprint(systemconfig): remove_avahi_service() mv_common.link_file(myth_status,profile_status) - if systemconfig.get("hostypec"): - setup_db() install_list = [ "nss-mdns", "rpcbind", "nfs-utils", "avahi", "libmysqlclient" ] - daemon_list = ["mythbackend", "rpcbind", "nfs-common", "netfs", "avahi" ] + daemon_list = ["mythbackend", "rpcbind", "nfs-common", "netfs", "avahi" ,"msg_daemon" ] daemon_remove_list=["mysql", "lighttpd", "certmaster"] @@ -326,6 +330,9 @@ def hostypeprint(systemconfig): daemon_list.append('xymon-client') setup_rsyslog_client(systemconfig.get("dbhost")) + if systemconfig.get("hostypec"): + logging.info(" Host type change detected, queuing restart of backend") + restart_mbe = True elif systemconfig.get("SystemType") == "Frontend_only": @@ -335,7 +342,7 @@ def hostypeprint(systemconfig): install_list=["mysql-clients", "libmysqlclient", "avahi", "rpcbind", "nfs-utils"] remove_list=["mysql","lighttpd"] - daemon_list=["nss-mdns", "mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs" ] + daemon_list=["nss-mdns", "mysql", "mythbackend", "avahi", "rpcbind", "nfs-common", "netfs" ,"msg_daemon"] daemon_remove_list=["mysql", "mythbackend","lighttpd"] if xymon_supported: install_list.append('xymonclient') @@ -361,16 +368,19 @@ def hostypeprint(systemconfig): if systemconfig.get("RunFrontend") == "1": logging.debug(" Will run the frontend") mv_common.add_service("frontend") - mv_common.add_service("hal") + #mv_common.add_service("hal") if data_config.SYSTEMTYPE == "MythVantage": mv_common.add_service("ghosd") else: logging.debug(" Will NOT run the frontend") mv_common.remove_service("frontend") - mv_common.add_service("hal") + #mv_common.add_service("hal") if data_config.SYSTEMTYPE == "MythVantage": mv_common.remove_service("ghosd") + if restart_mbe == True : + mv_common.restart_service("mythbackend") + if run_mysqlnetwork: setup_mysqlnetwork(EnableNetwork) diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py index c7a002d3..1d5f6fe 100755 --- a/abs/core/LinHES-config/mv_install.py +++ b/abs/core/LinHES-config/mv_install.py @@ -66,6 +66,14 @@ def kill_dhcp_chroot(): os.chdir(stddir) except: pass + #force kill + try: + cmd = "lsof -t /new_boot|xargs kill -9" + runcmd(cmd) + except: + print " !!!Problem killing all /new_boot pids" + + def statgrab(disk): cmd = "statgrab -M disk. |grep %s.write_bytes" % hostoptions["rootdisk"] @@ -590,14 +598,30 @@ def copy_it(install_type): if ( install_type == "upgrade"): logging.info("Upgrading system") - create_squashlist() - cmd = " unsquashfs -e %s -f -d %s /.livesys/medium/larch/system.sqf" %(data_config.SQUASHFILE, data_config.MOUNTPOINT) - #runcmd(cmd) - rc = runcmd(cmd)[0] - if rc != 0 : - error_out("Running unsquashfs") + cmdlist = ['rsync -avrp /image_mount/root/* /new_boot', + 'rsync -arvp /image_mount/lib/* /new_boot/lib/', + 'rsync -arvp /image_mount/usr /new_boot', + 'rsync -arvp /image_mount/var /new_boot'] + + #'rsync -arvp /image_mount/lib /new_boot', + + for cmd in cmdlist: + #runcmd(cmd) + rc = runcmd(cmd)[0] + if rc != 0 : + error_out("Running %s" %cmd) + + #create_squashlist() + #cmd = " unsquashfs -e %s -f -d %s /.livesys/medium/larch/system.sqf" %(data_config.SQUASHFILE, data_config.MOUNTPOINT) + + #rc = runcmd(cmd)[0] + #if rc != 0 : + # error_out("Running unsquashfs") #logging.debug(cmd) #cmdout=commands.getoutput(cmd) + + + # Create the missing dir i = ("sys", "proc", "dev", "tmp", "mnt", "media", "media/cdrom", "media/dvd", "var/log/mythtv", "var/lock", "var/tmp", "usr/lib/locale") mountpoint = data_config.MOUNTPOINT @@ -949,6 +973,8 @@ def fix_permissions(): runcmd(cmd) cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+"/var/log/mythtv") runcmd(cmd) + cmd = " chmod +s %s" %(data_config.MOUNTPOINT+"/usr/bin/ping") + runcmd(cmd) def apply_new_auth(): logging.info("_____Applying Password updates_______") diff --git a/abs/core/LinHES-config/mv_network.py b/abs/core/LinHES-config/mv_network.py index aab1345..d0fa16c 100755 --- a/abs/core/LinHES-config/mv_network.py +++ b/abs/core/LinHES-config/mv_network.py @@ -18,17 +18,32 @@ def setup_MYTH_DHCP(systemconfig): return defaultdhcp def all_interfaces(): - max_possible = 128 # arbitrary. raise if needed. - bytes = max_possible * 32 - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - names = array.array('B', '\0' * bytes) - outbytes = struct.unpack('iL', fcntl.ioctl( - s.fileno(), - 0x8912, # SIOCGIFCONF - struct.pack('iL', bytes, names.buffer_info()[0]) - ))[0] - namestr = names.tostring() - return [namestr[i:i+32].split('\0', 1)[0] for i in range(0, outbytes, 32)] + # read the file /proc/net/dev + ifacelist=[] + returnlist=[] + try: + f = open('/proc/net/dev','r') + # put the content to list + ifacelist = f.read().split('\n') + # close the file + f.close() + # remove 2 lines header + ifacelist.pop(0) + ifacelist.pop(0) + except: + logging.critical(" *Problem reading /proc/net/dev") + + # loop to check each line + for line in ifacelist: + ifacedata = line.replace(' ','').split(':') + # check the data have 2 elements + if len(ifacedata) == 2: + # check the interface is up (Transmit/Receive data) + if int(ifacedata[1]) > 0: + #print ifacedata[0] + returnlist.append(ifacedata[0]) + + return returnlist def get_ip(ifname): logging.debug(" Finding ip address for %s", ifname) @@ -43,12 +58,16 @@ def get_ip(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return socket.inet_ntoa(fcntl.ioctl( + + ip = socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) + logging.debug(" get_ip ip address is %s", ip) + return ip + def get_default_route(iface): rcroute = "127.0.0.1" f = open ('/proc/net/route', 'r') diff --git a/abs/core/LinHES-config/mv_screensaver.py b/abs/core/LinHES-config/mv_screensaver.py index 6a5ce1c..a1d1530 100755 --- a/abs/core/LinHES-config/mv_screensaver.py +++ b/abs/core/LinHES-config/mv_screensaver.py @@ -40,7 +40,7 @@ def mplayer_saver_check (cmd,templatefile): def killxscreensaver(): - logging.info(" Stopping xscreensaver") + logging.info(" Stopping xscreensaver") cmd="xscreensaver-command --exit " mv_common.runcmd(cmd) cmd="killall xscreensaver " @@ -160,6 +160,25 @@ def setup_gnome_screensaver(theme,idletime): logging.info("__End gnome screensaver") +def start_screensaver(screensaver): + logging.info(" Checking if screensaver needs to be started") + if mv_common.check_service("frontend"): + killxscreensaver() + logging.info(" Frontend is running, starting screensaver") + line='''su mythtv -c "DISPLAY=localhost:0 xscreensaver -no-splash 2>&1 > /dev/null &" \n''' + #line='''su mythtv -c "DISPLAY=localhost:0 xscreensaver -no-splash \&" ''' + try: + fout = open("/tmp/cmd.sh", "w") + fout.write(line) + fout.close() + os.chmod("/tmp/cmd.sh",0755) + cmd="/tmp/cmd.sh" + os.system(cmd) + os.remove("/tmp/cmd.sh") + except: + logging.info(" Couldn't start screensaver") + + def setup_screensaver (systemconfig,data_config): @@ -179,6 +198,7 @@ def setup_screensaver (systemconfig,data_config): mv_common.pacremove("gnome-screensaver") setup_x_screensaver(idletime, theme, configfile, templatefile) mplayer_saver_check("/usr/bin/xscreensaver-command -deactivate &",mtemplate) + start_screensaver("xscreensaver") elif screensavertype == "gscreensaver": mv_common.pacinstall("xscreensaver") diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py index 9a9cd11..baa7142 100755 --- a/abs/core/LinHES-config/systemconfig.py +++ b/abs/core/LinHES-config/systemconfig.py @@ -110,6 +110,12 @@ def main(argv): if cmdmodule["network"]: restartfe = mv_network.setup_network(systemconfig, cmdmodule["this_is_install"]) + systemconfig["mythip"] = mv_network.setup_MYTH_IP(systemconfig) + systemconfig["mythdhcp"] = mv_network.setup_MYTH_DHCP(systemconfig) + systemconfig["mythgw"] = mv_network.setup_MYTH_DHCP(systemconfig) + systemconfig["mythdns"] = mv_network.setup_MYTH_DHCP(systemconfig) + cmdmodule["hostype"] = True + if restartfe == True : logging.debug(" Setting the frontend to restart due to network change") cmdmodule["restartfe"] = True @@ -129,11 +135,11 @@ def main(argv): mv_hostype.hostypeprint(systemconfig) cmdmodule["smolt"] = True - if cmdmodule["network"]: - restartfe = mv_network.setup_network(systemconfig, cmdmodule["this_is_install"]) - if restartfe == True : - logging.debug(" Setting the frontend to restart due to network change") - cmdmodule["restartfe"] = True + #if cmdmodule["network"]: + #restartfe = mv_network.setup_network(systemconfig, cmdmodule["this_is_install"]) + #if restartfe == True : + #logging.debug(" Setting the frontend to restart due to network change") + #cmdmodule["restartfe"] = True -- cgit v0.12