diff options
author | Bob Igo <bob@stormlogic.com> | 2009-06-06 20:51:42 (GMT) |
---|---|---|
committer | Bob Igo <bob@stormlogic.com> | 2009-06-06 20:51:42 (GMT) |
commit | 9c88cd43e4ac8a83bd5eb77616ba0d13f08a891a (patch) | |
tree | 8d92e12969a08ece07657486b877ad841fd31dcc | |
parent | 8dd571de2d83b945fef01103fbe8c241e774f0e3 (diff) | |
parent | c13eeafc9aa43d7b2c4a457987409e9da03af481 (diff) | |
download | linhes_pkgbuild-9c88cd43e4ac8a83bd5eb77616ba0d13f08a891a.zip linhes_pkgbuild-9c88cd43e4ac8a83bd5eb77616ba0d13f08a891a.tar.gz linhes_pkgbuild-9c88cd43e4ac8a83bd5eb77616ba0d13f08a891a.tar.bz2 |
merge, plus some robustness options for install_db_chroot.sh
44 files changed, 3772 insertions, 1584 deletions
@@ -15,3 +15,4 @@ pkg mythbeselect.bin mythinstall.bin srclinks.* +*.pyc diff --git a/abs/core-testing/LinHES-config-svn/install_db_chroot.sh b/abs/core-testing/LinHES-config-svn/install_db_chroot.sh index 6dcbfd5..808dbb9 100755 --- a/abs/core-testing/LinHES-config-svn/install_db_chroot.sh +++ b/abs/core-testing/LinHES-config-svn/install_db_chroot.sh @@ -6,7 +6,7 @@ myhost=$hostname hostname $myhost echo $myhost > /etc/hostname -echo "install_db_chroot hostname is $hostname" +echo "$0 hostname is $hostname" . $MV_ROOT/bin/install_functions.sh #myhost=`cat /etc/hostname` @@ -16,8 +16,9 @@ echo "install_db_chroot hostname is $hostname" # that the database can be initialized. /etc/rc.d/mysqld stop -/etc/rc.d/mysqld stop +killall -9 mysqld /etc/rc.d/mysqld start +sleep 1 # Put a limit on how many times we try to (re-)start MySQL success_test() { @@ -49,6 +50,7 @@ while true; do else echo "MySQL server is not running. Trying to start it." # Maybe it just needs to be started + sleep 1 /etc/rc.d/mysqld start mysqld_tries=$((mysqld_tries + 1)) success_test $mysqld_tries @@ -58,7 +60,9 @@ while true; do else echo "MySQL server may not be installed. Trying to install it." # Maybe it's not installed; try (re-)installing it and starting it + sleep 1 pacman --noconfirm -Sf mysql + sleep 1 /etc/rc.d/mysqld start mysqld_tries=$((mysqld_tries + 1)) success_test $mysqld_tries diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index 1d925e5..7bd6369 100644..100755 --- a/abs/core-testing/LinHES-config/PKGBUILD +++ b/abs/core-testing/LinHES-config/PKGBUILD @@ -1,12 +1,12 @@ pkgname=LinHES-config pkgver=1.0 -pkgrel=413 +pkgrel=430 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev ) pkgdesc="Install and configure your system" -depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync ) +depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted ) arch=('i686') -source=(mythinstall.bin myth_user_call file_time_offset.py install-ui.xml install_proxy.sh install_functions.sh systemconfig.sh install_db_chroot.sh restore_default_settings.sh xconfig.sh timezip.py soundconfig.sh LinHES-release issue MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh timezone.bin autocard.py restore_km_db_chroot.sh README ir_config.sh) +source=(mv_install.py mv_config.py mythinstall.bin myth_user_call file_time_offset.py install-ui.xml install_proxy.sh install_functions.sh systemconfig.sh install_db_chroot.sh restore_default_settings.sh xconfig.sh timezip.py soundconfig.sh LinHES-release issue MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh timezone.bin autocard.py restore_km_db_chroot.sh README ir_config.sh mv_advanced.py mv_common.py mv_ir.py mv_misc.py mv_network.py mv_screensaver.py mv_smolt.py mv_software.py mv_webuser.py mv_hostype.py systemconfig.py) install=LinHES.install build() { @@ -17,18 +17,15 @@ build() { mkdir $startdir/pkg/etc/profile.d install -m 0755 MythVantage.sh $startdir/pkg/etc/profile.d/MythVantage.sh mkdir -p $MVDIR/bin - # mkdir -p $MVDIR/templates mkdir -p $MVDIR/etc -#copy in all the installer specific stuff -# rsync -r --exclude=.svn ../templates $MVDIR/ + #copy in all the installer specific stuff install -m0700 myth_user_call $MVDIR/bin/myth_user_call install -m 0755 install_proxy.sh $MVDIR/bin/install_proxy.sh install -m 0755 install_functions.sh $MVDIR/bin/install_functions.sh install -m 0755 systemconfig.sh $MVDIR/bin/systemconfig.sh install -m 0755 xconfig.sh $MVDIR/bin/xconfig.sh install -m 0755 ir_config.sh $MVDIR/bin/ir_config.sh -# install -m 0755 live-install.sh $MVDIR/bin/live-install.sh install -m 0755 install_db_chroot.sh $MVDIR/bin/install_db_chroot.sh install -m 0755 restore_km_db_chroot.sh $MVDIR/bin/restore_km_db_chroot.sh install -m 0755 restore_default_settings.sh $MVDIR/bin/restore_default_settings.sh @@ -39,29 +36,38 @@ build() { install -m 0755 timezone.bin $MVDIR/bin/timezone.bin install -m 0755 timezip.py $MVDIR/bin/timezip.py install -m 0755 autocard.py $MVDIR/bin/autocard.py - - + install -m 0755 mv_config.py $MVDIR/bin/mv_config.py + install -m 0755 mv_install.py $MVDIR/bin/mv_install.py + install -m 0755 mv_advanced.py $MVDIR/bin/ + install -m 0755 mv_common.py $MVDIR/bin/ + install -m 0755 mv_ir.py $MVDIR/bin/ + install -m 0755 mv_misc.py $MVDIR/bin/ + install -m 0755 mv_network.py $MVDIR/bin/ + install -m 0755 mv_screensaver.py $MVDIR/bin/ + install -m 0755 mv_smolt.py $MVDIR/bin/ + install -m 0755 mv_software.py $MVDIR/bin/ + install -m 0755 mv_webuser.py $MVDIR/bin/ + install -m 0755 mv_hostype.py $MVDIR/bin/ + install -m 0755 systemconfig.py $MVDIR/bin/ + + #README file displayed on install install -m 0755 README $MVDIR/README mkdir -p $startdir/pkg/usr/bin install -m 0755 file_time_offset.py $startdir/pkg/usr/bin/file_time_offset.py - #copy in the branding stuff + + #Copy in the branding stuff install -m 0755 LinHES-release $startdir/pkg/etc/LinHES-release install -m 0755 issue $startdir/pkg/etc/issue -# copy over the ui files + # copy over the ui files install -m 0755 install-ui.xml $startdir/pkg/usr/share/mythtv/themes/default/ -#copy in the binaries - #install -g mythtv -m 4750 mythinstall.bin $MVDIR/bin/MythVantage + #copy in the binaries install -m 4755 mythinstall.bin $MVDIR/bin/MythVantage cd $MVDIR/bin ln -s MythVantage mythvantage ln -s MythVantage mythinstall cd - -# install -g mythtv -m 4750 mythbeselect.bin $MVDIR/bin/mythbeselect - -# install -m 0755 startx $startdir/pkg/root/startx -# install -m 0755 live-install.sh $startdir/pkg/root/live-install.sh } diff --git a/abs/core-testing/LinHES-config/install_db_chroot.sh b/abs/core-testing/LinHES-config/install_db_chroot.sh index 6dcbfd5..808dbb9 100755 --- a/abs/core-testing/LinHES-config/install_db_chroot.sh +++ b/abs/core-testing/LinHES-config/install_db_chroot.sh @@ -6,7 +6,7 @@ myhost=$hostname hostname $myhost echo $myhost > /etc/hostname -echo "install_db_chroot hostname is $hostname" +echo "$0 hostname is $hostname" . $MV_ROOT/bin/install_functions.sh #myhost=`cat /etc/hostname` @@ -16,8 +16,9 @@ echo "install_db_chroot hostname is $hostname" # that the database can be initialized. /etc/rc.d/mysqld stop -/etc/rc.d/mysqld stop +killall -9 mysqld /etc/rc.d/mysqld start +sleep 1 # Put a limit on how many times we try to (re-)start MySQL success_test() { @@ -49,6 +50,7 @@ while true; do else echo "MySQL server is not running. Trying to start it." # Maybe it just needs to be started + sleep 1 /etc/rc.d/mysqld start mysqld_tries=$((mysqld_tries + 1)) success_test $mysqld_tries @@ -58,7 +60,9 @@ while true; do else echo "MySQL server may not be installed. Trying to install it." # Maybe it's not installed; try (re-)installing it and starting it + sleep 1 pacman --noconfirm -Sf mysql + sleep 1 /etc/rc.d/mysqld start mysqld_tries=$((mysqld_tries + 1)) success_test $mysqld_tries diff --git a/abs/core-testing/LinHES-config/mv_advanced.py b/abs/core-testing/LinHES-config/mv_advanced.py new file mode 100755 index 0000000..01351df --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_advanced.py @@ -0,0 +1,377 @@ +# -*- coding: utf-8 -*- +import logging, os, re +import mv_common + +def setup_pacman(create_link): + if create_link: + logging.info(" Creating pacman link") + #LOOK + #This is not implmented yet, below is the bash code for reference + #if [ ! x$1 = x ] + #then + #ln -s ${BASE}/data/var ${BASE}/data/srv/httpd/htdocs/repo + #echo "creating the link for the pacman repo mirror" + #fi + + #for i in mv-core mv-core-testing mv-extra mv-extra-testing + #do + #echo "[$i]" > ${BASE}/etc/pacman.d/$i + ##add mirror if needed + #if [ x$PKG_MIRROR = x1 ] + #then + #echo " Server = http://$dbhost/repo/$i " >> ${BASE}/etc/pacman.d/$i + #fi + ##add user templates + #USERTEMPLATES="/data/home/mythtv/templates" + #if [ -f $USERTEMPLATES/sources/$i ] + #then + #echo "Adding user $i" + #cat $USERTEMPLATES/sources/$i >> ${BASE}/etc/pacman.d/$i + #fi + #cat $TEMPLATES/sources/$i >> ${BASE}/etc/pacman.d/$i + #echo "setting local mirror to $dbhost for $i " + #done + else: + logging.info(" Pacman link will not be created") + return + +def setup_ncid_client(dbhost,templatefile): + #This always runs + logging.debug(" Configuring ncid client with server %s",dbhost) + cmd = '''sed -e "s/^set Host.*$/set Host %s /" %s >/etc/ncid/ncid.conf''' %(dbhost, templatefile) + return + +def setup_ncid_daemon(port,templatefile,Runncidd): + logging.info(" Configuring callerid daemon") + if Runncidd == "1": + logging.debug(" Port: %s",port) + mv_common.cp_and_log("/etc/ncid/ncidd.conf",templatefile) + cmd = '''sed -e "s/.*set ttyport.*$/set ttyport = \/dev\/%s /" %s >/etc/ncid/ncidd.conf''' %(port,templatefile) + mv_common.runcmd(cmd) + mv_common.pacinstall("ncidd") + mv_common.add_service("ncidd") + else: + logging.debug(" Callerid will not run") + mv_common.pacremove("ncidd") + mv_common.remove_service("ncidd") + return + +def setup_splash(Usebootsplash): + if Usebootsplash == "1": + logging.info(" Enabling splash") + cmd = ''' sed -i "s/^default.*0/default 1/g" /boot/grub/menu.lst''' + mv_common.runcmd(cmd) + else: + logging.info(" Disabling splash") + cmd = ''' sed -i "s/^default.*1/default 0/g" /boot/grub/menu.lst''' + mv_common.runcmd(cmd) + return + +def setup_hobbit(UseHobbit,SystemType,dbhost): + if UseHobbit == "1": + if SystemType == "Standalone" or SystemType == "Master_backend": + logging.info(" Installing hobbit server") + mv_common.pacinstall("hobbitserver") + mv_common.add_service("hobbit") + else: + logging.info(" Installing hobbit client") + mv_common.pacinstall("hobbit-client") + setup_hobbit_client(dbhost) + mv_common.add_service("hobbit-client") + + else: + logging.info(" Removing Hobbit") + mv_common.pacremove("hobbit") + mv_common.pacremove("hobbit-client") + mv_common.remove_service("hobbit-client") + mv_common.remove_service("hobbitserver") + cmd = "rm -f /data/srv/httpd/htdocs/hobbit/index.html" + mv_common.runcmd(cmd) + return + +def setup_hobbit_client(dbhost): + logging.info(" Configuring hobbit client") + logging.debug(" hobbit server is %s:", dbhost) + cmd='''sed -i "s/^BBDISP.*$/BBDISP=%s/g" /data/srv/hobbit/client/etc/hobbitclient.cfg ''' %dbhost + mv_common.runcmd(cmd) + return + +def setup_evrouter(UseEvrouter,EvrouterConfig,template): + if UseEvrouter == "1": + logging.info(" Configuring everouter") + logging.debug(" EvrouterConfig is %s:",EvrouterConfig) + if EvrouterConfig == "tinker": + logging.debug(" tinker mode, not changing the config") + return + mv_common.pacinstall("evrouter") + mv_common.pacinstall("Xvfb") + mv_common.cp_and_log(template+"/evrouter/"+EvrouterConfig,"/etc/evrouter.cfg") + mv_common.add_service("evrouter") + mv_common.add_service("Xvfb") + else: + logging.info(" Not using evrouter") + mv_common.pacremove("evrouter") + mv_common.remove_service("evrouter") + mv_common.remove_service("Xvfb") + + return + +def setup_DNSmasq(RunDHCP,ip,gw,nameserver): + if RunDHCP == "1": + logging.info(" Configuring dhcp server(dnsmasq)") + logging.debug(" ip: %s", ip) + logging.debug(" gw: %s", gw) + logging.debug(" ns: %s", nameserver) + mv_common.pacinstall("dnsmasq") + mv_common.pacinstall("mvpmc") + mv_common.add_service("dnsmasq") + logging.debug(" Setting default route to my gw: %s",gw) + try: + f = open("/etc/dnsmasq.conf",'r') + dnsconf = f.readlines() + f.close() + except: + logging.info(" Couldn't open dnsmasq.conf") + return + for line in dnsconf: + outline = line + if re.match("^dhcp-option=3",line): + logging.debug(" Setting default route to my gw: %s",gw) + outline = "dhcp-option=3,%s\n" %gw + if re.match("^dhcp-option=6",line): + logging.debug(" Setting dns to my ip: %s",ip) + outline = "dhcp-option=6,%s\n" %ip + f.write(outline) + f.close() + + logging.debug(" change nfsroot to my ip:%s",ip) + cmd = '''sed -i "s/nfsroot=.*:/nfsroot=%s:/g" /data/srv/tftp/pxelinux.cfg/default''' %ip + mv_common.runcmd(cmd) + + logging.debug(" Adding 127.0.0.1 to resolv.conf") + logging.debug(" other nameserver is %s",nameserver) + try: + f = open("/etc/resolv.conf",'r') + dns = f.readlines() + f.close() + except: + dns='' + logging.debug(" Couldn't open resolv.conf for reading") + try: + f = open("/etc/resolv.conf",'w') + line="search lan\n" + f.write(line) + line="nameserver 127.0.0.1\n" + f.write(line) + line="nameserver %s\n" %nameserver + f.write(line) + for line in dns: + f.write(line) + f.close() + except: + logging.debug(" Couldn't open resolv.conf for writing") + + logging.debug(" setup dongle.config") + cmd = ''' sed -i "s/mvpmc -f .*/mvpmc -f \/etc\/helvR10.fon -s %s \& /" /data/srv/tftp/dongle.bin.config ''' %ip + #COMMAND="%s/mvpmc -f .*/mvpmc -f \/etc\/helvR10.fon -s ${ip} \& /" + #ex ${BASE}/data/srv/tftp/dongle.bin.config <<EOF + mv_common.runcmd(cmd) + else: + logging.info(" removing dhcp server(dnsmasq)") + mv_common.pacremove("dnsmasq") + mv_common.pacremove("mvpmc") + mv_common.remove_service("dnsmasq") + return + +def setup_mythweb(UseMythWEB): + if UseMythWEB == "1": + logging.info(" Activating mythweb") + mv_common.pacinstall("lighttpd") + mv_common.pacinstall("mythweb") + mv_common.add_service("lighttpd") + else: + logging.info(" Removing mythweb") + mv_common.pacremove("lighttpd") + mv_common.pacremove("mythweb") + mv_common.remove_service("lighttpd") + return + +def setup_samba(systemconfig,data_config): + mythhome = data_config.MYTHHOME + if systemconfig["UseSamba"] == "1": + logging.info(" Activating windows file sharing") + usersamba=mythhome+"/templates/smb.conf" + mv_common.pacinstall("samba") + if not os.path.exists("/etc/samba"): + logging.debug(" Creating directory /etc/samba") + try: + os.makedirs("/etc/samba") + except: + pass + + if os.path.exists(usersamba): + logging.debug(" Using user provided config file %s",usersamba) + cmd = "install -D -m755 %s /etc/samba/smb.conf" %usersamba + mv_common.runcmd(cmd) + else: + Samba_media = systemconfig["Samba_media"] + Samba_home = systemconfig["Samba_home"] + if systemconfig["Samba_mediareadonly"] == "1": + smreadonly = "yes" + else: + smreadonly = "no" + + if systemconfig["Samba_homereadonly"] == "1": + shreadonly = "yes" + else: + shreadonly = "no" + domain = systemconfig["Samba_domain"] + servername = systemconfig["hostname"] + + try: + f = open(systemconfig["TEMPLATES"]+"/samba/smb.conf.template",'r') + t_smbconf = f.readlines() + f.close() + except: + logging.info(" Couldn't open samba template file") + return + + try: + f = open("/etc/samba/smb.conf",'w') + except: + logging.info(" Couldn't open samba file") + return + + for line in t_smbconf: + outline = line + if re.match("^.*workgroup", line): + logging.debug(" Setting workgroup to %s",domain) + outline="workgroup = %s\n" %domain + logging.debug(" %s",outline) + if re.match("^.* server string",line): + logging.debug(" Setting server name to %s",servername) + outline="server string = %s\n" %servername + logging.debug(" %s",outline) + f.write(outline) + outline="include = %s/templates/user.shares \n" %mythhome + f.write(outline) + if Samba_media == "1": + outline="include = /etc/samba/smb.conf.media\n" + f.write(outline) + if Samba_home == "1": + outline="include = /etc/samba/smb.conf.home\n" + f.write(outline) + f.close() + logging.info(" Writing smb.conf.media") + try: + f = open("/etc/samba/smb.conf.media","w") + except: + logging.info(" Couldn't open smb.conf.media") + return + medialines=''' +[%s] +path = %s +public = yes +only guest = yes +writeable = %s +printable = no +force user = mythtv +force group = mythtv +create mask = 0755''' %(data_config.SMEDIA,data_config.DATAMOUNT,smreadonly) + f.write(medialines) + f.close + logging.debug(" %s",medialines) + logging.info(" Writing smb.conf.home") + try: + f = open("/etc/samba/smb.conf.home","w") + except: + logging.info(" Couldn't open smb.conf.home") + return + homelines=''' +[home] +path = %s +public = yes +only guest = yes +writeable = %s +printable = no +force user = mythtv +force group = mythtv +create mask = 0755 ''' %(data_config.MYTHHOME,shreadonly) + f.write(homelines) + f.close + logging.debug(" %s",homelines) + + + mv_common.add_service("nmbd") + mv_common.add_service("smbd") + else: + logging.info(" Removing windows file sharing") + mv_common.remove_service("smbd") + mv_common.remove_service("nmbd") + mv_common.pacremove("samba") + mv_common.pacinstall("smbclient") + return + +def setup_NFSshares(UseNFS,templatefile): + if UseNFS == "1": + logging.info(" Activating NFS server") + mv_common.pacinstall("nfs-utils") + mv_common.pacinstall("portmap") + cmd = '''sed -e "s/REPLACEME/*/g" %s >/etc/exports''' %templatefile + mv_common.add_service("nfsd") + mv_common.add_service("nfs-utils") + mv_common.add_service("portmap") + else: + logging.info(" Removing NFS server") + mv_common.remove_service("nfsd") + return + +def setup_dyndns(DDnsEnable): + if DDnsEnable == "1": + logging.info(" Installing Dynamic DNS client") + mv_common.pacinstall("inadyn") + mv_common.add_service("inadyn") + else: + logging.info(" Removing Dynamic DNS client") + mv_common.pacremove("inadyn") + mv_common.remove_service("inadyn") + + +def setup_advanced(systemconfig,data_config): + logging.info("____Start of advanced configuration____") + create_link = False + if systemconfig["SystemType"] == "Master_backend": + create_link = True + setup_pacman(create_link) + setup_ncid_client(systemconfig["dbhost"], + systemconfig["TEMPLATES"]+"/ncid.conf.template") + + setup_ncid_daemon(systemconfig["nciddSerialPort"], + systemconfig["TEMPLATES"]+"/ncidd.conf.template", + systemconfig["Runncidd"]) + + setup_splash(systemconfig["Usebootsplash"]) + if data_config.SYSTEMTYPE == "MythVantage": + setup_hobbit(systemconfig["UseHobbit"], + systemconfig["SystemType"], + systemconfig["dbhost"]) + + setup_evrouter(systemconfig["UseEvrouter"], + systemconfig["EvrouterConfig"], + systemconfig["TEMPLATES"]) + systemconfig["mythip"]="192.168.100.myip" + systemconfig["mythgw"]="192.168.100.mygw" + systemconfig["mythdns"]="192.168.100.100" + + setup_DNSmasq(systemconfig["RunDHCP"], + systemconfig["mythip"], + systemconfig["mythgw"], + systemconfig["mythdns"]) + + setup_mythweb(systemconfig["UseMythWEB"]) + setup_samba(systemconfig,data_config) + setup_NFSshares(systemconfig["UseNFS"], + systemconfig["TEMPLATES"]+"/exports.template") + + setup_dyndns(systemconfig["DDnsEnable"]) + logging.info("__End of advanced configuration\n") diff --git a/abs/core-testing/LinHES-config/mv_common.py b/abs/core-testing/LinHES-config/mv_common.py new file mode 100755 index 0000000..9b33454 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_common.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +import logging, os, time +import commands +config_file = "mv_config" +data_config = __import__(config_file, globals(), locals(), []) + +def runcmd(cmd): + if data_config.NOOPDEBUG=="FALSE": + pass + else: + cmd = "echo "+cmd + logging.debug(" %s",cmd) + cmdout = commands.getstatusoutput(cmd) + logging.debug(" %s",cmdout) + return cmdout[0] + +def services(systemconfig): + logging.debug("______Start of services______") + logging.debug("__End services") + +def cp_and_log(srcfile,destfile): + #return + if not os.path.exists(srcfile): + logging.info("%s is not present, skipping...",srcfile) + else: + cmd = ("rsync -arhp %s %s") %(srcfile,destfile) + runcmd(cmd) + + +def add_service(daemon): + logging.info(" Adding service %s",daemon) + cmd = "add_service.sh %s" %daemon + runcmd(cmd) + +def remove_service(daemon): + logging.info(" Removing service %s",daemon) + cmd = "remove_service.sh %s" %daemon + runcmd(cmd) + +def start_service(daemon): + logging.info(" start service %s",daemon) + cmd = "sv start %s" %daemon + runcmd(cmd) + +def stop_service(daemon): + logging.info(" stop service %s",daemon) + cmd = "sv stop %s" %daemon + runcmd(cmd) + +def restart_service(daemon): + logging.info(" Restarting service %s",daemon) + if daemon == "lcdd": + stop_service(daemon) + logging.debug(" killing all lcdd") + cmd = "killall -9 LCDd" + runcmd(cmd) + time.sleep(2) + start_service(daemon) + else: + cmd = "sv restart %s" %daemon + runcmd(cmd) + +def hup_service(daemon): + logging.info(" hup service %s",daemon) + cmd = "sv hup %s" %daemon + runcmd(cmd) + + + +def pkg_blacklist_check(pkg): + cmd = '''grep -q %s /etc/blacklist.package''' %pkg + rc = runcmd(cmd) + if rc == 0: + return True + else: + return False + +def pkg_installed_check(pkg): + logging.debug(" Checking if %sis installed",pkg) + cmd = "pacman -Q %s " %pkg + rc = runcmd(cmd) + if rc == 0: + return True + else: + return False + + +def pacinstall(pkg): + logging.info(" Checking %s for install",pkg) + #extra pkg check + if pkg == "xine": + pacinstall("xine-ui") + elif pkg == "dvdcss": + pacinstall("libdvdcss") + elif pkg == "webmin": + add_service("webmin") + + if not pkg_blacklist_check(pkg): + if pkg_installed_check(pkg): + logging.info(" %s is already installed, will not install",pkg) + else: + logging.info(" Installing %s",pkg) + cmd ='''pacman --noconfirm -Sf %s ''' %pkg + runcmd(cmd) + else: + logging.info(" %s is blacklisted, will not install",pkg) + +def pacremove(pkg): + logging.info(" Checking %s for removal",pkg) + if pkg == "xine": + pacremove("xine-ui") + elif pkg == "dvdcss": + pacremove("libdvdcss") + elif pkg == "webmin": + remove_service("webmin") + + if not pkg_blacklist_check(pkg): + if not pkg_installed_check(pkg): + logging.info(" %s is not installed, will not remove",pkg) + else: + logging.info(" Removing %s",pkg) + cmd ='''pacman --noconfirm -R %s ''' %pkg + runcmd(cmd) + else: + logging.info(" %s is blacklisted, will not remove",pkg) + +def getpid(process): + return commands.getoutput('pidof %s' % process) + + +def restartLCD(RESTART_LCD): + if RESTART_LCD : + logging.info(" Restarting lcd server") + cmd = "killall -9 mythlcdserver" + runcmd(cmd) + else: + logging.debug(" Not restarting MYTHLCD server") + + +def reloadfe(dbhost,RESTART_LCD): + logging.debug("____Start of reloadfe____") + logging.info(" Clearing Backend cache") + cmd = '''/usr/bin/backend_control.sh clearcache behost %s''' %dbhost + runcmd(cmd) + restartLCD(RESTART_LCD) + for pid in getpid("mythfrontend"): + cmd = ''' kill -s USR1 %s ''' %pid + #runcmd(cmd) + logging.info(" Reloading frontend with pid of %s",pid) + + logging.debug("__End of reloadfe\n") + + +def restartfe(RESTART_LCD): + logging.debug("____Start of restartfe____") + if data_config.SYSTEMTYPE=="LinHES": + logging.debug(" LinHES seems to be running will not restartfe") + return + logging.info(" Restarting frontend") + restartLCD(RESTART_LCD) + cmd="killall -9 mythfrontend" + runcmd(cmd) + cmd="killall -9 welcome" + runcmd(cmd) + logging.debug("__End of restartfe\n") + + +def udev_trigger(): + logging.info(" Triggering udev") + cmd = "udevadm settle" + runcmd(cmd) + cmd = "udevadm trigger" + runcmd(cmd) + cmd = "udevadm settle" + runcmd(cmd) + cmd = "udevadm trigger" + runcmd(cmd) + + diff --git a/abs/core-testing/LinHES-config/mv_config.py b/abs/core-testing/LinHES-config/mv_config.py new file mode 100755 index 0000000..d5a247d --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_config.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +SYSTEMTYPE="LinHES" +MVHOSTNAME="larch5" +MOUNTPOINT="/new_boot" +DATAMOUNT="/myth" +MYTHHOME="/home/mythtv" +SQUASHFILE="/tmp/.squashlist" +SQUASHLIST=("bin","boot","etc","home","lib","opt","root","sbin","usr","var","data") +NOOPDEBUG="FALSE" +BACKUPFILE="mythconverg.sql.gz" +BACKUPPATH="/myth/backup/" +TEMP_TEMPLATES="/tmp/templates" +SMEDIA="/myth" + + + + diff --git a/abs/core-testing/LinHES-config/mv_hostype.py b/abs/core-testing/LinHES-config/mv_hostype.py new file mode 100755 index 0000000..0bbd16e --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_hostype.py @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- +import logging, mv_common +import os + +config_file = "mv_config" +data_config = __import__(config_file, globals(), locals(), []) + +def setup_ntp(usepool,ntpserver): + if usepool: + logging.info("Setting ntp server to %s",ntpserver) + print '''sed -i "s/pool.ntp.org/$dbhost/g" ${BASE}/etc/ntp.conf''' + else: + logging.info("Not changing ntp configuration") + +def setup_avahi(templates): + file="/etc/avahi/services/mysql.service" + if not os.path.exists(file): + logging.debug(" copying in mysql.service for avahi") + try: + os.makedirs("/etc/avahi/services") + except: + logging.debug(" Couldn't create /etc/avahi/services") + mv_common.cp_and_log(template+"/mysql.service",file) + cmd="sudo sv restart avahi" + mv_common.runcmd(cmd) + +def remove_avahi_service(): + file="/etc/avahi/services/mysql.service" + if os.path.exists(file): + logging.debug(" Removing avahi mysql.service file") + cmd="rm -rf %s" %file + runcmd(cmd) + cmd="sudo sv restart avahi" + mv_common.runcmd(cmd) + +def setup_db(): + logging.debug(" Setting up the database") + +def setup_mysqlnetwork(): + logging.debug(" Setting up mysql network") + +def setup_mysql(): + logging.debug(" Configuring mysql") + +def setup_func_key(): + if data_config.SYSTEMTYPE == "MythVantage": + logging.debug(" Grabbing the key for Func") + cmd="/usr/MythVantage/bin/grabkey.py" + mv_common.runcmd(cmd) + +def setup_func_minion(dbhost): + logging.info(" Setting up the func minion:") + logging.debug(" certmaster is %s:",dbhost) + cmd='''sed -i "s/^certmaster.*$/certmaster = %s/" /etc/func/minion.conf ''' %dbhost + mv_common.runcmd(cmd) + +def setup_syslog(dbhost): + logging.debug(" Setting syslog to log to %s",dbhost) + cmd ='''sed -i "s/^destination d_remote.*$/destination d_remote \{tcp\(\"%s\" port\(514\)\) \;\} \;/" /etc/syslog-ng.conf''' %dbhost + return + +def hostypeprint(systemconfig): + logging.info("______Start of hostype config_____") + mv_common.services(systemconfig) + install_list='' + remove_list='' + daemon_list='' + daemon_remove_list='' + + if systemconfig["SystemType"] == "Standalone": + logging.info("Stand alone system being configured") + setup_ntp(False,"null") + remove_avahi_service() + if systemconfig["hostypec"]: + setup_db() + install_list=("mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status") + daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd") + + elif systemconfig["SystemType"] == "Master_backend": + logging.info("Master backend system being configured") + setup_ntp(False,"null") + setup_avahi(systemconfig["TEMPLATES"]) + install_list=("mysql", "mythdb-initial", "avahi", "portmap", "nfs-utils", "local-website", "myth2ipod", "mythtv-status") + daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd") + if data_config.SYSTEMTYPE == "MythVantage": + install_list.append('func') + install_list.append('certmaster') + daemon_list.append('certmaster') + + elif systemconfig["SystemType"] == "Slave_backend": + logging.info("Slave backend system being configured") + setup_ntp(True,systemconfig["dbhost"]) + remove_avahi_service() + if systemconfig["hostypec"]: + setup_db() + install_list=("portmap", "nfs-utils", "local-website", "avahi", 'libmysqlclient') + daemon_list=("mythbackend", "portmap", "nfs-utils", "netfs", "lighttpd", "avahi") + daemon_remove_list=('mysql') + if data_config.SYSTEMTYPE == "MythVantage": + install_list.remove("local-website") + daemon_list.remove("lighttpd") + install_list.append('func') + daemon_list.append('funcd') + remove_list.append("lighttpd") + + + elif systemconfig["SystemType"] == "Frontend_only": + logging.info("Frontend only system being configured") + setup_ntp(True,systemconfig["dbhost"]) + remove_avahi_service() + install_list=("mysql-clients", "libmysqlclient", "avahi", "portmap", "nfs-utils", "local-website") + remove_list=("mysql") + daemon_list=("mysql", "mythbackend", "avahi", "portmap", "nfs-utils", "netfs", "lighttpd") + daemon_remove_list=("mysql", "mythbackend") + if data_config.SYSTEMTYPE == "MythVantage": + install_list.remove("local-website") + daemon_list.remove("lighttpd") + install_list.append('func') + daemon_list.append('funcd') + remove_list.append("lighttpd") + + + + for pkg in install_list: + mv_common.pacinstall(pkg) + for pkg in remove_list: + mv_common.pacinstall(pkg) + for daemon in daemon_list: + mv_common.add_service(daemon) + for daemon in daemon_remove_list: + mv_common.remove_service(daemon) + if systemconfig["RunFrontend"] == "1": + logging.debug(" Will run the frontend") + mv_common.add_service("frontend") + mv_common.add_service("hal") + else: + logging.debug(" Will NOT run the frontend") + mv_common.remove_service("frontend") + mv_common.remove_service("hal") + + setup_mysqlnetwork() + setup_mysql() + if data_config.SYSTEMTYPE == "MythVantage": + setup_func_minion(dbhost) + setup_func_key() + setup_syslog(systemconfig["dbhost"]) + logging.info("__End of hostype config\n") diff --git a/abs/core-testing/LinHES-config/mv_install.py b/abs/core-testing/LinHES-config/mv_install.py new file mode 100755 index 0000000..1281932 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_install.py @@ -0,0 +1,1241 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import sys, os, commands, glob, time +import getopt, re, MySQLdb +import logging +try: + import parted +except: + print "module parted not found" + +def usage(): + print "help text:" + print "example usage: --rootdisk=sda --rootfs=ext4 --rootsize=34240 --datafs=ext4 --datasize=3400 --datadisk=sda --swapsize=340 -c full_install" + +def clean_upgrade(): + return False + +def update_db(value, data): + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + try: + cursor = db.cursor() + cursor.execute("DELETE FROM settings where value=%s and hostname=%s;", (value, data_config.MVHOSTNAME)) + cursor.execute("REPLACE INTO settings set value=%s, data=%s, hostname=%s;", (value, data, data_config.MVHOSTNAME)) + logging.debug("Updated database with %s, %s", data, value) + except MySQLdb.Error, e: + logging.debug("Unable to update database with %s, %s", data, value) + + +def progress(pgnum): + progressline = str(pgnum) + "% complete" + logging.debug("Progress: %s", pgnum) + f = open('/tmp/.install_percent', 'w') + f.write(progressline) + f.close() + +def update_status(status): + logging.debug("Status: %s", status) + f = open('/tmp/.install_state', 'w') + f.write(str(status)) + f.close() + +def kill_dhcp_chroot(): + logging.debug("Killing off chroot dhcpcd") + stddir = os.getcwd() + piddir = ("%s/var/run/") %data_config.MOUNTPOINT + try: + os.chdir(piddir) + for FILE in glob.glob("dhcpcd-*.pid"): + f = open(FILE, 'r') + pid = f.readline() + f.close() + cmd = "kill -9 %s" %pid + runcmd(cmd) + os.remove(FILE) + os.chdir(stddir) + except: + pass + +def statgrab(disk): + cmd = "statgrab -M disk. |grep %s.write_bytes" % hostoptions["rootdisk"] + out = commands.getoutput(cmd) + try: + prewritebytes = out.split("=")[1].strip() + except: + prewritebytes = "1024" + outline = "STARTSIZE=%s" %prewritebytes + f = open('/tmp/.startsize.io', 'w') + f.write(str(outline)) + f.close() + +def backup_sql_check(): + logging.debug("Searching for backup file") + try: + hostoptions["backupfile"] + except: + logging.debug("Backup file var is empty") + return False + if os.path.exists(data_config.MOUNTPOINT+hostoptions["backupfile"]): + logging.debug("Backup file %s is present", data_config.MOUNTPOINT+hostoptions["backupfile"]) + return True + else: + logging.debug("Backup file %s is NOT present", data_config.MOUNTPOINT+hostoptions["backupfile"]) + return False + +def mdadm_find(PREFIX): + logging.debug("Searching for mdadm.conf") + if os.path.exists(PREFIX+"/etc/KnoppMyth-version"): + mdadmconf = "/etc/mdadm/mdadm.conf" + else: + mdadmconf = "/etc/mdadm.conf" + logging.debug("Using %s for mdadm.conf", mdadmconf) + return mdadmconf + +def mdadm_assemble_all(): + # read mdadm.conf and start the arrays + #ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 + logging.debug("Starting mdadm support") + mdadmconf_file = mdadm_find("/tmp") + cmd = "cdadm --assemble --scan -c /tmp/%s" %mdadmconf_file + runcmd(cmd) + mdadm_contents = '' + try: + f = open(mdadmconf_file, 'r') + mdadm_contents = f.readlines() + f.close() + except: + logging.debug(" Couldn't open mdadmconf file") + for line in mdadm_contents: + if line.startswith("ARRAY"): + logging.debug(" Found MD array: %s", line) + array = line.split()[1] + logging.info(" assembling array: %s", array) + cmd = "mdadm --assemble -c /tmp%s %s" %(mdadmconf_file, array) + runcmd(cmd) + time.sleep(2) + cmd = "fsck -p %s" %array + runcmd + +def copy_updates(): + try: + MVROOT = os.environ["MV_ROOT"] + except: + logging.debug("MVROOT was not defined, using the default value") + MVROOT = "/usr/MythVantage" + cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin", "*.sh") + cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin", "*.py") + +def timezone_to_db(timefile): + logging.info("importing timezone needs") + try: + f = open(timefile) + timezonecontents = f.readline().strip() + f.close() + except: + logging.debug("Couldn't open /tmp/etc/timezone, will not set the timezone") + return + tzsplit = timezonecontents.partition('/') + print tzsplit + if tzsplit[2] == '' : + update_db("HostTimeZoneRegion", tzsplit[0]) + else: + update_db("HostTimeZoneRegion", tzsplit[0]) + tztemp="HostTimeZoneRegion_%s" % tzsplit[0] + update_db(tztemp, tzsplit[2]) + + + +def cp_and_log(srcfile, destfile): + #return + if not os.path.exists(srcfile): + logging.info("%s is not present, skipping...", srcfile) + else: + cmd = ("rsync -arvp %s %s") %(srcfile, destfile) + runcmd(cmd) + +def cp_and_log2(srcfile, destfile, fileglob): + #return + logging.debug("cp_and_log2") + logging.debug("%s, %s, %s", srcfile, destfile, fileglob) + + if not os.path.exists(srcfile): + logging.info("%s is not present, skipping...", srcfile) + else: + if fileglob == '': + cmd = ("rsync -arvp %s %s") %(srcfile, destfile) + runcmd(cmd) + else: + fileglob = "*" + cmd = ("rsync -arvp %s/%s %s") %(srcfile, fileglob, destfile) + runcmd(cmd) + +def runcmd(cmd): + if data_config.NOOPDEBUG == "FALSE": + pass + else: + cmd = "echo "+cmd + logging.debug(" %s", cmd) + cmdout = commands.getoutput(cmd) + logging.debug(" %s", cmdout) + return cmdout + +def mysqldb(cmd, inchroot): + if cmd == "start": + mycmd = " /etc/rc.d/mysqld start" + elif cmd == "stop": + mycmd = " /etc/rc.d/mysqld stop" + if inchroot == "chroot": + mycmd = " chroot %s" %mycmd + runcmd(mycmd) + + +def mount_bind_chroot(): + logging.debug("Mounting dev/proc/sysfs for chroot") + cmd = " mount --bind /dev %s" %data_config.MOUNTPOINT+"/dev" + runcmd(cmd) + cmd = " mount --bind /proc %s" %data_config.MOUNTPOINT+"/proc" + runcmd(cmd) + cmd = " mount -t sysfs none %s" %data_config.MOUNTPOINT+"/sys" + runcmd(cmd) + +def umount_bind_chroot(): + logging.debug("UnMounting dev/proc/sysfs for chroot") + cmd = " umount -l %s" %data_config.MOUNTPOINT+"/dev" + runcmd(cmd) + cmd = " umount -l %s" %data_config.MOUNTPOINT+"/proc" + runcmd(cmd) + cmd = " umount -l %s" %data_config.MOUNTPOINT+"/sys" + runcmd(cmd) + + +def partitions_removeall(diskdevice, label): + logging.info("Removing all partitions for %s %s", label, diskdevice) + device = parted.getDevice(diskdevice) + partdisk = parted.Disk(device) + partdisk.deleteAllPartitions() + if data_config.NOOPDEBUG == "FALSE": + partdisk.commit() + + for partition in partdisk.partitions: + print "type: %s" %partition.type + +def create_partitions(diskdevice, size, ptype, startsector): + logging.debug("_____Create partitions______") + if size == "NO": + logging.info("Size is 0, skipping") + return "NO" + partlist = [] + newstart = 0 + totalused = 0 + device = parted.getDevice(diskdevice) + partdisk = parted.Disk(device) + for partition in partdisk.partitions: + if partition.type != parted.PARTITION_FREESPACE: + partlist.append((partition, + partition.path, + partition.getFlag(parted.PARTITION_BOOT), + partition.geometry.start, + partition.geometry.end, + partition.geometry.length, + partition.type, + partition.fileSystem)) + for slice in partlist: + (usedpartition, usedpath, usedbootable, usedstart, usedend, usedlength, usedtype, usedfs) = slice + #Start the new partition one after the end of last + newstart = usedend+1 + + if startsector == 0: + newstart = 0 + if size == "ALL": + logging.debug(" Using the rest of the disk %s", (device.length-newstart) ) + try: + geom = parted.Geometry(device=device, start=newstart, length=(device.length-newstart)) + except: + logging.info("An error occured, probably invalid parition size") + return + else: + # convert size in MB to a length on the device in sectors + length = (int(size) * (1024 * 1024)) / device.sectorSize + logging.debug("Size is %s", length) + try: + geom = parted.Geometry(device=device, start=newstart, length=length) + except: + logging.info("An error occured, probably invalid parition size") + return + #collect device constraint + constraint = device.getConstraint() + # new partition + if ptype == "NORMAL": + newpart = parted.Partition(disk=partdisk, type=parted.PARTITION_NORMAL, geometry=geom) + elif ptype == "SWAP": + newpart = parted.Partition(disk=partdisk, type=parted.PARTITION_NORMAL, geometry=geom) + + #add the partition to the disk and commit changes + partdisk.addPartition(partition=newpart, constraint=constraint) + if data_config.NOOPDEBUG == "FALSE": + partdisk.commit() + logging.info("created partition %s of %dMB and added it to %s" % + (newpart.getDeviceNodeName(), newpart.getSize(), diskdevice)) + return newpart.getDeviceNodeName() + + +def partition_disk(): + global hostoptions + logging.info("Partitioning") + logging.debug("____start of partition_disk____") + rootdisk = hostoptions["rootdisk"] + datadisk = hostoptions["datadisk"] + label = "root" + partitions_removeall("/dev/"+rootdisk, label) + label = "data" + partitions_removeall("/dev/"+datadisk, label) + hostoptions["rootpartition"] = create_partitions("/dev/"+rootdisk, hostoptions["rootsize"], "NORMAL", 0) + hostoptions["swappartition"] = create_partitions("/dev/"+rootdisk, hostoptions["swapsize"], "SWAP", 1) + if datadisk != rootdisk: + hostoptions["datapartition"] = create_partitions("/dev/"+datadisk, hostoptions["datasize"], "NORMAL", 0) + else: + hostoptions["datapartition"] = create_partitions("/dev/"+datadisk, hostoptions["datasize"], "NORMAL", 1) + time.sleep(5) + +def fscmd(fstype): + fscmds = {"reiserfs":"mkreiserfs -q -l ROOT", "xfs": "mkfs -t xfs -f", "ext3": "mkfs.ext3", "jfs":"mkfs.jfs -q", "ext4":"mkfs.ext4", "Do_not_format":"noformat", "no_format":"noformat"} + try: + rc = fscmds[fstype] + except: + logging.critical(" %s is not a valid fs type, exiting now", fstype) + sys.exit(3) + return rc + + +def format_disk(install_type): + logging.info("______Starting Disk Format______") + rootfs = fscmd(hostoptions["rootfs"]) + datafs = fscmd(hostoptions["datafs"]) + + rootdisk = hostoptions["rootdisk"] + datadisk = hostoptions["datadisk"] + rootpartition = hostoptions["rootpartition"] + datapartition = hostoptions["datapartition"] + if install_type != "upgrade": + swapsize = hostoptions["swapsize"] + swappartition = hostoptions["swappartition"] + + logging.debug(" Format command for rootfs %s : %s ", rootfs, rootpartition) + if ( rootfs != "noformat"): + logging.info("Starting format of %s", rootpartition) + cmd = " %s /dev/%s" %( rootfs, rootpartition) + #os.system(cmd) + runcmd(cmd) + else: + logging.info("Will not format root partition: %s", rootpartition) + + logging.debug(" Format command for datafs %s : %s ", datafs, datapartition) + if (datafs != "noformat"): + logging.info("Starting format of %s", datapartition) + cmd = " %s /dev/%s" %( datafs, datapartition) + #os.system(cmd) + runcmd(cmd) + else: + logging.info("Will not format data partition: %s", datapartition) + + if install_type == "install": + if (hostoptions["swapsize"] != "NO"): + logging.info("Starting format for swap %s", swappartition) + cmd = " mkswap /dev/%s" % swappartition + #os.system(cmd) + runcmd(cmd) + else: + logging.debug(" Swap is set to NO, will not run mkswap") + + logging.debug("_____End of format______") + + +def mount_it(): + logging.info("______Mounting disk______") +# Create mount points + try: + mountpoint = data_config.MOUNTPOINT + mp = mountpoint + logging.info("Creating mountpoints %s", mp) + os.makedirs(mp) + except OSError: + logging.debug(" Could not create %s", mp) + +# Mount root + cmd = "mount /dev/%s %s" %(hostoptions["rootpartition"], mountpoint) + runcmd(cmd) + #logging.debug(cmd) + #cmdout=commands.getoutput(cmd) + #logging.debug(cmdout) +# Mount data +#make mountpoint after mounting / + try: + mountpoint = data_config.MOUNTPOINT + datapoint = data_config.DATAMOUNT + mp = mountpoint+datapoint + logging.info("Creating mountpoints %s", mp) + os.makedirs(mp) + except OSError: + logging.debug(" Could not create %s", mp) + + cmd = "mount /dev/%s %s" %(hostoptions["datapartition"], mp) + runcmd(cmd) + #logging.debug(cmd) + #cmdout=commands.getoutput(cmd) + #logging.debug(cmdout) + +def unmount_it(): + logging.info("______Unmounting disk______") + cmd = "umount %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) + runcmd(cmd) + time.sleep(2) + + cmd = "swapoff /dev/%s" %(hostoptions["swappartition"]) + runcmd(cmd) + + cmd = "sync" + runcmd(cmd) + + cmd = "umount %s" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "sync" + runcmd(cmd) + + +def create_squashlist(): + logging.debug("Creating squashlist") + squashfile = data_config.SQUASHFILE + f = open(squashfile, 'w') + for i in data_config.SQUASHLIST: + f.write(i) + f.write("\n") + logging.debug(i) + f.close() + + +def copy_it(install_type): + logging.info("______Transferring to disk______") + logging.debug( install_type) + if ( install_type == "install"): + logging.info("Transferring system") + cmd = " unsquashfs -f -d %s /.livesys/medium/system.sqf" %(data_config.MOUNTPOINT) + runcmd(cmd) + #logging.debug(cmd) + #cmdout=commands.getoutput(cmd) + + if ( install_type == "upgrade"): + logging.info("Upgrading system") + create_squashlist() + cmd = " unsquashfs -e %s -f -d %s /.livesys/medium/system.sqf" %(data_config.SQUASHFILE, data_config.MOUNTPOINT) + runcmd(cmd) + #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") + mountpoint = data_config.MOUNTPOINT + for item in i: + try: + mp = mountpoint+"/"+item + logging.info("Creating mountpoints %s", mp) + os.makedirs(mp) + except OSError: + logging.debug(" __Could not create %s", mp) +# General fixup + cmd = "chmod 777 %s/tmp" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "mknod %s/dev/null c 1 5" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "mknod %s/dev/console c 5 1" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "chmod +s %s/usr/bin/Xorg" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "chmod +s %s/usr/bin/crontab" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "chmod +s %s/usr/bin/sudo" %(data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "chmod +s %s/bin/mount" %(data_config.MOUNTPOINT) + runcmd(cmd) + logging.debug("__End of copy_it__") + +def create_fstab(extralines): + logging.debug("______Creating new fstab file_______") + logging.info("Creating new fstab file") + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" + fstab_list = [] + f = open(fstabfile, 'w') + line = '''# <file system> <dir> <type> <options> <dump> <pass> \n''' + fstab_list.append(line) + line = '''none /dev/pts devpts defaults 0 0 \n''' + fstab_list.append(line) + line = '''none /dev/shm tmpfs defaults 0 0\n''' + fstab_list.append(line) + line = '''/dev/cdrom /media/cdrom auto ro,user,noauto,unhide 0 0\n''' + fstab_list.append(line) + line = '''/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0\n''' + fstab_list.append(line) + line = '''UUID=ROOTUID / auto defaults,noatime 0 1\n''' + fstab_list.append(line) + line = '''UUID=DATAUID %s auto defaults,noatime 0 1\n''' %(data_config.DATAMOUNT) + fstab_list.append(line) + line = '''UUID=SWAPUID swap swap defaults 0 0 \n''' + fstab_list.append(line) + for vline in extralines: + fstab_list.append(vline) + for outline in fstab_list: + logging.debug(outline) + f.write(outline) + f.close() + +def find_uuid(partition): + logging.info("Finding the UUID for %s...", partition) + cmd = "blkid -s UUID /dev/%s" %partition + tmpuuid = runcmd(cmd) + splituuid = tmpuuid.partition("=") + uuid = splituuid[2].replace('"', "") + logging.info("The uuid is %s", uuid) + return uuid.strip() + +def pick_out_vg(): + logging.info("Searching for Volume Groups in old fstab") + vglines = [] + f = open("/tmp/etc/fstab", 'r') + oldfscontents = f.readlines() + for line in oldfscontents: + if line.startswith("/dev/vg"): + vglines.append(line) + templine = line.split() + mdir = templine[1] + if not os.path.exists (mdir): + logging.debug("Creating dir %s for VG mount", mdir) + os.makedirs (mdir) +# Might need to os.chown to mythtv:users + else: + logging.debug("Directory %s for VG mount already present", mdir) + return vglines + +def fstab_it(install_type): + logging.info("______Checking fstab______") + kmvg = [] + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" +# Check for knoppmyth install, if found create new + if install_type == "upgrade": + if os.path.exists("/tmp/etc/KnoppMyth-version"): + logging.debug(" KnoppMyth-Version found, creating new fstab") + kmvg = pick_out_vg() + create_fstab(kmvg) + elif os.path.exists("/tmp/etc/fstab"): + logging.debug(" Upgrade and not Knoppmyth, using old fstab") + cp_and_log("/tmp/etc/fstab", fstabfile) +# Catch all for creating new fstab + if not os.path.exists(data_config.MOUNTPOINT+"/etc"): + os.makedirs(data_config.MOUNTPOINT+"/etc") + if not os.path.exists(fstabfile): + create_fstab(kmvg) + + logging.info("____UUID check for %s", "swap") + swapuuid = find_uuid(hostoptions["swappartition"]) + + logging.info("____UUID check for %s", "data") + datauuid = find_uuid(hostoptions["datapartition"]) + + logging.info("____UUID check for %s", "root") + rootuuid = find_uuid(hostoptions["rootpartition"]) + + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" + logging.info("Correcting UUID's in %s", fstabfile) + f = open(fstabfile, 'r') + oldfscontents = f.readlines() + newfstab = [] + f.close() + for line in oldfscontents: + if line.startswith("UUID"): + templine = line.split() + if ( templine[1] == "/"): + logging.debug(" Found Root fstab line:") + logging.debug( templine) + templine[0] = "UUID=%s" %(rootuuid) + newline = '' + for i in templine: + newline+=i + newline+=" " + newline+="\n" + logging.debug(" New fstab line:") + logging.debug( newline) + newfstab.append(newline) + + if ( templine[1] == data_config.DATAMOUNT): + logging.debug(" Found DATA mount") + logging.debug( templine) + templine[0] = "UUID=%s" %(datauuid) + newline = '' + for i in templine: + newline+=i + newline+=" " + newline+="\n" + logging.debug(" New fstab line:") + logging.debug( newline) + newfstab.append(newline) + + if ( templine[1] == "swap"): + if len(swapuuid) <= 5: + logging.debug(" swapp uuid is to small") + else: + logging.debug(" Found swap partition") + logging.debug( templine) + templine[0] = "UUID=%s" %(swapuuid) + newline = '' + for i in templine: + newline+=i + newline+=" " + newline+="\n" + logging.debug(" New fstab line:") + logging.debug( newline) + newfstab.append(newline) + else: + logging.debug(" Line didn't match, adding to newfstab:") + logging.debug( line) + newfstab.append(line) + logging.info("Writing out newfstab") + logging.debug("______This is the new fstab_____") + f = open(fstabfile, 'w') + for line in newfstab: + logging.debug(line) + f.write(line) + #f.write("\n") + f.close() + +def grub_it(): + logging.info("______Start of grub install______") + cmd = " grub-install --recheck --no-floppy --root-directory=%s \"(hd0)\" " % data_config.MOUNTPOINT + logging.info("Running grub-install") + runcmd(cmd) + rootuuid = find_uuid(hostoptions["rootpartition"]) + cmd = " mkinitcpio -g %s/boot/kernel26.img" % data_config.MOUNTPOINT + logging.info("Running mkinitcpio") + runcmd(cmd) + logging.info("Adding root uuid to grub menu") + grubfile = data_config.MOUNTPOINT+"/boot/grub/menu.lst" + try: + f = open(grubfile, 'r') + oldgrub = f.readlines() + newgrub = [] + f.close() + for line in oldgrub: + if line.startswith("kernel"): + templine = line.split() + logging.debug(" Found kernel Root grubline:") + logging.debug( templine) + templine[2] = "root=/dev/disk/by-uuid/%s" %(rootuuid) + newline = '' + for i in templine: + newline+=i + newline+=" " + newline+="\n" + logging.debug(" New grub menu.lst line:") + logging.debug( newline) + newgrub.append(newline) + else: + logging.debug("Line didn't match, adding to newgrub:") + logging.debug( line) + newgrub.append( line) + logging.info("Writing out new grub file") + logging.debug("______This is the new grub_____") + f = open(grubfile, 'w') + for line in newgrub: + logging.debug(line) + f.write(line) + f.close() + except: + logging.debug("Couldn't open grub file") + +def fix_permissions(): + logging.info("Fixing permissions") + SE = os.environ["TEMPLATES"]+"/settings/syssettings" + cmd = " chmod -R 755 %s" %(data_config.MOUNTPOINT+SE) + runcmd(cmd) + cmd = " chmod 755 %s" %(data_config.MOUNTPOINT+"/etc/systemconfig") + runcmd(cmd) + cmd = " chmod 755 %s" %(data_config.MOUNTPOINT+"/root") + runcmd(cmd) + cmd = " chown root:mythtv %s" %(data_config.MOUNTPOINT+"/etc/systemconfig") + runcmd(cmd) + cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+SE) + runcmd(cmd) + cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+"/var/log/mythtv") + runcmd(cmd) + +def apply_new_auth(): + logging.info("_____Applying Password updates_______") + passfile = "/root/myth_user_call.out" + try: + MVROOT = os.environ["MV_ROOT"] + except: + logging.debug("MVROOT was not defined, using the default value") + MVROOT = "/usr/MythVantage" + if data_config.NOOPDEBUG == "FALSE": + cmdprefix = "chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i " + else: + cmdprefix = "echo chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i " + try: + f = open(passfile, 'r') + passcmds = f.readlines() + f.close() + for cmd in passcmds: + execmd = cmdprefix+cmd +# Using os.system because runcmd fails + logging.debug(execmd) + os.system(execmd) + except: + logging.debug("Applying password updates failed, couldn't open %s", passfile) + logging.debug + +def swapsearch(): +#currently unused! + partlist = [] + stddir = os.getcwd() + os.chdir("/sys/block") + partitionlist = glob.glob("*") + for item in partitionlist: + try: + newitem = item.strip().rpartition(" ")[2] + if (not newitem == '') and (not newitem.startswith("loop")): + path = "/dev/"+newitem.strip() + path = path.strip() + device = parted.getDevice(path) + (cylinders, heads, sectors) = device.biosGeometry + sizeInBytes = device.length * device.sectorSize + disk = parted.Disk(device) + for partition in disk.partitions: + if partition.type == parted.PARTITION_PROTECTED or \ + partition.type == parted.PARTITION_METADATA or \ + partition.type == parted.PARTITION_FREESPACE: + continue + + partlist.append((partition, + partition.path, + partition.getFlag(parted.PARTITION_BOOT), + partition.geometry.start, + partition.geometry.end, + partition.geometry.length, + partition.type, + partition.fileSystem)) + for slice in partlist: + (partition, path, bootable, start, end, length, type, fs) = slice + if partition.getFlag(parted.PARTITION_SWAP) or fs.type == "linux-swap": + print "found swap" + print path + except: + pass + os.chdir(stddir) + +def sane_settings(file): + #Remove some settings from file_name + removeline = ("HOSTrootfstype", "HOSTrootfstype", "HOSTdatafstype", "HOSTOSsize", "HostUseALLdata", "HOSTDATAsize", "HOSTuprootfstype", "HostUseSWAP", "HOSTSWAPsize") + logging.debug("__Running sane settings") + try: + f = open(file, 'r') + filecontents = f.readlines() + f.close() + except: + logging.debug(" Couldn't find file %s to sane", file) + try: + f = open(file, 'w') + for line in filecontents: + for item in removeline: + if line.startsize(line.strip()): + logging.debug(" Found a line to remove in %s, %s", file, line) + else: + f.write(line) + except: + logging.debug(" Couldn't open file %s for writing", file) + logging.debug(" __End sane settings") + +def restore_default_settings(): + try: + MVROOT = os.environ["MV_ROOT"] + except: + logging.debug(" MVROOT was not defined, using the default value") + MVROOT = "/usr/MythVantage" + logging.info("Saving syssettings") + cmd = "%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME) + runcmd(cmd) + SE = os.environ["TEMPLATES"]+"/settings/syssettings/" + cp_and_log(SE, data_config.MOUNTPOINT+SE) + cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab") + copy_updates() + fix_permissions() + +def full_install(hostoptions): + logging.info("______Start of full install______") + try: + MVROOT = os.environ["MV_ROOT"] + except: + logging.debug(" MVROOT was not defined, using the default value") + MVROOT = "/usr/MythVantage" + + try: + os.remove("/tmp/.this_is_upgrade") + except OSError: + logging.debug(" File /tmp/.this_is_upgrade not present, couldn't delete it") + pass +# Partition disk + statusmsg = "Partitioning %s" %( hostoptions["rootdisk"]) + update_status(statusmsg) + progress(1) + if data_config.NOOPDEBUG == "FALSE": + partition_disk() + else: + logging.debug(" Debug mode, skipping partitioning step") + +# Format disk + statusmsg = "Preparing %s" %( hostoptions["rootdisk"]) + update_status(statusmsg) + progress(2) + format_disk("install") + + +# Mount partitions + statusmsg = "Mounting %s" %( hostoptions["rootdisk"]) + update_status(statusmsg) + progress(3) + mount_it() + +# Find number of bytes written to disk before starting copy. This is used +# to have a somewhat decent progress indication. + statgrab( hostoptions["rootdisk"]) + msg = "Creating %s" %(systemconfig["hostname"]) + update_status(msg) + +# Copy system to disk + copy_it("install") +# Remove old fstab so that a new one is created + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" + try: + os.remove(fstabfile) + except OSError: + logging.debug(" ERROR: deleting %s", fstabfile) + fstab_it("full_install") +# Configure system + msg = "Configuring system" + update_status(msg) + progress(98) + grub_it() +# Configuring the system + logging.info("______Configuring system________") + cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig") + cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install") + restore_default_settings() + #try: + #MVROOT=os.environ["MV_ROOT"] + #except: + #logging.debug(" MVROOT was not defined, using the default value") + #MVROOT="/usr/MythVantage" + #logging.info("Saving syssettings") + #cmd="%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME) + #runcmd(cmd) + #SE=os.environ["TEMPLATES"]+"/settings/syssettings" + #cp_and_log(SE, data_config.MOUNTPOINT+SE) + #cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab") + #cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin/", "*.sh") + #cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin/", "*.py") + #fix_permissions() + apply_new_auth() + if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ): +# This install will need a DB, so install it + logging.info("______Installing Database in CHROOT________") + mysqldb("stop", '') + mount_bind_chroot() + cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + logging.info("Running systemconfig in chroot") + #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + mysqldb("stop", "chroot") + kill_dhcp_chroot() + logging.info("____End Database in CHROOT____") + mysqldb("start", '') + umount_bind_chroot() + else: + logging.info("______No database required, continuing configuration________") + mount_bind_chroot() + cmd = " chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) +# Need to check for to touch /tmp/.dbsysfailed + cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + if ( 'x' == '1' ): + logging.debug("touching /tmp/.dbsysfailed") + else: + #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + cmd = " chroot %s %s/bin/restore_default_settings.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + umount_bind_chroot() + #cmd = " chroot %s %s/bin/systemconfig.sh advanced, user" %(data_config.MOUNTPOINT, MVROOT) + #runcmd(cmd) + cmd = " touch %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME) + runcmd(cmd) + cmd = " chmod 777 %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME) + runcmd(cmd) + msg = "Done" + update_status(msg) + cp_and_log("/tmp/mythvantage_install.log", data_config.MOUNTPOINT+"/var/log/mythvantage_install.log") + cp_and_log("/tmp/mv_debug.log", data_config.MOUNTPOINT+"/var/log/mv_debug.log") + unmount_it() + logging.debug("_____End of full install_____") + +def find_upgrade(): + logging.info("_____Start of find_upgrade_____") + global hostoptions + #try to mount first partition of disk + #copy old /etc/systemconfig to live, import settings into db + #umount drive. + #check for clean upgrade + if ( clean_upgrade() ): + logging.info("Clean upgrade requested, not using old data") + return + mount_it() + oldbackupfile = data_config.MOUNTPOINT+"/root/backup/"+data_config.BACKUPFILE + newbackupfile = "/tmp/"+data_config.BACKUPFILE + if os.path.exists(oldbackupfile): + logging.debug("Setting backup file to %s", newbackupfile) + hostoptions["backupfile"] = newbackupfile + cp_and_log(oldbackupfile, newbackupfile) + + srcfile = data_config.MOUNTPOINT+"/etc/systemconfig" + logging.info("Searching for systemconfig file %s", srcfile) + if os.path.exists(srcfile): + logging.info("Found systemconfig file %fs", srcfile) + TEMPLATES = os.environ["TEMPLATES"]+"/settings/syssettings" + cp_and_log2(data_config.MOUNTPOINT+TEMPLATES, data_config.TEMP_TEMPLATES, '') + sane_settings("/tmp/templates/settings/syssettings/settings.txt") + cp_and_log2(data_config.TEMP_TEMPLATES, TEMPLATES, '') + cp_and_log(srcfile, "/etc/systemconfig") + cp_and_log(data_config.MOUNTPOINT+"/etc/", "/tmp/etc/") + cp_and_log(data_config.MOUNTPOINT+"/var/lib/oss/", "/tmp/oss") + cp_and_log("/tmp/etc/mdadm.conf", "/etc/mdadm.conf") + else: + logging.info("Could not find systemconfig file %s", srcfile) + cp_and_log(data_config.MOUNTPOINT+"/etc/", "/tmp/etc/") + cp_and_log("/tmp/etc/mdadm.conf", "/etc") + timezone_to_db("/tmp/etc/timezone") + unmount_it() + logging.debug("End of find_upgrade") + +def upgrade_mount_search(): + #Search for data/myth partition based on contents of fstab + logging.debug("______Start of upgrade_mount_search_____") + cmd = "umount %s%s" %(data_config.MOUNTPOINT, data_config.DATAMOUNT) + runcmd(cmd) + fstab_list = [] + fstab_data_mount = '' + try: + f = open("/tmp/etc/fstab", 'r') + oldfscontents = f.readlines() + f.close() + ## ['UUID=', '/myth', 'auto', 'defaults, noatime', '0', '1'] + #for line in oldfscontents: + #mountdir=line.split() + #if mountdir[1] == (data_config.DATAMOUNT): + #fstablist.append(mountdir) + except: + logging.debug(" Couldn't open /tmp/etc/fstab") + for line in oldfscontents: + if line.startswith("#"): + continue + mountdir=line.split() + try: + if mountdir[1] == (data_config.DATAMOUNT): + fstablist.append(mountdir) + except: + continue + #search fstab for data/myth mountpoint + for i in fstab_list: + if i[1] == data_config.DATAMOUNT: + fstab_data_mount = i[0] + break + + #start software raid support if needed + for i in fstab_list: + if i[0].startswith("/dev/md"): + logging.debug(" starting software raid support") + mdadm_assemble_all + + + if re.search("UUID", fstab_data_mount): + fstab_data_uuid = fstab_data_mount.split("=")[1] + cmd = "blkid -t UUID=%s" %fstab_data_uuid + retcode = call(cmd, shell=True) + if retcode != 0: + logging.debug(" Couldn't find uuid %s, starting md support", fstab_data_uuid) + mdadm_assemble_all + #hoping everything is up and running and data/myth will be available for mount + cmd = "mount -U %s %s" %(fstab_data_uuid, data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "blkid -t UUID=%s|cut -d: -f1" %fstab_data_uuid + logging.debug(cmd) + datadisk = commands.getoutput(cmd) + cmd = "basename %s" %datadisk + datadisk = commands.getoutput(cmd) + else: + cmd = "mount %s %s" %(fstab_data_mount, data_config.MOUNTPOINT) + runcmd(cmd) + cmd = "basename %s" %fstab_data_mount + datadisk = commands.getoutput(cmd) + time.sleep(3) +# hostoptions["backupfile"]=data_config.BACKUPPATH+data_config.BACKUPFILE + if not backup_sql_check(): + newbackupfile = "/tmp/"+data_config.BACKUPFILE + if os.path.exists(newbackupfile): + logging.debug("Setting backup file to %s", newbackupfile) + cp_and_log(newbackupfile, data_config.MOUNTPOINT+newbackupfile) + hostoptions["backupfile"] = newbackupfile + else: + logging.info("Couldn't find any database to restore, upgrade will continue with a new database") + + + +def upgrade(hostoptions): + + try: + MVROOT = os.environ["MV_ROOT"] + except: + logging.debug("MVROOT was not defined, using the default value") + MVROOT = "/usr/MythVantage" + logging.info("______Start of upgrade______") + cmd = "touch /tmp/.this_is_upgrade" + runcmd(cmd) + if hostoptions["rootfs"] == "Do_not_format": + logging.info("Will not format root filesystem") + else: + statusmsg = "Preparing %s" %( hostoptions["rootdisk"]) + update_status(statusmsg) + progress(2) + format_disk("upgrade") + #sys.exit(2) + statusmsg = "Mounting %s" %( hostoptions["rootdisk"]) + update_status(statusmsg) + progress(3) + mount_it() + hostoptions["backupfile"] = data_config.BACKUPPATH+data_config.BACKUPFILE + statgrab( hostoptions["rootdisk"]) + msg = "Upgrading %s" %(systemconfig["hostname"]) + update_status(msg) + time.sleep(3) + copy_it("upgrade") + cmd = "rm -rf %s/etc.old" %data_config.MOUNTPOINT + runcmd(cmd) + + cp_and_log("/tmp/etc/", data_config.MOUNTPOINT+"/etc.old/") + cp_and_log("/tmp/oss", data_config.MOUNTPOINT+"/var/lib/oss.old") + srcfile = "%s/etc.old/ssh/" %(data_config.MOUNTPOINT) + destfile = "%s/etc/ssh/" %(data_config.MOUNTPOINT) + cp_and_log2(srcfile, destfile, '*.pub') + cp_and_log2(srcfile, destfile, '*.key') + cp_and_log2(srcfile, destfile, '*key') + mdfile = mdadm_find("/tmp") + cp_and_log("/tmp"+mdfile, data_config.MOUNTPOINT+"/etc") + srcfile = "%s/etc.old/asound.state" %(data_config.MOUNTPOINT) + destfile = "%s/etc/asound.state" %(data_config.MOUNTPOINT) + cp_and_log(srcfile, destfile) + if not os.path.exists("/tmp/etc/KnoppMyth-version"): + logging.debug(" standard upgrade, restoring auth files") + cp_and_log(data_config.MOUNTPOINT+"/etc.old/passwd", data_config.MOUNTPOINT+"/etc/passwd") + cp_and_log(data_config.MOUNTPOINT+"/etc.old/shadow", data_config.MOUNTPOINT+"/etc/shadow") + cp_and_log(data_config.MOUNTPOINT+"/etc.old/group", data_config.MOUNTPOINT+"/etc/group") + msg = "Configuring system" + + update_status(msg) + progress(98) + logging.info("______Configuring system________") + cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig") + if not backup_sql_check(): + upgrade_mount_search() + fstab_it("upgrade") + time.sleep(1) + grub_it() + time.sleep(1) + #needed to get around a bug with pacman + cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install") + cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab") + if clean_upgrade() or os.path.exists("/tmp/etc/KnoppMyth-version"): + logging.debug("clean upgrade or knoppmyth upgrade detected, running restore settings") + restore_default_settings() + if clean_upgrade(): + file = "%s/%s/.kmupgrade" %(data_config.MOUNTPOINT, data_config.MYTHHOME) + cmd = "touch %s && chmod 777 %s" %(file, file) + runcmd(cmd) + copy_updates() + fix_permissions() + mount_bind_chroot() + logging.info("Running systemconfig in chroot") + #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + mysqldb("stop", "") + if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ): + if clean_upgrade() or not backup_sql_check(): + logging.info("Installing new database") + cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + else: + logging.info("Restoring database") + cmd = " chroot %s %s/bin/restore_km_db_chroot.sh %s|tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT, hostoptions["backupfile"]) + runcmd(cmd) + + if os.path.exists("/tmp/etc/KnoppMyth-version"): + cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + logging.debug("Correcting permissions because of km->linhes upgrade") + cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) + runcmd(cmd) + cmd = " chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup") + runcmd(cmd) + else: + cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + + logging.info("Running systemconfig in chroot 2nd time") + #cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT) + cmd = " chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT) + runcmd(cmd) + #logging.info("Running systemconfig in chroot") + #cmd = " chroot %s %s/bin/systemconfig.sh advanced" %(data_config.MOUNTPOINT, MVROOT) + #runcmd(cmd) + mysqldb("stop", 'chroot') + apply_new_auth() + kill_dhcp_chroot() + umount_bind_chroot() + cp_and_log("/tmp/mythvantage_install.log", data_config.MOUNTPOINT+"/var/log/mythvantage_install.log") + cp_and_log("/tmp/mv_debug.log", data_config.MOUNTPOINT+"/var/log/mv_debug.log") + unmount_it() + msg = "Done" + update_status(msg) + mysqldb("start", '') + + + + +def main(argv): + global hostoptions + try: + opts, args = getopt.getopt(argv, 'c:h', ["help", "rootdisk=", "rootfs=", "rootsize=", "datafs=", "datasize=", "datadisk=", "swapsize=", "datapartition=" ] ) + except getopt.GetoptError, why: + print why + usage() + sys.exit(2) + hostoptions = {"op": 'null'} + for opt, arg in opts: + if opt in ("-h", "--help"): + usage() + sys.exit(0) + elif opt in ( "--rootdisk"): + hostoptions["rootdisk"] = arg + hostoptions["rootpartition"] = arg+str(1) + elif opt in ("--rootfs"): + hostoptions["rootfs"] = arg + elif opt in ("--rootsize"): + hostoptions["rootsize"] = arg + elif opt in ("--datafs"): + hostoptions["datafs"] = arg + elif opt in ("--datasize"): + hostoptions["datasize"] = arg + elif opt in ("--datadisk"): + hostoptions["datadisk"] = arg + elif opt in ("--datapartition"): + hostoptions["datapartition"] = arg + elif opt in ("--swapsize"): + hostoptions["swapsize"] = arg + + elif opt in ("-c"): + validop = ["full_install", "upgrade", "netboot", "find_upgrade"] + if arg not in validop: + logging.critical("-c %s is not a valid option", arg) + sys.exit(2) + else: + hostoptions["op"] = arg + try: + hostoptions["datadisk"] + except: + hostoptions["datadisk"] = hostoptions["rootdisk"] + hostoptions["datapartition"] = hostoptions["datadisk"]+str(3) + try: + hostoptions["datapartition"] + except: + hostoptions["datapartition"] = hostoptions["datadisk"]+str(3) + hostoptions["swappartition"] = hostoptions["rootdisk"] + str(2) + + + if ( hostoptions["op"] == "full_install" ) : + full_install(hostoptions) + elif (hostoptions["op"] == "upgrade" ) : + hostoptions["datafs"] = "no_format" + find_upgrade() + upgrade(hostoptions) + elif (hostoptions["op"] == "find_upgrade" ) : + find_upgrade() + return hostoptions + + +#____________________________________________setup the logging______________________________________________________ +LOG_FILENAME = '/tmp/mv_status.log' +DEBUGLOG = '/tmp/mv_debug.log' +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + datefmt='%m-%d %H:%M', + filename=DEBUGLOG, + filemode='a') +# define a Handler which writes INFO messages or higher to the sys.stderr +console = logging.StreamHandler() +console.setLevel(logging.INFO) +# set a format which is simpler for console use +#formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') +formatter = logging.Formatter("%(message)s") +# tell the handler to use this format +console.setFormatter(formatter) +# add the handler to the root logger +logging.getLogger('').addHandler(console) + +#infoformatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") +infoformatter = logging.Formatter("%(message)s") +infofile = logging.FileHandler(LOG_FILENAME, 'w') +infofile.setFormatter(infoformatter) +infofile.setLevel(logging.INFO) +logging.getLogger('').addHandler(infofile) + +#Read in systemconfig +global systemconfig +systemconfig = {} +file_name = "/etc/systemconfig" +try: + config_file = open(file_name) +except: + logging.debug("%s could not be opened", file_name) + config_file = '' + +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.strip('"') + systemconfig[var.strip()] = val.strip() + + +if __name__ == "__main__": + config_file = "mv_config" + data_config = __import__(config_file, globals(), locals(), []) + logging.debug("___________START OF DEBUG_________________________") + cmdoptions = main(sys.argv[1:]) + logging.debug("______cmd line options______") + for i in cmdoptions.items(): + logging.debug (i) + logging.debug("______systemconfig______") + for i in systemconfig.items(): + logging.debug(i) + logging.debug("______hostoptions______") + for i in hostoptions.items(): + logging.debug(i) + pass + diff --git a/abs/core-testing/LinHES-config/mv_ir.py b/abs/core-testing/LinHES-config/mv_ir.py new file mode 100755 index 0000000..efc8a60 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_ir.py @@ -0,0 +1,311 @@ +# -*- coding: utf-8 -*- +import logging, mv_common +import os, re , glob +from time import time, localtime, strftime +import time + +def setup_lirc_links(mythhome): + logging.debug(" Creating links for lirc") + if not os.path.exists(mythhome+"/.mythtv"): + logging.debug(" Creating %s/.mythtv",mythhome) + try: + os.mkdir(mythhome+"/.mythtv") + except: + logging.debug(" Couldn't create .mythtv ") + return + os.chown(mythhome+"/.mythtv","mythtv","mythtv") + + if not os.path.exists(mythhome+"/.mythtv/lircrc"): + logging.debug(" Creating symlink for myth lircrc") + os.symlink("/etc/lircrc",mythhome+"/.mythtv/lircrc") + else: + logging.debug(" %s/lircrc already present",mythhome) + + if not os.path.exists(mythhome+"/.lircrc"): + logging.debug(" Creating symlink for lircrc") + os.symlink("/etc/lircrc",mythhome+"/.lircrc") + else: + logging.debug(" %s/.lircrc already present",mythhome) + +def scrub_modules(filename,module): + logging.debug(" scrubbing %s from %s",module,filename) + cmd = '''sed -i -e '/.*#%s/d' %s''' %(module,filename) + mv_common.runcmd(cmd) + +def add_module(filename,module): + logging.debug(" adding %s to %s",module,filename) + cmd = ''' echo "%s" >> %s ''' %(module,filename) + mv_common.runcmd(cmd) + +def unload_all_lirc(): + logging.debug(" Unloading all lirc modules") + cmd = "sv stop lircd" + mv_common.runcmd(cmd) + cmd = "killall -9 lircd" + mv_common.runcmd(cmd) + cmd = '''modprobe -r $(lsmod |grep ^lirc |awk '{print $1}') ''' + mv_common.runcmd(cmd) + + + +def include_file( incfile,filename): + logging.debug(" including %s within %s",filename,incfile) + try: + f = open( incfile, 'a') + except: + logging.debug(" Couldn't open %s for writing",incfile) + return + line = '''include "%s" ''' %filename + logging.debug(" %s",line) + f.write(line) + f.write("\n") + f.close() + +def setup_ir_remote(Remotetype,templates): + logging.debug(" Setup of remote type %s",Remotetype) + if Remotetype == "no_remote": + mv_common.remove_service(lircd) + elif Remotetype == "tinker": + pass + else: + currenttime = strftime("%b-%d-%Y-%H:%M:%S", localtime()) + cmd = "mv /etc/lircd.conf /etc/lircd.conf-%s" %currenttime + mv_common.runcmd(cmd) + cmd = "mv /etc/lircrc /etc/lircrc-%s" %currenttime + mv_common.runcmd(cmd) + files = templates + "/remotes/" + Remotetype + "/lircd*" + logging.debug(" Using %s",files) + for filename in glob.glob(files): + # Ignore subfolders + if os.path.isdir (filename): + logging.debug(" %s is a dir, skipping",filename) + continue + include_file("/etc/lircd.conf",filename) + files = templates + "/remotes/" + Remotetype + "/lircrc*" + logging.debug(" Using %s",files) + for filename in glob.glob(files): + # Ignore subfolders + if os.path.isdir (filename): + logging.debug(" %s is a dir, skipping",filename) + continue + include_file("/etc/lircrc",filename) + cmd = "chmod 755 /etc/lircrc" + mv_common.runcmd(cmd) + mv_common.add_service("lircd") + + +def setup_ir_receiver(ReceiverType,TEMPLATES): + logging.info(" Configuring receiver %s", ReceiverType) + if ReceiverType == "Serial": + scrub_modules("/etc/modules.mythvantage","lirc") + add_module("/etc/modules.mythvantage","lirc_serial #lirc") + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + mv_common.remove_service("igdaemon") + mv_common.remove_service("tatir") + + elif ReceiverType == "Usb-imon": + scrub_modules("/etc/modules.mythvantage","lirc") + add_module("/etc/modules.mythvantage","lirc_imon #lirc") + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + mv_common.remove_service("igdaemon") + mv_common.remove_service("tatir") + + elif ReceiverType == "Hauppauge": + scrub_modules("/etc/modules.mythvantage","lirc") + add_module("/etc/modules.mythvantage","lirc_i2c #lirc") + mv_common.cp_and_log(TEMPLATES+"/modules/lirc_i2c.conf" , + "/etc/modprobe.d/lirc_i2c.conf") + cmd = "rmmod lirc_i2c" + mv_common.runcmd(cmd) + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + mv_common.remove_service("igdaemon") + mv_common.remove_service("tatir") + elif ReceiverType == "pvr150": + scrub_modules("/etc/modules.mythvantage","lirc") + add_module("/etc/modules.mythvantage","lirc_i2c #lirc") + mv_common.cp_and_log(TEMPLATES+"/modules/lirc_i2c.conf" , + "/etc/modprobe.d/lirc_i2c.conf") + cmd = "rmmod lirc_i2c" + mv_common.runcmd(cmd) + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + mv_common.remove_service("igdaemon") + mv_common.remove_service("tatir") + elif ReceiverType == "iguanaIR-usb": + scrub_modules("/etc/modules.mythvantage","lirc") + mv_common.add_service("igdaemon") + mv_common.remove_service("tatir") + + elif ReceiverType == "tatir": + scrub_modules("/etc/modules.mythvantage","lirc") + mv_common.add_service("tatir") + mv_common.remove_service("igdaemon") + + else: + logging.debug(" didn't match receiver, using genric case") + scrub_modules("/etc/modules.mythvantage","lirc") + mv_common.remove_service("igdaemon") + mv_common.remove_service("tatir") + +def setup_blaster_proto(HostBlasterType,Hostnumblaster,TEMPLATES,systemconfig): + logging.debug(" Start of setup_blaster_proto") + logging.debug(" HostBlasterType: %s", HostBlasterType) + logging.debug(" Hostnumblaster: %s" , Hostnumblaster) + if not HostBlasterType == "pvr150" and not HostBlasterType == "None": + for i in range(int(Hostnumblaster)): + try: + proto = systemconfig["HostTransmitproto_"+str(i+1)] + logging.debug(" proto: %s",proto) + except: + logging.info(" unkown proto for %s",i+1) + continue + template=TEMPLATES+"/transmit/%s/lircd.conf" %proto + if os.path.exists(template): + logging.debug(" include blaster template: %s",proto) + include_file("/etc/lircd.conf",template) + else: + logging.debug(" template: %s is not present",template) + logging.info("------NEED TO SETUP CHANGE_CHANNEL------") + + +def setup_blaster_transmiter(HostBlasterType): + logging.debug(" Start of setup_blaster_transmiter") + logging.info(" HostBlasterType : %s", HostBlasterType) + + if HostBlasterType == "Receiver": + logging.info(" Blaster is receiver, skipping module config for Blaster") + return + + if HostBlasterType == "no blaster": + scrub_modules("/etc/modules.mythvantage","blaster") + elif HostBlasterType == "Serial": + scrub_modules("/etc/modules.mythvantage","blaster") + add_module("/etc/modules/.mythvantage","lirc_serial #blaster") + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + elif HostBlasterType == "pvr150": + scrub_modules("/etc/modules.mythvantage", "blaster") + scrub_modules("/etc/modules.mythvantage", "lirc") + add_module("/etc/modules.mythvantage", "lirc_pvr150 #blaster") + add_module("/etc/modules.mythvantage", "lirc_pvr150 #lirc") + cmd = "rmmod lirc_i2c" + mv_common.runcmd(cmd) + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + else: + scrub_modules("/etc/modules.mythvantage","blaster") + +def setup_lcd(LCDtype, TEMPLATES, Remotetype): + logging.debug("____Start of setup_lcd____") + logging.debug(" LCDType: %s", LCDtype) + logging.debug(" Remotetype: %s", Remotetype) + if LCDtype == "tinker": + logging.info(" tinker mode detected") + return + + if LCDtype == "no_lcd": + logging.info(" Disabling LCD support") + cmd = "sv stop lcdd" + mv_common.runcmd(cmd) + #sometimes it doesn't want to die + cmd = "killall -9 LCDd" + mv_common.runcmd(cmd) + cmd = "load-modules-mythvantage.sh UNLOAD LCD" + mv_common.runcmd(cmd) + scrub_modules("/etc/modules.mythvantage", "LCD") + mv_common.remove_service("lcdd") + else: + lcdmodule="%s/LCD/%s/modules" %(TEMPLATES,LCDtype) + if os.path.exists(lcdmodule): + logging.debug(" Adding module for LCD") + scrub_modules("/etc/modules.mythvantage", "LCD") + cmd = "cat %s >> /etc/modules.mythvantage" %lcdmodule + mv_common.runcmd(cmd) + if Remotetype != "tinker": + lcdconf = "%s/LCD/%s/LCDd.conf" %(TEMPLATES,LCDtype) + lcdlirc = "%s/LCD/%s" %(TEMPLATES,LCDtype) + mv_common.pacinstall("lcdproc") + if os.path.exists(lcdconf): + logging.debug(" Copying in lcdconf template file: %s",lcdconf) + mv_common.cp_and_log(lcdconf, "/etc/LCDd.conf") + else: + logging.debug(" %s is not present, will not copy it") + + if os.path.exists(lcdlirc+"/lircrc"): + logging.debug(" LCD seems to support lirc") + #setup the lirc aspect of the lcd + #copied from setup_ir_remote + files = lcdlirc+"/lircd*" + logging.debug(" Using %s",files) + for filename in glob.glob(files): + # Ignore subfolders + if os.path.isdir (filename): + logging.debug(" %s is a dir, skipping",filename) + continue + include_file("/etc/lircd.conf",filename) + files = lcdlirc+"/lircrc*" + logging.debug(" Using %s",files) + for filename in glob.glob(files): + # Ignore subfolders + if os.path.isdir (filename): + logging.debug(" %s is a dir, skipping",filename) + continue + include_file("/etc/lircrc",filename) + cmd = "chmod 755 /etc/lircrc" + mv_common.runcmd(cmd) + + mv_common.add_service("lcdd") + mv_common.restart_service("lcdd") + logging.debug("__End of setup_lcd") + +def setup_ir(systemconfig, data_config): + rc = False + logging.info("____Start of IR____") + if systemconfig["Remotetype"] == "tinker": + logging.info(" Tinker mode detected") + else: + if not systemconfig["HostBlasterType"]: + HostBlasterType = "unknown" + Hostnumblaster = "0" + else: + HostBlasterType = systemconfig["HostBlasterType"] + Hostnumblaster = systemconfig["Hostnumblaster"] + + if systemconfig["HostBlasterType"] == "pvr150": + remotetype = "hauppauge-blaster" + logging.debug(" pvr150 blaster selected, setting remote to hauppauge-blaster") + else: + remotetype = systemconfig["Remotetype"] + + setup_ir_remote(remotetype,systemconfig["TEMPLATES"]) + setup_lirc_links(data_config.MYTHHOME) + + if systemconfig["ReceiverType"]: + setup_ir_receiver(systemconfig["ReceiverType"], + systemconfig["TEMPLATES"]) + else: + setup_ir_receiver("unknown", systemconfig["TEMPLATES"]) + unload_all_lirc() + setup_blaster_proto(HostBlasterType, + Hostnumblaster, + systemconfig["TEMPLATES"], + systemconfig) + setup_blaster_transmiter(HostBlasterType) + cmd = "load-modules-mythvantage.sh" + mv_common.runcmd(cmd) + time.sleep(2) + mv_common.udev_trigger() + cmd="sv start lircd" + mv_common.runcmd(cmd) + rc = [ True , True ] + if systemconfig["LCDtype"]: + setup_lcd(systemconfig["LCDtype"], + systemconfig["TEMPLATES"], + systemconfig["Remotetype"]) + else: + logging.debug(" LCD not defined") + logging.info("__End IR\n") + return rc
\ No newline at end of file diff --git a/abs/core-testing/LinHES-config/mv_misc.py b/abs/core-testing/LinHES-config/mv_misc.py new file mode 100755 index 0000000..c93cd71 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_misc.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +import logging, mv_common +import os, re +from urllib2 import Request, urlopen, URLError, HTTPError + +config_file = "mv_config" +data_config = __import__(config_file, globals(), locals(), []) + +def setup_zip(MVROOT,zipcode): + logging.debug("____Setting up the zipcode____") + + if zipcode: + cmd="%s/bin/restore_default_settings.sh -c ZIP -c %s" %(MVROOT,zipcode) + mv_common.runcmd(cmd) + #Let's also speed things up for those in North America + cmd="mkdir /usr/bin/perlbin/vendor/tv_grabbers_non_na" + mv_common.runcmd(cmd) + cmd="mv /usr/bin/perlbin/vendor/tv_grab_* /usr/bin/perlbin/vendor/tv_grabbers_non_na" + mv_common.runcmd(cmd) + cmd="mv /usr/bin/perlbin/vendor/tv_grabbers_non_na/tv_grab_na* /usr/bin/perlbin/vendor/" + mv_common.runcmd(cmd) + else: + logging.debug(" Zipcode is not set") + + logging.debug("__End of zipcode\n") + +def setup_tz(timezone,TEMPLATES): + logging.info("____Setting up the timezone____") + + if not timezone: + timezone="unknown" + logging.info(" Setting timezone to %s",timezone) + try: + logging.debug(" Removing /etc/localtime") + os.remove("/etc/localtime") + except: + logging.debug(" Couldn't remove /etc/localtime") + pass + + srclink="/usr/share/zoneinfo/%s" %timezone + logging.debug(" symlinking %s to /etc/localtime",srclink) + try: + os.symlink(srclink,"/etc/localtime") + except: + logging.critical(" Couldn't make symlink for /etc/localtime") + cmd = '''sed -e "s/^TIMEZONE=.*$/TIMEZONE=\\"%s\\" /" /etc/rc.conf > $TEMPLATES/rc.conf''' %re.escape(timezone) + mv_common.runcmd(cmd) + + if os.path.exists("/etc/php/php.ini"): + logging.info(" Changing timezone for php") + cmd = '''sed -i "s/^.*date.timezone.*$/date.timezone=%s/" ${BASE}/etc/php/php.ini''' %re.escape(timezone) + mv_common.runcmd(cmd) + + mv_common.cp_and_log(TEMPLATES+"/rc.conf","/etc/rc.conf") + logging.info("__End of timezone\n") + +def setup_nfs(systemconfig): + nfslist=[] + logging.info("____Start of setup_nfs____") + scrubnfs(systemconfig["TEMPLATES"]) + + if systemconfig["HaveCentralNFS"] == "yes": + logging.debug(" Using a Central NFS server") + if systemconfig["NFSserver"] == "file:nfsmap": + #if it's a file check for it, failure results in downloading attempt from MBE + nfsmap_file=data_config.MYTHHOME+"/templates/nfsmap" + if not os.path.exists(nfsmap_file): + logging.debug(" Couldn't find local %s",nfsmap_file) + logging.info(" Trying to download nfsmap from MBE") + nfsmap_file = download_nfsmap(systemconfig["dbhost"]) + nfslist = process_nfsmap_file(nfsmap_file) + # if it's an ip parse ip and download file + elif re.search(systemconfig["NFSserver"],":nfsmap"): + ip=systemconfig["NFSserver"].split(":")[0] + nfsmap_file = download_nfsmap(ip) + nfslist = process_nfsmap_file(nfsmap_file) + #else treat it as a single mount point + else: + item = (systemconfig["NFSserver"] , systemconfig["NFSmount"]) + nfslist.append(item) + else: + #if standalone or slave try to use MBE + if systemconfig["SystemType"] == "Frontend_only" or systemconfig["SystemType"] == "Slave_Backend": + item = (systemconfig["dbhost"] , data_config.DATAMOUNT) + nfslist.append(item) + setup_nfs_fstab(nfslist) + logging.info("__End of nfs\n") + +def setup_sleep(systemconfig): + logging.debug("____Setting up sleep____") + autoshutdown = systemconfig["AutoShutdown"] + stime1 = systemconfig["Shutdowntime"] + stime2 = systemconfig["Shutdowntime2"] + cstime1='' + + if autoshutdown == "1" : + if not stime1 == "-1" : + cstime1 = stime1 + cshutdown = cstime1 + if not stime2 == "-1" : + if cstime1 : + cshutdown = "%s,%s" %(cstime1,stime2) + else: + cshutdown = stime2 + logging.debug(" Shutdown time at %s",cshutdown) + cmd='''sed -e "s/HOUR/%s/g" %s/cron.template | crontab - -u mythtv''' %(cshutdown,systemconfig["TEMPLATES"]) + mv_common.runcmd(cmd) + else: + logging.info(" Shutdown not enabled") + cmd='''sed -e "/00 HOUR.*/d" %s/cron.template | crontab - -u mythtv''' %systemconfig["TEMPLATES"] + mv_common.runcmd(cmd) + + logging.debug("__End of sleep\n") + + +def process_nfsmap_file(mapfile): + logging.debug(" processing nfsmap file %s",mapfile) + nfslist = [] + try: + f = open(mapfile,"r") + for line in f.readlines(): + if line.startswith("#"): + continue + item = line.split() + if len(item) <= 1 : + continue + logging.debug(" %s",item) + nfslist.append(item) + except : + logging.critical("Couldn't read file %s, or some other error",mapfile) + return nfslist + +def scrubnfs(templates): + logging.info(" Scrubbing nfs") + mv_common.cp_and_log("/etc/fstab",templates+"/fstab.conf.template") + #used this sed cmd because it's clean and took me forever to figure out =) + cmd='''sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' %s/fstab.conf.template > /etc/fstab''' %templates + mv_common.runcmd(cmd) + +def download_nfsmap(ip): + nfsmap_file="/tmp/nfsmap" + myurl="http://%s:1337/templates/nfsmap" %ip + req = Request(myurl) + try: + f = urlopen(req) + logging.info(" downloading %s", myurl) + local_file = open(nfsmap_file, "w") + #Write to our local file + local_file.write(f.read()) + local_file.close() + #handle errors + except HTTPError, e: + logging.info(" File download failed") + logging.debug(" %s", myurl) + logging.debug(" HTTP Error: %s", e.code) + except URLError, e: + logging.info(" File download failed") + logging.debug(" %s",myurl) + logging.debug(" URL Error: %s ", e.reason) + + return nfsmap_file + +def setup_nfs_fstab(nfslist): + logging.info(" Adding nfs paths to fstab") + try: + f = open('/etc/fstab', 'a') + line = "#STARTSCRUB --------------anything in this block will be scrubbed\n" + f.write(line) + for s, m in nfslist: + line = "%s %s nfs \n" %(s,m) + logging.debug(" %s",line) + f.write(line) + line = "#ENDSCRUB\n" + f.write(line) + f.close() + except: + logging.critical(" *Couldn't open /etc/fstab for writing") + logging.debug(" Done adding nfs paths to fstab") + diff --git a/abs/core-testing/LinHES-config/mv_network.py b/abs/core-testing/LinHES-config/mv_network.py new file mode 100755 index 0000000..ca29c7d --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_network.py @@ -0,0 +1,276 @@ +# -*- coding: utf-8 -*- +import sys , os, commands , glob, time, re +import logging +import mv_common +global etcnetdir +etcnetdir = "/etc/net/ifaces" + + +def setup_MYTH_IP(systemconfig): + default_interface = systemconfig["default_interface"] + try: + defaultip = systemconfig["Hostip"+default_interface] + except: + logging.debug(" Error occured finding the defaultip") + defaultip = "127.0.0.1" + logging.debug(" Using %s as default ip", defaultip) + return defaultip + +def setup_MYTH_DHCP(systemconfig): + default_interface = systemconfig["default_interface"] + try: + defaultdhcp = systemconfig["HostUSEDHCP"+default_interface] + except: + logging.critical(" *Error occured finding default dhcp") + defaultdhcp = "0" + logging.debug(" Using %s as dhcp value for %s", default_interface, defaultdhcp) + return defaultdhcp + +def flush(netdev): + logging.debug(" Flushing %s",netdev) + cmd = '''ip address flush dev %s''' %netdev + mv_common.runcmd(cmd) + +def kill_dhcp(basedir): + logging.debug(" _Start of kill_dhcp") + logging.debug(" Killing off dhcpd") + stddir = os.getcwd() + piddir = ("%s/var/run/") %basedir + try: + os.chdir(piddir) + for FILE in glob.glob("dhcpcd-*.pid"): + f = open(FILE,'r') + pid = f.readline() + f.close + cmd = "kill -9 %s" %pid + mv_common.runcmd(cmd) + os.remove(FILE) + os.chdir(stddir) + except: + pass + +def setup_nameserver(dns): + logging.info(" Adding %s for DNS", dns) + cmd = '''grep -q %s /etc/resolv.conf''' %dns + status = mv_common.runcmd(cmd) + if not status == 0 : + cmd = ''' echo "nameserver %s" >> /etc/resolv.conf ''' %dns + mv_common.runcmd(cmd) + + + +def setup_hostname(systemconfig): + logging.debug(" _Start of setup_hostname") + try: + hostname = systemconfig["hostname"] + except: + logging.critical(" *Hostname could not be set") + logging.info(" Using default value of me") + hostname = "me" + logging.info(" Setting the hostname to %s", hostname) + cmd = "cat /etc/hosts | grep -v 127.0.0.1 | grep -v %s > /tmp/hosts" %hostname + mv_common.runcmd(cmd) + if systemconfig["mythdhcp"] == "1" : + logging.debug(" not using dhcp") + cmd = ''' echo 127.0.0.1 localhost > /etc/hosts ''' + mv_common.runcmd(cmd) + cmd = ''' echo %s %s > /etc/hosts ''' %(systemconfig["mythip"], systemconfig["hostname"]) + mv_common.runcmd(cmd) + else: + cmd = ''' echo 127.0.0.1 %s localhost > /etc/hosts ''' %systemconfig["hostname"] + mv_common.runcmd(cmd) + cmd = '''cat /tmp/hosts >> /etc/hosts ''' + mv_common.runcmd(cmd) + +def setup_interface(netdev,systemconfig): + logging.debug(" _Start of setup_interface for %s",netdev) + nettrans = {'Hostip':'ip', + 'Hostnetmask':'netmask', + 'HostActive':'isactive', + 'HostDNS':'dns', + 'HostUSEDHCP':'UseDHCP', + 'HostGW':'GW', + 'HostMTU':'mtu', + 'HOST_iswireless':"wireless", + 'HostESSID':'ESSID', + 'HostKey':'key', + 'HostUseEncryption':'ENCRYPT'} + netinfo = {} + #populate the netinfo dict + for netitem in nettrans: + if systemconfig[netitem+netdev]: + netinfo[nettrans[netitem]] = systemconfig[netitem+netdev] + else: + netinfo[nettrans[netitem]] = False + logging.debug(" %s:%s",netitem,netinfo[nettrans[netitem]]) + logging.info(" %s wireless: %s", netdev,netinfo["wireless"]) + try: + os.makedirs(etcnetdir) + except: + logging.debug(" Could not create %s",etcnetdir) + + optionfile=etcnetdir+"/"+netdev+"/options" + if not os.path.exists(optionfile): + os.makedirs(etcnetdir+"/"+netdev) + mv_common.cp_and_log(systemconfig["TEMPLATES"]+"/etcnet/eth/options", optionfile) + + if netinfo["isactive"] == "1" : + change_iface_state(netdev,"enabled") + else: + change_iface_state(netdev,"disabled") + + if netinfo["wireless"] == "1" : + logging.info(" Enabling wireless extensions") + cmd = ''' sed -i -e 's/^CONFIG_WIRELESS=.*$/CONFIG_WIRLESS=yes/g' %s/%s/options''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + #set the key and essid + cmd = ''' echo "essid %s" > %s/%s/iwconfig ''' %(netinfo["ESSID"], etcnetdir, netdev) + mv_common.runcmd(cmd) + if netinfo["ENCRYPT"] == "1": + logging.info(" Enabling encryption") + cmd = '''echo "key %s" >> %s/%s/iwconfig ''' %(netinfo["KEY"], etcnetdir, netdev) + mv_common.runcmd(cmd) + else: + logging.info(" Disabling wireless extensions") + cmd = '''sed -i -e 's/^CONFIG_WIRLESS=.*$/CONFIG_WIRLESS=no/g' %s/%s/options''' %(etcnetdir, netdev) + mv_common.runcmd(cmd) + + if netinfo["UseDHCP"] == "0" : + logging.info(" Enabling DHCP support") + cmd = ''' sed -i -e 's/^BOOTPROTO=.*$/BOOTPROTO=dhcp/g' %s/%s/options''' %(etcnetdir, netdev) + mv_common.runcmd(cmd) + else: + logging.info(" Using static ip address of %s",netinfo["ip"]) + cmd = ''' sed -i -e 's/^BOOTPROTO=.*$/BOOTPROTO=static/g' %s/%s/options''' %(etcnetdir, netdev) + mv_common.runcmd(cmd) + cmd = '''echo "default via %s" > %s/%s/ipv4route''' %(netinfo["GW"], etcnetdir, netdev) + mv_common.runcmd(cmd) + cmd = '''echo "%s%s" > %s/%s/ipv4address ''' %(netinfo["ip"], netinfo["netmask"], etcnetdir, netdev) + mv_common.runcmd(cmd) + setup_nameserver(netinfo["dns"]) + + if netinfo["mtu"] : + logging.info(" Setting mtu to %s", netinfo["mtu"]) + cmd = '''sed -i '/^mtu.*$/d' %s/%s/iplink''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + cmd = ''' echo "mtu %s" >> %s/%s/iplink''' %(netinfo["mtu"], etcnetdir,netdev) + mv_common.runcmd(cmd) + else: + logging.info(" Using default mtu value") + cmd = '''sed -i '/^mtu.*$/d' %s/%s/iplink''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + + +def change_iface_state(netdev, state): + if state == "enabled": + logging.info(" Activating %s", netdev) + cmd = '''sed -i -e 's/^ONBOOT=.*$/ONBOOT=yes/g' %s/%s/options''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + cmd = '''sed -i -e 's/^DISABLED=.*$/DISABLED=no/g' %s/%s/options ''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + else: + logging.info(" Disabling %s", netdev) + cmd = '''sed -i -e 's/^ONBOOT=.*$/ONBOOT=no/g' %s/%s/options''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + cmd = '''sed -i -e 's/^DISABLED=.*$/DISABLED=yes/g' %s/%s/options ''' %(etcnetdir,netdev) + mv_common.runcmd(cmd) + cmd = "/sbin/ifconfig %s down" %netdev + mv_common.runcmd(cmd) + cmd = "ip address flush %s" %netdev + mv_common.runcmd(cmd) + +def find_active(systemconfig): + interfacelist=('eth0', 'eth1', 'wlan0', 'wlan1') + logging.debug(" _Start of find_active") + + if systemconfig["mythdhcp"] == "1": + try: + os.remove("/etc/resolv.conf") + except: + logging.debug(" couldn't remove /etc/resolv.conf") + cmd = ''' echo search lan > /etc/resolv.conf ''' + mv_common.runcmd(cmd) + cmd = ''' echo nameserver 127.0.0.1 >> /etc/resolv.conf ''' + mv_common.runcmd(cmd) + + for netdev in interfacelist: + currentnet = "HostActive" + netdev + try: + systemconfig[currentnet] + except: + logging.debug(" %s is not defined",currentnet) + continue + if systemconfig[currentnet] == "1" : + setup_interface(netdev,systemconfig) + else: + change_iface_state(netdev, "disabled") + +def vnc_netboot_check(): + logging.debug(" Start of VNC/NETBOOT check") + vnc = False + netboot = False + try: + f = open('/proc/cmdline', 'r') + bootoptions = f.readlines() + f.close() + except: + logging.critical(" *Couldn't open /proc/cmdline") + logging.debug(" Assuming it's ok to fiddle with the network") + return True + bootoptions = bootoptions[0] + if re.match("vnc",bootoptions) != None : + logging.debug(" Found VNC option") + vnc = True + if re.match("nfsroot",bootoptions) != None : + logging.debug(" Found netboot option") + netboot = True + + return (vnc or netboot) + +def start_network(): + if not vnc_netboot_check(): + logging.info(" Restarting network") + cmd ="/etc/net/scripts/network.init reload" + mv_common.runcmd(cmd) + cmd ="/etc/net/scripts/network.init reload" + mv_common.runcmd(cmd) + else: + logging.info(" Will not restart network due to netboot/vnc") + + +def stop_network(): + if not vnc_netboot_check(): + logging.info(" Stopping network") + cmd ="/etc/net/scripts/network.init stop" + mv_common.runcmd(cmd) + kill_dhcp("") + interfacelist=('eth0', 'eth1', 'wlan0', 'wlan1') + for i in interfacelist: + flush(i) + else: + logging.info(" Will not stop network due to netboot/vnc") + pass + + + +def setup_network (systemconfig): + logging.info("____Start of network____") + logging.info(" Setting up the network") + setup_hostname(systemconfig) + find_active(systemconfig) + logging.info("__End of network\n") + + + +##this is used by the install process to start the network +def install_network_setup(systemconfig): + logging.info("____Start of network_install____") + logging.info(" Setting up the network") + #setup_MYTH_vars + setup_hostname(systemconfig) + stop_network() + find_active(systemconfig) + start_network() + logging.info("__End of network install \n") + + diff --git a/abs/core-testing/LinHES-config/mv_screensaver.py b/abs/core-testing/LinHES-config/mv_screensaver.py new file mode 100755 index 0000000..2da970c --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_screensaver.py @@ -0,0 +1,199 @@ +# -*- coding: utf-8 -*- +import logging, mv_common +import re +import os + + +def mplayer_saver_check (cmd,templatefile): + logging.debug(" Checking for heartbeat command in mplayer.conf") + mplayerconf = "/etc/mplayer/mplayer.conf" + if not os.path.exists(mplayerconf): + logging.debug(" copying in mplayer template file") + mv_common.cp_and_log(templatefile, mplayerconf) + + try: + f = open(mplayerconf, 'r') + mplayerconf_contents = f.readlines() + f.close() + except: + logging.debug(" Couldn't open %s for reading",mplayerconf) + mplayerconf_contents = "#\n" + + try: + f = open(mplayerconf, 'w') + except: + logging.debug(" Couldn't open %s for writing",mplayerconf) + return + + for line in mplayerconf_contents: + if re.match("^.*stop-xscreensaver",line): + continue + elif re.match("^.*heartbeat-cmd",line): + continue + else: + f.write(line) + + f.write("stop-xscreensaver = 0\n") + line='''heartbeat-cmd="%s"\n''' %cmd + f.write(line) + f.close() + + +def killxscreensaver(): + logging.info(" Stopping xscreensaver") + cmd="xscreensaver-command --exit " + mv_common.runcmd(cmd) + cmd="killall xscreensaver " + mv_common.runcmd(cmd) + +def killgscreensaver(): + logging.info(" Stopping gnome-screensaver") + cmd="gnome-screensaver-command --exit " + mv_common.runcmd(cmd) + cmd="killall gnome-screensaver " + mv_common.runcmd(cmd) + + +def setup_x_screensaver(idle,theme,screenconfigfile,templatefile): + logging.info(" Configuring X screensaver") + killgscreensaver() + logging.debug(" Why can't xscreensaver have a nice configuration !") + + if not os.path.exists(screenconfigfile): + logging.debug(" copying in new template file") + mv_common.cp_and_log(templatefile,screenconfigfile) + + try: + f = open(screenconfigfile, 'r') + screenconfigcontents=f.readlines() + f.close() + except: + logging.info("Couldn't open %s for reading",screenconfigfile) + return + try: + f = open(screenconfigfile, 'w') + except: + logging.info("Couldn't open %s for writing",screenconfigfile) + return + + startline=0 + foundline=0 + + for k, line in enumerate(screenconfigcontents): + if re.match("programs:",line): + startline = k + if re.search(theme,line): + foundline = k + themenumber=foundline-startline-2 + + for line in screenconfigcontents: + if re.match("selected.*$",line): + continue + + if re.match("timeout",line): + logging.info(" Setting idletime to %s",idle) + outline = "timeout: 0:%s:00 \n" %idle + f.write(outline) + elif re.match("mode",line): + if theme == "Random": + logging.info(" Setting theme to %s", "Random") + outline = "mode: random \n" + f.write(outline) + outline = "selected: -1 \n" + f.write(outline) + continue + + elif theme == "Blank": + logging.info(" Setting theme to %s", "blank") + outline = "mode: blank \n" + f.write(outline) + outline = "selected: -1 \n" + f.write(outline) + continue + + else: + logging.info(" Setting theme to %s", theme) + outline = "mode: one\n" + f.write(outline) + logging.debug(" Theme number is %s",themenumber) + outline = "selected: %s\n" %themenumber + f.write(outline) + continue + + else: + outline = line + f.write(outline) + f.close() + logging.debug("__End of xscreensaver") + +def setup_gnome_screensaver(theme,idletime): + logging.info(" Configuring gnome screensaver") + + logging.info(" Disabling lock screen") + cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-screensaver/lock_enabled false''' + mv_common.runcmd(cmd) + + logging.info(" Setting idletime to %s",idletime) + cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type int -s "/apps/gnome-screensaver/idle_delay" %s''' %idletime + mv_common.runcmd(cmd) + + logging.info(" Setting mode to single") + cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/mode" single''' + mv_common.runcmd(cmd) + + if theme == "Random": + logging.info(" setting theme to random") + cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/mode" random''' + mv_common.runcmd(cmd) + + elif theme == "Blank": + logging.info(" setting theme to blank") + cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/themes" blank''' + mv_common.runcmd(cmd) + + else: + logging.info(" setting theme to %s",theme) + cmd='''gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --set --type list --list-type=string /apps/gnome-screensaver/themes [screensavers-%s]''' %theme + mv_common.runcmd(cmd) + + killxscreensaver() + logging.info("__End gnome screensaver") + + + + +def setup_screensaver (systemconfig,data_config): + logging.info("____Start of screensaver configuration____") + screensavertype = systemconfig["Screensavertype"] + theme = systemconfig["Screensavertheme"] + idletime = systemconfig["Screensaveridle"] + configfile = data_config.MYTHHOME+"/.xscreensaver" + templatefile = systemconfig["TEMPLATES"]+"/xscreensaver.template" + mtemplate = systemconfig["TEMPLATES"]+"/mplayer.conf.template" + + if screensavertype == "xscreensaver": + mv_common.pacinstall("xscreensaver") + mv_common.pacremove("gnome-screensaver") + setup_x_screensaver(idletime, theme, configfile, templatefile) + mplayer_saver_check("/usr/bin/xscreensaver-command -deactivate &",mtemplate) + + elif screensavertype == "gscreensaver": + mv_common.pacinstall("xscreensaver") + mv_common.pacinstall("gnome-screensaver") + setup_gnome_screensaver(theme,idletime) + mplayer_saver_check("/usr/bin/gnome-screensaver-command -p &",mtemplate) + + elif screensavertype == "none": + mv_common.pacremove("xscreensaver") + mv_common.pacremove("gnome-screensaver") + killgscreensaver() + killxscreensaver() + + elif screensavertype == "tinker" : + logging.debug(" screensaver tinker mode detected") + else: + logging.debug(" Unknown screensaver") + logging.info("__End of screensaver\n") + + + diff --git a/abs/core-testing/LinHES-config/mv_smolt.py b/abs/core-testing/LinHES-config/mv_smolt.py new file mode 100755 index 0000000..5fd3722 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_smolt.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +import logging +import mv_common + +def read_release(stype): + if stype == "LinHES": + rfile = "/etc/LinHES-release" + else: + rfile = "/etc/MythVantage-release" + + try: + f= open(rfile,'r') + releasename = f.readlines()[0] + f.close() + except: + logging.debug(" Couldn't open %s",rfile) + releasename = "unknown" + + return releasename + + +def setup_smolt_type(SystemType,Remotetype,RunFrontend,mythhome,stype): + logging.debug("____Start of setup_smolt_type____") + releasename = read_release(stype) + + if SystemType == "Standalone": + smoltsystem = 6 + MVRELEASE="%s (Standalone)" %releasename + elif SystemType == "Master_backend": + if RunFrontend == "1": + smoltsystem = 2 + MVRELEASE="%s (MBE with Frontend)" %releasename + else: + smoltsystem=1 + MVRELEASE="%s (MBE)" %releasename + elif SystemType == "Slave_backend": + if RunFrontend == "1" : + smoltsystem = 4 + MVRELEASE="%s (SLAVE with Frontend)" %releasename + else: + smoltsystem = 5 + MVRELEASE="%s (SLAVE)" %releasename + elif SystemType == "Frontend_only": + smoltsystem = 3 + MVRELEASE="%s ( Frontend only)" %releasename + + logging.debug(" smolt type is %s : %s", MVRELEASE,smoltsystem) + smoltfile = mythhome+"/.mythtv/smolt.info" + cmd = ''' echo "%s" > /etc/os_myth_release ''' %MVRELEASE + mv_common.runcmd(cmd) + + cmd = '''echo "systemtype=%s" > %s''' %(smoltsystem,smoltfile) + mv_common.runcmd(cmd) + + cmd = '''echo "remote=%s" >> %s ''' %(Remotetype,smoltfile) + mv_common.runcmd(cmd) + + logging.debug("__End of setup_smolt_type") + diff --git a/abs/core-testing/LinHES-config/mv_software.py b/abs/core-testing/LinHES-config/mv_software.py new file mode 100755 index 0000000..047a235 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_software.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +import logging, mv_common +import os, re + +def setup_software(systemconfig, data_config): + logging.info("____Start of Software install____") + default_disabled = ("mythphone", "mytharchive", "mythbrowser", "mythnews", + "mythgame", "mythflix", "mythweather", + "mythappletrailers", "mythstream", "mythvodka") + + default_installed=("mythcontrols", "mythgallery", "mythmovies", + "mythmusic", "mythsmolt", "mythvideo") + other_pkg=("miro", "xe", "romdb", "xine", "dvdcss", "webmin") + + for pkg in default_disabled: + try: + if systemconfig[pkg] == "1": + mv_common.pacinstall(pkg) + else: + mv_common.pacremove(pkg) + except: + logging.debug(" ERROR-- %s is not defined", pkg) + + for pkg in default_installed: + try: + if systemconfig[pkg] == "0": + mv_common.pacremove(pkg) + else: + mv_common.pacinstall(pkg) + except: + logging.debug(" ERROR-- %s is not defined", pkg) + + for pkg in other_pkg: + try: + if systemconfig[pkg] == "1": + mv_common.pacinstall(pkg) + elif systemconfig[pkg] == "0": + mv_common.pacremove(pkg) + except: + logging.debug(" ERROR-- %s is not defined", pkg) + logging.info("__End Software\n ")
\ No newline at end of file diff --git a/abs/core-testing/LinHES-config/mv_webuser.py b/abs/core-testing/LinHES-config/mv_webuser.py new file mode 100755 index 0000000..a8517a8 --- /dev/null +++ b/abs/core-testing/LinHES-config/mv_webuser.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +import logging, mv_common +#import os + +def setup_web_auth(UseMythWEB_auth): + logging.info("____Start of setup_web_auth____") + if UseMythWEB_auth == str(1): + #enable auth + logging.info(" Enabling authorization for mythweb") + cmd='''sed -i "s/^.*include.*auth-inc.conf.*$/include \\"\/etc\/lighttpd\/auth-inc.conf\\"/g" /etc/lighttpd/lighttpd.conf''' + mv_common.runcmd(cmd) + else: + #disable auth + logging.info(" Disabling authorization for mythweb") + cmd='''sed -i "s/^.*include.*auth-inc.conf.*$/#include \\"\/etc\/lighttpd\/auth-inc.conf\\"/g" /etc/lighttpd/lighttpd.conf''' + mv_common.runcmd(cmd) + logging.debug("Restarting lighttpd") + cmd="sudo sv restart lighttpd" + mv_common.runcmd(cmd) + logging.info("__End of webauth\n") + diff --git a/abs/core-testing/LinHES-config/systemconfig.py b/abs/core-testing/LinHES-config/systemconfig.py new file mode 100755 index 0000000..5ccaa10 --- /dev/null +++ b/abs/core-testing/LinHES-config/systemconfig.py @@ -0,0 +1,230 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import sys, os, commands, glob, time +import getopt, re, MySQLdb +import logging +import mv_common , mv_network +import inspect +#____________________________________________setup the logging______________________________________________________ +LOG_FILENAME = '/tmp/systemconfig.log' +DEBUGLOG = '/tmp/systemconfig_debug.log' +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + datefmt='%m-%d %H:%M', + filename=DEBUGLOG, + filemode='w') +# define a Handler which writes INFO messages or higher to the sys.stderr +console = logging.StreamHandler() +console.setLevel(logging.INFO) +# set a format which is simpler for console use +#formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') +formatter = logging.Formatter("%(message)s") +# tell the handler to use this format +console.setFormatter(formatter) +# add the handler to the root logger +logging.getLogger('').addHandler(console) + +#infoformatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") +infoformatter = logging.Formatter("%(message)s") +infofile = logging.FileHandler(LOG_FILENAME, 'w') +infofile.setFormatter(infoformatter) +infofile.setLevel(logging.INFO) +logging.getLogger('').addHandler(infofile) + + +def usage(): + logging.info("tell people how to use this") + +def setup_x(systemconfig): + cmd = "%s/bin/xconfig.sh" %systemconfig["MVROOT"] + mv_common.runcmd(cmd) + +def main(argv): + try: + MVROOT = os.environ["MV_ROOT"] + except: + logging.debug("MVROOT was not defined, using the default value") + MVROOT = "/usr/MythVantage" + + global cmdmodule + global systemconfig + systemconfig["MVROOT"]=MVROOT + restartlcd = False + cmdmodule={"misc":False , "sleep":False , "hostype":False , "hostypec":False , "advanced":False , "audio":False , "network":False , "advancedX":False , "webuser":False , "restartfe":False , "reloadfe":False , "ddns":False , "screensaver":False , "ir":False , "this_is_install":False , "user":False, "software":False, "plugins":False, "smolt":False, "all":False} + try: + opts, args = getopt.getopt(argv, 'c:hm:', ["help","modules" ] ) + except getopt.GetoptError, why: + print why + usage() + print "exception happened" + sys.exit(2) + for opt, arg in opts: + if opt in ("-h", "--help"): + usage() + sys.exit(0) + elif opt in ("-m"): + for i in arg.split(","): + cmdmodule[i]=True + + if cmdmodule["this_is_install"] or cmdmodule["hostypec"]: + systemconfig["hostypec"] = True + cmdmodule["smolt"] = True + + systemconfig["mythip"] = mv_network.setup_MYTH_IP(systemconfig) + systemconfig["mythdhcp"] = mv_network.setup_MYTH_DHCP(systemconfig) + + if cmdmodule["all"]: + logging.info("*** WILL RUN ALL MODULES ***") + cmdmodule["hostype"] = True + cmdmodule["ir"]= True + cmdmodule["network"] = True + cmdmodule["audio"] = True + cmdmodule["misc"] = True + cmdmodule["sleep"] = True + cmdmodule["webuser"] = True + cmdmodule["ddns"] = True + cmdmodule["screensaver"] = True + cmdmodule["advanced"] = True + cmdmodule["software"] = True + cmdmodule["advancedX"] = True + cmdmodule["smolt"] = True + cmdmodule["user"] = True + + + if cmdmodule["hostype"]: + import mv_hostype + cmdmodule["advancedX"] = True + setup_x(systemconfig) + cmdmodule["ir"] = True + mv_hostype.hostypeprint(systemconfig) + cmdmodule["smolt"] = True + + if cmdmodule["network"]: + mv_network.setup_network(systemconfig) + + + + if cmdmodule["ir"] == True: + import mv_ir + restart = mv_ir.setup_ir(systemconfig,data_config) + restartfe = restart[0] + restartlcd = restart[1] + if restartfe == True: + logging.debug(" Setting the frontend to restart due to lirc change") + cmdmodule["restartfe"] = True + cmdmodule["smolt"] = True + + + if cmdmodule["audio"] == True: + logging.debug("______Start of Audio Configuration______") + if not systemconfig["Audiotype"] == "tinker": + cmd="%s/bin/soundconfig.sh -t real -i %s -d %s" %(MVROOT,systemconfig["Audiotype"],systemconfig["SoundDevice"]) + mv_common.runcmd(cmd) + else: + logging.debug(" Tinker mode(audio), not changing configuration") + logging.debug("__End of audio") + + if cmdmodule["misc"]: + import mv_misc + mv_misc.setup_zip(MVROOT,systemconfig["zipcode"]) + mv_misc.setup_tz(systemconfig["timezone"],systemconfig["TEMPLATES"]) + mv_misc.setup_nfs(systemconfig) + + if cmdmodule["sleep"]: + import mv_misc + mv_misc.setup_sleep(systemconfig) + + if cmdmodule["webuser"]: + import mv_webuser + mv_webuser.setup_web_auth(systemconfig["UseMythWEB_auth"]) + + if cmdmodule["ddns"]: + print " LOOK FOR DDNS" + + if cmdmodule["screensaver"]: + import mv_screensaver + mv_screensaver.setup_screensaver(systemconfig, data_config) + + if cmdmodule["advanced"]: + import mv_advanced + mv_advanced.setup_advanced(systemconfig, data_config) + + if cmdmodule["software"] or cmdmodule["plugins"]: + import mv_software + mv_software.setup_software(systemconfig, data_config) + + if cmdmodule["advancedX"]: + setup_x(systemconfig) + + if cmdmodule["restartfe"]: + mv_common.restartfe(restartlcd) + + if cmdmodule["reloadfe"]: + mv_common.reloadfe(systemconfig["dbhost"],restartlcd) + + if cmdmodule["smolt"]: + import mv_smolt + mv_smolt.setup_smolt_type(systemconfig["SystemType"], + systemconfig["Remotetype"], + systemconfig["RunFrontend"], + data_config.MYTHHOME, + data_config.SYSTEMTYPE) + + if cmdmodule["user"]: + logging.info("____Start of ssh user____") + if systemconfig["rootSSH"] == "1" : + logging.info(" Allowing ssh access for root") + cmd = '''sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin yes/" /etc/ssh/sshd_config''' + mv_common.runcmd(cmd) + else: + logging.info(" Removing ssh access for root") + cmd = '''sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin no/" /etc/ssh/sshd_config''' + mv_common.runcmd(cmd) + logging.info("__End of ssh user\n") + +if __name__ == "__main__": + + config_file = "mv_config" + data_config = __import__(config_file, globals(), locals(), []) + #Read in systemconfig + global systemconfig + systemconfig = {"hostypec":False} + file_name = "/etc/systemconfig" + try: + config_file = open(file_name) + except: + logging.critical("%s could not be opened", file_name) + sys.exit(1) + + 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.strip('"') + systemconfig[var.strip()] = val.strip() + try: + systemconfig["TEMPLATES"] = os.environ["TEMPLATES"] + except: + logging.critical(" *TEMPLATES is not defined") + logging.critical(" *using default value") + systemconfig["TEMPLATES"] = "/usr/MythVantage/templates" + + logging.debug("______START OF DEBUG______") + main(sys.argv[1:]) + logging.debug("______cmd line options______") + for i in cmdmodule.items(): + logging.debug (i) + logging.debug("______systemconfig______") + for i in systemconfig.items(): + logging.debug(i) + #pass + + + + + + + + + + diff --git a/abs/core-testing/LinHES-config/systemconfig.sh b/abs/core-testing/LinHES-config/systemconfig.sh index 54d3b01..4f58ee2 100755 --- a/abs/core-testing/LinHES-config/systemconfig.sh +++ b/abs/core-testing/LinHES-config/systemconfig.sh @@ -4,1453 +4,11 @@ #Any changes made to config files will be removed when systemconfig.sh is run # #JM -################################################################### -#set -x -. /etc/profile -#MVRELEASE=`cat /etc/mythvantage-release |cut -d" " -f -2` -MVRELEASE=`cat /etc/LinHES-release ` echo $@ >/tmp/systemconfig.call echo "----------------------start of systemconfig $@ ----------------------" -BASE="" - -#TEMPLATES="/usr/share/templates" . /etc/profile -MYTHHOME=$BASE/home/mythtv . $MV_ROOT/bin/networkconfig.sh -PACMAN="pacman --noconfirm" postfix=`cat ${BASE}/usr/local/share/mythtv/.releasetype` -PKGBLACKLIST=$BASE/etc/blacklist.package - -if [ x$1 = x"Mysql_only" ] - then - rm -f /tmp/mysql.txt - sed -e "s/^DBHostName=.*$/DBHostName=$2/" $TEMPLATES/mysql.txt > /tmp/mysql.txt - exit 0 - fi - - -if [ -f /etc/systemconfig ] -then - . /etc/systemconfig - setup_MYTH_vars -TEMPNET="Hostip"$default_interface -echo $TEMPNET -eval MYTHIP=\$${TEMPNET} -else - echo "could not find /etc/systemconfig" - exit 1 -fi - - -function cp_and_log () { - if [ -e $1 ] - then - echo "copying $1 to $2" - cp -rfp "$1" "$2" - else - echo "$1 is not present, skipping..." - fi - -} - - -#----------------------------------------------------- - - -function setupmysql { -#setup mysql.txt to find the database servers -echo "running setup mysql" - if [ $SystemType = "Master_backend" ] - then - if [ $MYTHDHCP = 0 ] - then - #this grabs eth0, as that is all thats supported. -# dbhost=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1` - dbhost=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'` - sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old - cp_and_log /tmp/systemconfig.old ${BASE}/etc/systemconfig - ##logic to change master_serverip and backend_serverip in db - - ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost - else - - dbhost=$MYTHIP - sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old - cp_and_log /tmp/systemconfig.old ${BASE}/etc/systemconfig - #logic to change dbhost in db - ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost - fi - fi - - if [ $SystemType = "Slave_backend" ] - then - if [ $MYTHDHCP = 0 ] - then - #this grabs eth0, as that is all thats supported. - #slavehost=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1` - slavehost=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'` - ##logic to change backend_serverip in db - ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s slave -a $slavehost - else - slavehost=$MYTHIP - - #logic to change backend_serverif in db - ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s slave -a $slavehost - fi - fi - - MYSQLTXT=${BASE}/usr/share/mythtv/mysql.txt - if [ $SystemType = "Standalone" ] - then - sed -e "s/^DBHostName=.*$/DBHostName="localhost"/" $TEMPLATES/mysql.txt > $MYSQLTXT - else - sed -e "s/^DBHostName=.*$/DBHostName=$dbhost/" $TEMPLATES/mysql.txt > $MYSQLTXT - fi - rm ${BASE}/home/mythtv/.mythtv/mysql.txt - rm ${BASE}${MV_ROOT}/bin/mythtv/.mythtv/mysql.txt - if [ -f ${BASE}/home/mythtv/templates/mysql.txt ] - then - cp_and_log ${BASE}/home/mythtv/templates/mysql.txt $MYSQLTXT - fi - - chmod 755 $MYSQLTXT - chown mythtv $MYSQLTXT - -} - -function setupmysqlnetwork(){ -MFILE=etc/my.cnf -grep "#skip-networking" $BASE/$MFILE -status=$? - - - - if [ $SystemType = "Standalone" ] - then - sed -ie "s/^#skip-networking/skip-networking/g" $BASE/$MFILE - if [ $status = 0 ] - then - sudo sv restart mysql - echo "restarting mysql with no network" - fi - - fi - - if [ $SystemType = "Master_backend" ] - then - sed -ie "s/^skip-networking/#skip-networking/g" $BASE/$MFILE - if [ $status = 1 ] - then - sudo sv restart mysql - echo "restarting mysql with network" - fi - - fi - - -} - - -function settimezone { -#set the timezone -if [ x"$timezone" = x ] -then - timezone="unknown" -fi -rm ${BASE}/etc/localtime -echo $timezone -ln -s "/usr/share/zoneinfo/$timezone" ${BASE}/etc/localtime - sed -e "s~^TIMEZONE=.*$~TIMEZONE=\"${timezone}\"~" ${BASE}/etc/rc.conf > $TEMPLATES/rc.conf - - -if [ -f ${BASE}/etc/php/php.ini ] -then - echo "changing timezone in php.ini" - sed -i "s/^.*date.timezone.*$/date.timezone=${timezone}/" ${BASE}/etc/php/php.ini -fi - - - -cp_and_log $TEMPLATES/rc.conf ${BASE}/etc/rc.conf -#Check for Atomic Ant -if grep disablemodules=agpart,intel_agp /proc/cmdline >/dev/null -then - cat /etc/rc.conf | sed -e '/MOD_BLACKLIST/ c\MOD_BLACKLIST=($ALSABLACKLIST agpart intel_agp)' > /etc/rc.conf.aa - mv /etc/rc.conf /etc/rc.conf.preaa - mv /etc/rc.conf.aa /etc/rc.conf -# else -# exit 1 -fi - -} - - -# function setupreceiver { -# case $ReceiverType in -# tinker) echo "do nothing" -# ;; -# Serial) echo "setup serial lirc" -# sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage -# echo "lirc_serial #lirc" >> ${BASE}/etc/modules.mythvantage -# load-modules-mythvantage.sh -# ;; -# Usb-imon) echo "setup receiver-usb-imon" -# sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage -# echo "lirc_imon #lirc" >> ${BASE}/etc/modules.mythvantage -# load-modules-mythvantage.sh -# ;; -# Hauppauge) echo "setup hauppauge reciever (lirc_i2c)" -# sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage -# echo "lirc_i2c #lirc" >> ${BASE}/etc/modules.mythvantage -# cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf -# rmmod lirc_i2c 2>/dev/null -# load-modules-mythvantage.sh -# ;; -# *) sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage -# ;; -# esac -# -# -# } - - -function setupevrouter { - if [ x$UseEvrouter = x1 ] - then - case x$EvrouterConfig in - xtinker ) - echo "do nothing for evrouter" - ;; - x ) echo "empty evrouter" - ;; - * ) echo "setup evrouter for $EvrouterConfig " - cp_and_log $TEMPLATES/evrouter/$EvrouterConfig /etc/evrouter.cfg - daemon_add="evrouter Xvfb $daemon_add" - - ;; - esac - else - # disable evrouter - daemon_remove="evrouter Xvfb $daemon_remove" - fi - - - - -} - - - -function scrubnfs { - cp_and_log /etc/fstab $TEMPLATES/fstab.conf.template - - sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab -} - -function setupfstab () { -# setupfstab $NFSserver $NFSshare $NFSmount - echo "#STARTSCRUB --------------anything in this block will be scrubbed" >> ${BASE}/etc/fstab - echo "$1 $2 nfs" >> ${BASE}/etc/fstab - if [ ! -e "$2" ] - then - mkdir -p "$2" - chown mythtv:mythtv "$2" - fi - if [ x$DCONFIG = x ] - then - mount $2 & - fi - echo "#ENDSCRUB" >> ${BASE}/etc/fstab -} - -function setupncidclient -{ - sed -e "s/^set Host.*$/set Host $dbhost /" $TEMPLATES/ncid.conf.template >${BASE}/etc/ncid/ncid.conf -} - -function setupnciddaemon { - if [ x$Runncidd = x1 ] - then - cp_and_log /etc/ncid/ncidd.conf $TEMPLATES/ncidd.conf.template - sed -e "s/.*set ttyport.*$/set ttyport = \/dev\/$nciddSerialPort /" $TEMPLATES/ncidd.conf.template >${BASE}/etc/ncid/ncidd.conf - fi - -} - -function setupntp () { - #this is used for backend or standlone types - if [ $1 = "1" ] - then - #MBE/STD use deafult - echo "Not changing ntp config" - else - #echo "server $dbhost" >> ${BASE}/etc/ntp.conf - echo "setting ntp to $dbhost" - sed -i "s/pool.ntp.org/$dbhost/g" ${BASE}/etc/ntp.conf - fi - - -} - -function setupplugins (){ - -pkglistinstall="" -pkglistremove="" -#default enabled -for i in mythcontrols mythgallery mythmovies mythmusic mythsmolt mythvideo -do - eval pkgvalue=\$${i} - if [ x$pkgvalue = x ] - then - pkglistinstall="$pkglistinstall $i$postfix" - else - if [ x$pkgvalue = x1 ] - then - pkglistinstall="$pkglistinstall $i$postfix" - else - pkglistremove="$pkglistremove $i$postfix" - fi - fi -done - -#default disabled -for i in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather mythappletrailers mythstream mythvodka -do - eval pkgvalue=\$${i} - if [ x$pkgvalue = x ] - then - pkglistremove="$pkglistremove $i$postfix" - else - if [ x$pkgvalue = x1 ] - then - pkglistinstall="$pkglistinstall $i$postfix" - else - pkglistremove="$pkglistremove $i$postfix" - fi - fi -done -#everything else -for i in miro xe romdb xine dvdcss webmin -do - eval pkgvalue=\$${i} - case $i in - xine) - if [ x$pkgvalue = x1 ] - then - pkglistinstall="$pkglistinstall xine-ui" - else - pkglistremove="$pkglistremove xine-ui" - fi - ;; - dvdcss) - if [ x$pkgvalue = x1 ] - then - pkglistinstall="$pkglistinstall libdvdcss" - else - pkglistremove="$pkglistremove libdvdcss" - fi - ;; - webmin) - ##Daemon_add is here because webmin is on the software page instead of the advanced screen - if [ x$pkgvalue = x1 ] - then - pkglistinstall="$pkglistinstall webmin" - daemon_add="webmin $daemon_add" - else - pkglistremove="$pkglistremove webmin" - daemon_remove="webmin $daemon_remove" - fi - ;; - *) - if [ x$pkgvalue = x1 ] - then - pkglistinstall="$pkglistinstall $i" - else - pkglistremove="$pkglistremove $i" - fi - ;; -esac - -done - - -install="$pkglistinstall $install" -remove="$pkglistremove $remove" - -} - -function LCDcheck () { -case x$LCDtype in - xtinker) echo "do nothing lcd " - ;; - xno_lcd) echo "no lcd " - ;; - xxosd) install="xosd lcdproc $install" - ;; - x) echo "lcd empty " - ;; -*) - install="lcdproc $install" - ;; -esac -} - - -function packages () { -#see which plugins need to be installed -echo " Starting to install Packages" -setupplugins -LCDcheck -if [ ! -f $PKGBLACKLIST ] -then - touch $PKGBLACKLIST -fi - for i in $remove - do - if [ ! x$i = xnone ] - then - echo "-----------$i --------------" - grep -q $i $PKGBLACKLIST - if [ $? = 1 ] - then - pacman -Q $i 2>/dev/null - #VAR=`pacman -Q $i 2>&1 ` - if [ $? = 0 ] - then - if [ $i = "mythweb$postfix" ] - then - pacman --noconfirm -R mythweb$postfix - echo removed $i - else - pacman --noconfirm -Rs $i - echo removed $i - fi - fi - else - echo "$i is black listed" - fi - fi - done - - - for i in $install - do - if [ ! x$i = xnone ] - then - echo "-----------$i --------------" - grep -q $i $PKGBLACKLIST - if [ $? = 1 ] - then - pacman -Q $i 2>/dev/null - #VAR=`pacman -Q $i 2>&1 ` - # echo $VAR |grep -vq error: - - if [ ! $? = 0 ] - then - pacman --noconfirm -Sf $i - echo installed $i - else - echo "$i already installed" - fi - else - echo "$i is black listed" - fi - fi - done -} - -function daemons { -echo "Daemons on boot" - - for i in $daemon_remove - do - sv check $i 1>/dev/null - status=$? - if [ $status -eq 0 ] - then - sv down $i - fi - remove_service.sh $i - done - - - for i in $daemon_add - do - sv check $i 1>/dev/null - status=$? - add_service.sh $i - - if [ $status -eq 0 ] - then - case $i in - mysql*) sv hup $i - ;; - mythback*) sv hup $i - ;; - lirc* ) sv hup $i - ;; - frontend) sv check frontend 1>/dev/null - ;; - - smbd ) sv hup $i - ;; - nmbd ) sv hup $i - ;; - evrouter) sv restart $i - ;; - *) sv down $i - sleep 1 - sv up $i - ;; - esac - fi - - done - -} - - -function services -{ -ser_install="" -ser_daemon_add="" -ser_remove="" -ser_daemon_remove="" -if [ x$UseEvrouter = x1 ] -then - ser_daemon_add="evrouter Xvfb $ser_daemon_add" -else - ser_daemon_remove="evrouter Xvfb $ser_remove" -fi - -if [ x$RunDHCP = x1 ] -then - ser_daemon_add="dnsmasq $ser_daemon_add" - ser_install="dnsmasq mvpmc $ser_install" - -else - ser_daemon_remove="dnsmasq $ser_daemon_remove" - ser_remove="dnsmasq mvpmc $ser_remove" -fi - -if [ x$RunFrontend = x1 ] -then - ser_daemon_add="frontend hal $ser_daemon_add" - ser_install=" $ser_install" - showX=true -else - ser_daemon_remove="frontend hal $ser_daemon_remove" - ser_remove="$ser_remove" -fi - -if [ x$UseMythWEB = x1 ] -then - ser_install="lighttpd mythweb$postfix $ser_install" - ser_daemon_add="lighttpd $ser_daemon_add" -else - ser_remove="mythweb$postfix $ser_remove" - ser_daemon_remove="$ser_daemon_remove" -fi - -#samba -if [ x$UseSamba = x1 ] -then - ser_install="samba $ser_install" - ser_daemon_add="nmbd smbd $ser_daemon_add " - if [ x$Samba_mediareadonly = x1 ] - then - smreadonly="no" - else - smreadonly="yes" - fi - - if [ x$Samba_homereadonly = x1 ] - then - shreadonly="no" - else - shreadonly="yes" - fi - - if [ ! -d ${BASE}/etc/samba ] - then - mkdir ${BASE}/etc/samba - fi - - if [ -f ${MYTHHOME}/templates/smb.conf ] - then - install -D -m755 ${MYTHHOME}/templates/smb.conf ${BASE}/etc/samba/smb.conf - else - sed -e "s/^.*workgroup =.*$/ workgroup = $Samba_domain/g " \ - -e "s/^.*server string = .*$/ server string = $hostname/g" $TEMPLATES/samba/smb.conf.template > ${BASE}/etc/samba/smb.conf - - if [ x$Samba_media = "x1" ] - then - echo "include = /etc/samba/smb.conf.media" >> ${BASE}/etc/samba/smb.conf - sed -e "s/^.*writeable.*$/writeable = $smreadonly/g" $TEMPLATES/samba/smb.conf.media > ${BASE}/etc/samba/smb.conf.media - fi - - if [ x$Samba_home = "x1" ] - then - echo "include = /etc/samba/smb.conf.home" >> ${BASE}/etc/samba/smb.conf - sed -e "s/^.*writeable.*$/writeable = $shreadonly/g" $TEMPLATES/samba/smb.conf.home > ${BASE}/etc/samba/smb.conf.home - - fi - - fi -else - ser_remove="samba $ser_remove" - ser_install="smbclient $ser_install" - ser_daemon_remove="smbd nmbd $ser_daemon_remove" -fi - - -if [ x$UseNFS = x1 ] -then - ser_install="nfs-utils portmap $ser_install" - ser_daemon_add="nfsd nfs-utils portmap $ser_daemon_add" - sed -e "s/REPLACEME/*/g" $TEMPLATES/exports.template > ${BASE}/etc/exports - -else - ser_remove="$ser_remove" - ser_daemon_remove="nfsd $ser_daemon_remove" -fi - -if [ x$Runncidd = x1 ] -then - ser_daemon_add="ncidd ncid $ser_daemon_add" - ser_install="ncid $ser_install" -else - ser_daemon_remove="ncidd ncid $ser_daemon_remove" - ser_remove="ncid $ser_remove" -fi - - -if [ x$UseEvrouter = x1 ] -then - ser_install="evrouter Xvfb $ser_install" -else - ser_remove="evrouter $ser_remove" -fi - - -if [ x$DDnsEnable = x1 ] -then - ser_daemon_add="inadyn $ser_daemon_add" - ser_install="inadyn $ser_install" -else - ser_daemon_remove="inadyn $ser_daemon_remove" - ser_remove="inadyn $ser_remove" -fi - -case x$Screensavertype in - xxscreensaver) ser_install="xscreensaver $ser_install" - ser_remove="gnome-screensaver $ser_remove" - ;; - xgscreensaver) ser_install="xscreensaver gnome-screensaver $ser_install" - - ;; - xnone) ser_remove="gnome-screensaver xscreensaver $ser_remove" - ;; - - xtinker) echo "tinker mode for screensaver" - ;; - - esac - - - -#Setting the default, just to avoid the or statement.. -#if [ x$UseHobbit = x ] -#then -# UseHobbit=0 -#fi - -#if [ x$UseHobbit = x1 ] -#then -# case $SystemType in -# Standalone|Master_backend ) -# ser_daemon_add="hobbit $ser_daemon_add" -# ser_install="hobbitserver $ser_install" -# ;; -# -# *) ser_daemon_add="hobbit-client $ser_daemon_add" -# ser_install="hobbit-client $ser_install" -# ;; -# esac -#else -# ser_daemon_remove="hobbit hobbit-client $ser_daemon_remove" -# ser_remove="hobbit-client hobbitserver $ser_remove" -# rm -f /data/srv/httpd/htdocs/hobbit/index.html -# -# fi - - - -} - - - -function setupsleep { -if [ x$AutoShutdown = x1 ] -then - cronshutdowntime="" - if [ x$Shutdowntime != x-1 ] - then - cronshutdowntime=$Shutdowntime - fi - if [ x$Shutdowntime2 != x-1 ] - then - if [ x$cronshutdowntime = x ] - then - cronshutdowntime=$Shutdowntime2 - else - cronshutdowntime="${cronshutdowntime},${Shutdowntime2}" - fi - fi - - sed -e "s/HOUR/$cronshutdowntime/g" $TEMPLATES/cron.template | crontab - -u mythtv -else - sed -e "/00 HOUR.*/d" $TEMPLATES/cron.template | crontab - -u mythtv -fi - -} - - -function setuppacman () { -#setup link to httpd dir -echo "Configuring pacman" -if [ ! x$1 = x ] - then - ln -s ${BASE}/data/var ${BASE}/data/srv/httpd/htdocs/repo - echo "creating the link for the pacman repo mirror" - fi - - for i in mv-core mv-core-testing mv-extra mv-extra-testing - do - echo "[$i]" > ${BASE}/etc/pacman.d/$i - #add mirror if needed - if [ x$PKG_MIRROR = x1 ] - then - echo " Server = http://$dbhost/repo/$i " >> ${BASE}/etc/pacman.d/$i - fi - #add user templates - USERTEMPLATES="/data/home/mythtv/templates" - if [ -f $USERTEMPLATES/sources/$i ] - then - echo "Adding user $i" - cat $USERTEMPLATES/sources/$i >> ${BASE}/etc/pacman.d/$i - fi - cat $TEMPLATES/sources/$i >> ${BASE}/etc/pacman.d/$i - echo "setting local mirror to $dbhost for $i " - done - - #sed -e "s/REPLACEME/$dbhost/g" $TEMPLATES/sources/svc_pkg > /etc/pacman.d/svc_pkg - - -} - - -function setupzipcode () { - if [ ! x$zipcode = x ] - then - ${MV_ROOT}/bin/restore_default_settings.sh -c ZIP -z $zipcode - #Let's also speed things up for those in North America - mkdir /usr/bin/perlbin/vendor/tv_grabbers_non_na - mv /usr/bin/perlbin/vendor/tv_grab_* /usr/bin/perlbin/vendor/tv_grabbers_non_na - mv /usr/bin/perlbin/vendor/tv_grabbers_non_na/tv_grab_na* /usr/bin/perlbin/vendor/ - fi -} - -function process_nfsmap () { -#first look for a local copy of nfsmap -if [ $1 = noip ] -then - if [ -f /data/home/mythtv/templates/nfsmap ] - then - NFSMAP="/data/home/mythtv/templates/nfsmap" - else - mv -f /tmp/nfsmap /tmp/nfsmap.old - wget -O /tmp/nfsmap http://$dbhost:1337/templates/nfsmap - if [ $? = 0 ] - then - NFSMAP="/tmp/nfsmap" - fi - fi -else - mv -f /tmp/nfsmap /tmp/nfsmap.old - wget -O /tmp/nfsmap http://$1:1337/templates/nfsmap - if [ $? = 0 ] - then - NFSMAP="/tmp/nfsmap" - fi -fi - - if [ -f $NFSMAP ] - then - #read in file - while read line - do - NFSserver=`echo "$line"|cut -d" " -f1` - NFSmount=`echo "$line"|cut -d" " -f2` - setupfstab $NFSserver $NFSmount - done <$NFSMAP - else - echo "couldn't find nfsmap" - - fi -} - -function setupcnfs () { - scrubnfs - if [ $HaveCentralNFS = "yes" ] - then - case x$NFSserver in - xfile:nfsmap ) - process_nfsmap noip - ;; - *:nfsmap ) - nfsmapip=`echo "$NFSserver" | cut -d: -f1 ` - process_nfsmap $nfsmapip - ;; - *) setupfstab $NFSserver $NFSmount - esac - - #if [ ! x"$NFSserver" = "xfile:nfsmap" ] - #then - # setupfstab $NFSserver $NFSmount - #else - # process_nfsmap - #fi - else - echo "fe_nfs" - #if no central nfs found, then use the mbe. - if [ $SystemType = "Frontend_only" ] - then - setupfstab ${dbhost}:/myth /myth - fi - fi - -} - -function setupbootsplash () { - -if [ x$Usebootsplash = x1 ] -then - COMMAND="%s/^default.*0/default 1/g" -else - COMMAND="%s/^default.*1/default 0/g" -fi - -ex ${BASE}/boot/grub/menu.lst <<EOF -:$COMMAND -:wq -EOF - -} - -function setuphobbitclient () { -COMMAND="%s/^BBDISP=.*$/BBDISP=$dbhost/g" - - -ex ${BASE}/data/srv/hobbit/client/etc/hobbitclient.cfg <<EOF -:$COMMAND -:wq -EOF - -} - -function setupSyslog () { -COMMAND="%s/^destination d_remote.*$/destination d_remote \{tcp\(\"${dbhost}\" port\(514\)\) \;\} \;/" -ex ${BASE}/etc/syslog-ng.conf <<EOF -:$COMMAND -:wq -EOF - - - - -} - -function setupfuncminion () { -COMMAND="%s/^certmaster.*$/certmaster = ${dbhost}/" -ex ${BASE}/etc/func/minion.conf <<EOF -:$COMMAND -:wq -EOF -} - -function setupDNSMASQ(){ -if [ x$RunDHCP = x1 ] -then - echo "DNSMASQ setup" - -#set default route to my GW -COMMAND="%s/^dhcp-option=3.*$/dhcp-option=3,${route}/" -ex ${BASE}/etc/dnsmasq.conf <<EOF -:$COMMAND -:wq -EOF - -#setup dns to my ip -COMMAND="%s/^dhcp-option=6.*$/dhcp-option=6,${ip}/" -ex ${BASE}/etc/dnsmasq.conf <<EOF -:$COMMAND -:wq -EOF - - -#change nfsroot to my ip -COMMAND="%s/nfsroot=.*:/nfsroot=${ip}:/" -ex ${BASE}/data/srv/tftp/pxelinux.cfg/default <<EOF -:$COMMAND -:wq -EOF - -#add 127.0.0.1 to /etc/resolv.conf - echo "search lan" > ${BASE}/etc/resolv.conf - echo "nameserver 127.0.0.1" >> ${BASE}/etc/resolv.conf - echo "nameserver $nameserver" >> ${BASE}/etc/resolv.conf -fi - -#setup dongle.config -COMMAND="%s/mvpmc -f .*/mvpmc -f \/etc\/helvR10.fon -s ${ip} \& /" -ex ${BASE}/data/srv/tftp/dongle.bin.config <<EOF -:$COMMAND -:wq -EOF - - - -#setup dongle.config - -} - -function reloadfe(){ -PID=`ps -ef |grep mythfrontend|grep -v grep |awk '{print $2 }'` -/usr/bin/backend_control.sh clearcache behost $dbhost -if [ x$RESTART_LCD = xtrue ] -then - killall -9 mythlcdserver -fi -if [ x = x$PID ] -then - echo "Mythfrontend not running, will not reload" -else - kill -s USR1 $PID -fi -exit 0 - -} - - -function setup_db (){ - - install="mysql avahi" - daemon_add="mysql" - packages - daemons -status=1 -mysqlstatus=1 -while [ ! $status = 0 ] -do - sv stop mysql - sleep 1 - sv start mysql - mysqlstatus=$? - if [ $mysqlstatus = 0 ] - then - mysql -e "show databases;" - showstatus=$? - if [ $showstatus = 0 ] - then - pacman --noconfirm -R mythdb-initial - pacman --noconfirm -S mythdb-initial - $MV_ROOT/bin/restore_default_settings.sh -c load - if [ $SystemType = "Master_backend" ] - then - $MV_ROOT/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost - fi - #update database to allow user jobs on this host. - $MV_ROOT/bin/restore_default_settings.sh -c USERJOBALLOW - $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL - if [ -d /data/srv/mysql/mythconverg ] - then - pacman --noconfirm -R webcalendar - pacman --noconfirm --nodeps -S webcalendar - status=0 - fi - fi - fi -done -} - -function setup_web_auth { - if [ x$UseMythWEB_auth = x1 ] - then - #enable auth - sed -ie "s/^.*include.*auth-inc.conf.*$/include \"\/etc\/lighttpd\/auth-inc.conf\"/g" /etc/lighttpd/lighttpd.conf - else - #disable auth - sed -ie "s/^.*include.*auth-inc.conf.*$/#include \"\/etc\/lighttpd\/auth-inc.conf\"/g" /etc/lighttpd/lighttpd.conf - fi - sudo sv restart lighttpd - -} - - -function mplayer_saver_check () { - if [ ! -f $BASE/etc/mplayer/mplayer.conf ] - then - mkdir -p $BASE/etc/mplayer - touch $BASE/etc/mplayer/mplayer.conf - #cp -f $TEMPLATES/mplayer.conf.template $BASE/etc/mplayer/mplayer.conf - fi - grep -q stop-xscreensaver $BASE/etc/mplayer/mplayer.conf - if [ $? = 0 ] - then - sed -i "s/^.*stop-xscreensaver.*$/stop-xscreensaver = 1 / g" $BASE/etc/mplayer/mplayer.conf - else - echo stop-xscreensaver = 1 >> $BASE/etc/mplayer/mplayer.conf - fi - grep -q heartbeat-cmd $BASE/etc/mplayer/mplayer.conf - if [ $? = 0 ] - then - sed -i '/^.*heartbeat-cmd.*$/d' $BASE/etc/mplayer/mplayer.conf - #sed -i "s/^.*heartbeat-cmd.*$/heartbeat-cmd=\"$1\"/ g" $BASE/etc/mplayer/mplayer.conf - fi - echo "heartbeat-cmd = \"$1\"" >> $BASE/etc/mplayer/mplayer.conf -} - - - -function killxscreensaver { - xscreensaver-command --exit & - killall xscreensaver & -} - -function killgscreensaver(){ - gnome-screensaver-command --exit & - killall gnome-screensaver & -} - - -function setupscreensaver { -#copy in template - -case x$Screensavertype in - xxscreensaver) - killgscreensaver - #why can't it have a nice conf tool like gconf - if [ ! -f $MYTHHOME/.xscreensaver ] - then - #copy in template - cp -f $TEMPLATES/xscreensaver.template $MYTHHOME/.xscreensaver - fi - #change the idle - sed -i "s/^timeout.*$/timeout: 0:$Screensaveridle:00/g" $MYTHHOME/.xscreensaver - - #set the mode - case x$Screensavertheme in - xRandom) - sed -i "s/^mode.*$/mode: random/g" $MYTHHOME/.xscreensaver - ;; - xBlank) - sed -i "s/^mode.*$/mode: blank/g" $MYTHHOME/.xscreensaver - ;; - *) sed -i "s/^mode.*$/mode: one/g" $MYTHHOME/.xscreensaver - #set the theme - start=`awk '/programs/{print NR" "}' $MYTHHOME/.xscreensaver` - ss=`awk '/'$Screensavertheme'/{print NR" "}' $MYTHHOME/.xscreensaver` - sspos=$((ss-start-1)) - sed -i "s/^selected.*$/selected: $sspos/g" $MYTHHOME/.xscreensaver - - ;; - esac - mplayer_saver_check "/usr/bin/xscreensaver-command -deactivate &" - ;; - xgscreensaver) - gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-screensaver/lock_enabled false - gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type int -s "/apps/gnome-screensaver/idle_delay" $Screensaveridle - gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/mode" single - - case x$Screensavertheme in - xRandom) - gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/mode" random - - ;; - xBlank) - gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string -s "/apps/gnome-screensaver/themes" blank - ;; - - *) - gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --set --type list --list-type=string /apps/gnome-screensaver/themes [screensavers-$Screensavertheme] - ;; - esac - mplayer_saver_check "/usr/bin/gnome-screensaver-command -p &" - killxscreensaver - ;; - xnone) killgscreensaver - killxscreensaver - ;; - - xtinker) echo "tinker mode for setupscreensaver" - ;; - - esac - -# -# #start it if not already running. -# if [ x$XScreensaver = x1 ] -# then -# #check if it's running, it not start it. -# if [ ! x$MV_NEW_INSTALL = "xtrue" ] -# then -# su - mythtv -c "/usr/bin/gnome-screensaver " -# fi -# else -# #kill it -# gnome-screensaver-command --exit & -# killall gnome-screensaver & -# fi - - - -} -#----------------------------------------------------MAIN PROGRAM------------------------------------------- -#misc,sleep,hostype,advanced,audio -eval LAST=\$$# -LIST=`echo $LAST | tr , " " ` - -hosttypechange="false" - - -for i in $LIST -do -echo $i -case $i in - misc) showmisc="true" - ;; - sleep) showsleep="true" - ;; - hostype) showhost="true" - showX="true" - ;; - hostypec) hosttypechange="true" - ;; - advanced) showadvanced="true" - ;; - audio) showaudio="true" - ;; - network) shownetwork="true" - ;; - advancedX) showX="true" - ;; - webuser) setup_web_auth - ;; - restartfe) killall -9 mythfrontend - killall -9 mythwelcome - exit 0 - ;; - reloadfe) reloadfe - ;; - ddns) services - install=$ser_install - remove=$ser_remove - daemon_add=$ser_daemon_add - daemon_remove=$ser_daemon_remove - ;; - screensaver) - services - install=$ser_install - remove=$ser_remove - daemon_add=$ser_daemon_add - daemon_remove=$ser_daemon_remove - showscreensaver="true" - ;; - ir) - showir="true" - ;; - - this_is_install) MV_NEW_INSTALL="true" - ;; - user) - if [ x$rootSSH = "x1" ] - then - sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin yes/" $BASE/etc/ssh/sshd_config - else - sed -i "s/^.*PermitRootLogin.*$/PermitRootLogin no/" $BASE/etc/ssh/sshd_config - fi - sv hup sshd - ;; - esac -done - -if [ x$MV_NEW_INSTALL = xtrue ] -then - hosttypechange="false" -fi - - - -# exit 1 - -#network -if [ x"$shownetwork" = xtrue ] -then - OLDHOSTNAME=`hostname` - NEWHOSTNAME=$hostname - if [ ! $OLDHOSTNAME = $NEWHOSTNAME ] - then - - ${MV_ROOT}/bin/restore_default_settings.sh -cuhostname -o -h$OLDHOSTNAME - RESTART_FE="true" - hostname $NEWHOSTNAME - if [ $SystemType != "Frontend_only" ] - then - sv restart mythbackend - fi - - fi - - setup_network - CMDLINE=$(cat /proc/cmdline) - echo $CMDLINE |grep -q netboot - NETBOOT=$? - if [ x$NETBOOT = x1 ] - then - echo "loading network" - ${BASE}/etc/net/scripts/network.init reload - ${BASE}/etc/net/scripts/network.init restart - else - echo "netboot, will not start network" - fi -fi - - -if [ x$showhost = "xtrue" ] -then - . $MV_ROOT/bin/ir_config.sh - setupir - case $SystemType in - Standalone) - setupntp 1 - services - - if [ x$hosttypechange = "xtrue" ] - then - setup_db - fi - if [ -f ${BASE}/etc/avahi/services/mysql.service ] - then - rm -f ${BASE}/etc/avahi/services/mysql.service - sudo sv restart avahi - fi - - install="mysql mythdb-initial avahi portmap nfs-utils local-website $ser_install" - remove="none $ser_remove" - - daemon_add="mysql mythbackend avahi portmap nfs-utils netfs lighttpd $ser_daemon_add" - daemon_remove="none $ser_daemon_remove" - - ;; - Master_backend) - setupntp 1 - services - - if [ ! -f ${BASE}/etc/avahi/services/mysql.service ] - then - mkdir ${BASE}/etc/avahi/services - cp $TEMPLATES/mysql.service ${BASE}/etc/avahi/services/mysql.service - sudo sv restart avahi - fi - - install="mysql mythdb-initial avahi portmap nfs-utils local-website myth2ipod mythtv-status $ser_install " - remove="$ser_remove" - - daemon_add="mysql mythbackend avahi portmap nfs-utils netfs lighttpd $ser_daemon_add" - daemon_remove="$ser_daemon_remove" - ;; - Slave_backend) - setupntp 0 - services - if [ x$hosttypechange = "xtrue" ] - then - setup_db - fi - if [ -f ${BASE}/etc/avahi/services/mysql.service ] - then - rm -f ${BASE}/etc/avahi/services/mysql.service - sudo sv restart avahi - fi - - #cp $TEMPLATES/mysql.service ${BASE}/etc/avahi/services/mysql.service - install="mysql avahi local-website portmap nfs-utils $ser_install " - remove=" $ser_remove" - - daemon_add="mythbackend avahi portmap nfs-utils netfs lighttpd $ser_daemon_add" - daemon_remove="$ser_daemon_remove" - ;; - Frontend_only) - #Add values for services - setupntp 0 - services - if [ -f ${BASE}/etc/avahi/services/mysql.service ] - then - rm -f ${BASE}/etc/avahi/services/mysql.service - sudo sv restart avahi - fi - - install="libmysqlclient mysql-clients portmap nfs-utils avahi local-website $ser_install" - remove="mysql mythweb$postfix $ser_remove" - - daemon_add="avahi portmap nfs-utils netfs lighttpd $ser_daemon_add " - daemon_remove="mysql mythbackend $ser_daemon_remove" - ;; - esac - #setupSyslog - -fi - -#apply these to ALL types - - - - -#systemtype - -if [ x$showhost = "xtrue" ] -then - setupmysqlnetwork - setupmysql - - #setupremote - #REMOTE FIND ME JM - - #grab the new dbhost key - #/usr/bin/grabkey.py -fi - -#audio - -if [ x$showaudio = "xtrue" ] -then - #setupsoundtype - if [ ! x$Audiotype = xtinker ] - then - ${MV_ROOT}/bin/soundconfig.sh -t real -i $Audiotype -d $SoundDevice - fi -fi - -#should always run -packages - -#misc - -if [ x$showmisc = "xtrue" ] -then - setupzipcode - settimezone - setupcnfs -fi - -#sleep -if [ x$showsleep = "xtrue" ] -then - setupsleep -fi - -if [ x$showX = "xtrue" ] -then - ${MV_ROOT}/bin/xconfig.sh -fi - -#advanced -if [ x$showadvanced = "xtrue" ] -then - if [ ! x$showhost = "xtrue" ] - then - services - install="none $ser_install" - remove="none $ser_remove" - daemon_add=" none $ser_daemon_add" - daemon_remove="none $ser_daemon_remove" - packages - - - if [ x$SystemType = xMaster_backend ] - then - setuppacman link - else - setuppacman - fi - fi - setupncidclient - setupnciddaemon - setupbootsplash - setuphobbitclient - #setupreceiver - setupevrouter - #setupblaster - #setupLCD - setupDNSMASQ - - - -fi - -if [ x$showscreensaver = xtrue ] -then - setupscreensaver -fi - -if [ x$showir = xtrue ] -then - . $MV_ROOT/bin/ir_config.sh - setupir -fi - -daemons -#add check for lcd, and restart if needed. - -if [ x$RESTART_FE = xtrue ] -then - reloadfe -fi - - - - -case $SystemType in - Standalone) smoltsystem=6 - MVRELEASE="$MVRELEASE (Standalone)" - ;; -Master_backend) - if [ x$RunFrontend = x1 ] - then - smoltsystem=2 - MVRELEASE="$MVRELEASE (MBE with Frontend)" - else - smoltsystem=1 - MVRELEASE="$MVRELEASE (MBE)" - fi - ;; -Slave_backend) - if [ x$RunFrontend = x1 ] - then - smoltsystem=5 - MVRELEASE="$MVRELEASE (SLAVE with Frontend)" - else - smoltsystem=5 - MVRELEASE="$MVRELEASE (SLAVE)" - fi - ;; - Frontend_only) - smoltsystem=3 - MVRELEASE="$MVRELEASE ( Frontend only)" - ;; -esac -echo $MVRELEASE > /etc/os_myth_release -echo "systemtype=$smoltsystem" > /home/mythtv/.mythtv/smolt.info 2>/dev/null -echo "remote=$Remotetype" >> /home/mythtv/.mythtv/smolt.info 2>/dev/null +systemconfig.py -m $@ diff --git a/abs/core-testing/libcap/PKGBUILD b/abs/core-testing/libcap/PKGBUILD index 8d09b19..a80dccf 100644 --- a/abs/core-testing/libcap/PKGBUILD +++ b/abs/core-testing/libcap/PKGBUILD @@ -1,20 +1,22 @@ -#$Id: PKGBUILD 8870 2008-08-16 22:39:56Z eric $ -# Maintainer: Arjan Timmerman <arjan@archlinux.org> +#$Id: PKGBUILD 29964 2009-03-15 02:32:04Z hugo $ +# Maintainer: Hugo Doria <hugo@archlinux.org> + pkgname=libcap -pkgver=1.10 -pkgrel=2 +pkgver=2.16 +pkgrel=3 pkgdesc="POSIX 1003.1e capabilities" -arch=(i686 x86_64) +arch=('i686' 'x86_64') url="http://www.kernel.org/pub/linux/libs/security/linux-privs/" -license="GPL" +license=('GPL') depends=('glibc') -source=(http://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.4/${pkgname}-${pkgver}.tar.gz - libcap-1.10-debian.patch) -md5sums=('2c09eea823f67cfdde96177a959bc39b' 'ba642c86c4072917fcff77ec31411194') +source=(http://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/${pkgname}-${pkgver}.tar.gz) +md5sums=('9e075fda242c4070ba76407064c13302') build() { - cd ${startdir}/src/${pkgname}-${pkgver} - patch -Np1 -i ${startdir}/src/libcap-1.10-debian.patch || return 1 - make prefix=/usr DESTDIR=${startdir}/pkg install - rmdir ${startdir}/pkg/usr/share/man/man2 + cd ${srcdir}/${pkgname}-${pkgver} + sed -i -e "s|LIBDIR=\$(FAKEROOT)\$(lib_prefix)/\$(lib)|LIBDIR=\$(FAKEROOT)/\$(lib)|g" Make.Rules || return 1 + make prefix=/usr DESTDIR=${pkgdir} install + + rm ${pkgdir}/lib/*.a || return 1 + chmod 755 ${pkgdir}/lib/libcap.so.* || return 1 } diff --git a/abs/core-testing/local-website/PKGBUILD b/abs/core-testing/local-website/PKGBUILD index e02a757..6ce813c 100644 --- a/abs/core-testing/local-website/PKGBUILD +++ b/abs/core-testing/local-website/PKGBUILD @@ -1,6 +1,6 @@ pkgname=local-website pkgver=2 -pkgrel=6 +pkgrel=7 pkgdesc="Contents of http://localhost" arch=(i686 x86_64) license=('GPL') diff --git a/abs/core-testing/local-website/htdocs/fuppes.php b/abs/core-testing/local-website/htdocs/fuppes.php new file mode 100644 index 0000000..f082f31 --- /dev/null +++ b/abs/core-testing/local-website/htdocs/fuppes.php @@ -0,0 +1,4 @@ +<?php +$HTTP_HOST = getenv('HTTP_HOST'); +header("Location: http://$HTTP_HOST:81/"); +?> diff --git a/abs/core-testing/local-website/htdocs/index.html b/abs/core-testing/local-website/htdocs/index.html index 661f673..14d5c22 100644 --- a/abs/core-testing/local-website/htdocs/index.html +++ b/abs/core-testing/local-website/htdocs/index.html @@ -1,22 +1,39 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> + + <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> + + <meta content="Cecil Watson" name="author"> + + + + <title>LinHES R6</title> <link href="KnoppMyth.css" rel="stylesheet" type="text/css"> </head> + + <body> <p align="center"><a href="http://www.mysettopbox.tv"> <img src="header.png" alt="Tux with a Remote" align="middle" border="0"></a> </p> + + + <table align="center" border="0" cellpadding="5"> <tbody> + <tr> + <td style="vertical-align: top;"> + <p class="headerimage" align="center"><b>The Linux Home Entertainment System Release 6</b></p> + <p><a href="mythweb/mythweb.php"><b>MythWeb</b></a>: <br> The MythWeb allows you to use a web page to control @@ -24,6 +41,7 @@ but it is dependent upon MythTV being installed and operational." </p> + <p><a href="remote/index.html"><b>MythTV Web Virtual Remote</b></a>: <br> A web based virtual remote control for MythTV. @@ -32,32 +50,38 @@ <b>Utilities/Setup -> Setup -> General -> Fourth Page</b>. </p> + <p><a href="mythtv-doc/mythtv-HOWTO.html"><b>MythTV Documentation</b></a>: <br> The MythTV Installation / User's Guide. </p> + <p><a href="mythtv-doc/keys.txt"><b>MythTV Keybindings</b></a>: <br> The keybindings for the normal MythTV interface. </p> + <p><a href="linhes.html"><b>LinHES</b></a>: <br> Describes how "The Project Leader" setup multiple systems to form a <b>Lin</b>ux <b>H</b>ome <b>E</b>ntertainment <b>S</b>ystem. </p> + <p><a href="folding@home/"><b>My Folding Status</b></a>: <br> Status of the folding@home work for the local user. </p> + <p><a href="http://fah-web.stanford.edu/cgi-bin/main.py?qtype=teampage&teamnum=50975"><b>Folding@home</b></a>: <br> KnoppMyth Team status for the folding@home effort. </p> + <p><a href="ipodfeed/"><b>iPod Feeds</b></a> <br> Transcodes ready for the ipod (if any).</p> @@ -67,62 +91,27 @@ FUPPES - Free UPnP Entertainment Service. A UPnP to be used inplace of the UPnP server that comes with MythTV. If the UPnP that comes with MythTV doesn't work for you, you can -try FUPPES. Edit <i>/etc/sv/mythtvbackend/run</i>, and add "<i>--noupnp</i>" -to the command line for <i>/usr/bin/mythbackend</i>. Then restart the -backend and start FUPPES.</p> - <p style="font-weight: bold;">sv restart mythtvbackend fuppes</p> - <p>If you want FUPPES to start on boot add a link to the - <i>/etc/sv/fuppes</i> directory under <i>/var/service</i>.</p> - <p><b>ln -s /etc/sv/fuppes /var/service</b></p> - <p></p> - - <p><a href="motion/index.html"><b>Motion</b></a>: <br> - - Motion is a software motion detector. The configuration file for - motion is <i>/etc/motion/motion.conf</i>. All you should have to do is edit - "videodevice" to point to your webcam or capture device. You'll also - need to change the IP in <i>/var/www/motion/index.html</i> to the IP of your - backend. - <br><br> - - As root: <b>sv start motion</b> will start motion. - To have it start automatically add a link to the - <i>/etc/sv/motion</i> directory under <i>/var/service</i>.</p> - <p><b>ln -s /etc/sv/motion /var/service</b></p> - <p>Images and video are stored in <i>/myth/motion</i>. - Symlinks to <i>/myth/gallery</i> and <i>/myth/video</i> exist. - <br><br> - - For further detail on configuring Motion, please read the - <a href="http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide">Motion Guide</a>. - - </p> - +try FUPPES. + <p><a href="rrd/index.html"><b>RRDTool</b></a>: <br> Hardware status graphs. </p> - <p><a href="vlc_control.php"><b>VLC HTTP Interface</b></a>: <br> - - Web interface for VideoLan Client. - </p> - - <b>Tip:</b> - If you seem to be stuck in a - loop when trying to select a video to stream from MythWeb - (MythStreamTV), go back to the main - <a href="mythweb/">MythWeb</a> page and select "StreamTV" again. - + <p><a href="javascript:void(0)"onclick="window.open('mythweb/data/mp3player.html','linkname','height=100, width=260,scrollbars=no')"><b>KnoppMyth Radio</b></a>: <br> Your music must be encoded as MP3 in MythMusic for this to work.</p> + </td> + </tr> + <tr> <td style="vertical-align: top;"></td> </tr> </tbody> + </table> </body> diff --git a/abs/core-testing/perl_modules/perl-algorithm-diff/PKGBUILD b/abs/core-testing/perl_modules/perl-algorithm-diff/PKGBUILD index 38be2cc..d185772 100644 --- a/abs/core-testing/perl_modules/perl-algorithm-diff/PKGBUILD +++ b/abs/core-testing/perl_modules/perl-algorithm-diff/PKGBUILD @@ -2,13 +2,14 @@ # Maintainer: Charles Mauch <cmauch@gmail.com> pkgname=perl-algorithm-diff pkgver=1.1902 -pkgrel=3 +pkgrel=4 pkgdesc="Perl/CPAN Module Algorithm::Diff : Diff also Longest Common Subsequence" arch=("i686" "x86_64") url="http://search.cpan.org/TYEMQ/Algorithm-Diff" license=("GPL" "Artistic") source=("http://www.cpan.org/authors/id/T/TY/TYEMQ/Algorithm-Diff-1.1902.tar.gz") md5sums=("ff3e17ae485f8adfb8857b183991fbce") +groups=('shepherd-dep') build() { cd $startdir/src/Algorithm-Diff-1.1902 PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1 diff --git a/abs/core-testing/perl_modules/perl-digest-sha1/PKGBUILD b/abs/core-testing/perl_modules/perl-digest-sha1/PKGBUILD index 7a3a414..7bf6976 100644 --- a/abs/core-testing/perl_modules/perl-digest-sha1/PKGBUILD +++ b/abs/core-testing/perl_modules/perl-digest-sha1/PKGBUILD @@ -5,7 +5,7 @@ pkgname=perl-digest-sha1 _realname=Digest-SHA1 pkgver=2.11 -pkgrel=3 +pkgrel=4 pkgdesc="Perl Module: Interface to the SHA-1 Algorithm." arch=(i686 x86_64) license=('PerlArtistic') @@ -16,7 +16,7 @@ source=(http://www.cpan.org/authors/id/G/GA/GAAS/${_realname}-${pkgver}.tar.gz) replaces=('digest-sha1') provides=('digest-sha1') md5sums=('2449bfe21d6589c96eebf94dae24df6b') - +groups=('shepherd-dep') build() { cd ${startdir}/src/${_realname}-${pkgver} # install module in vendor directories. diff --git a/abs/core-testing/perl_modules/perl-javascript/PKGBUILD b/abs/core-testing/perl_modules/perl-javascript/PKGBUILD index 8ce00cb..564e2d9 100644 --- a/abs/core-testing/perl_modules/perl-javascript/PKGBUILD +++ b/abs/core-testing/perl_modules/perl-javascript/PKGBUILD @@ -1,7 +1,7 @@ pkgname=perl-javascript _realname=JavaScript pkgver=1.12 -pkgrel=1 +pkgrel=2 pkgdesc="get name of current working directory" arch=('i686' 'x86_64') url="http://search.cpan.org/~KWILLIAMS/Path-Class" @@ -11,6 +11,7 @@ depends=('perl>=5.10.0' spidermonkey) options=('!emptydirs') source=(http://search.cpan.org/CPAN/authors/id/C/CL/CLAESJAC/JavaScript-$pkgver.tar.gz) #source=(http://search.cpan.org/CPAN/authors/id/T/TB/TBUSCH/JavaScript-SpiderMonkey-0.19.tar.gz) +groups=('shepherd-dep') build() { cd $startdir/src/$_realname-$pkgver JS_INC=/usr/include/js PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1 diff --git a/abs/core-testing/perl_modules/perl-list-compare/PKGBUILD b/abs/core-testing/perl_modules/perl-list-compare/PKGBUILD index c1406c1..7480b98 100644 --- a/abs/core-testing/perl_modules/perl-list-compare/PKGBUILD +++ b/abs/core-testing/perl_modules/perl-list-compare/PKGBUILD @@ -4,12 +4,13 @@ pkgname=perl-list-compare _realname=List-Compare pkgver=0.37 -pkgrel=1 +pkgrel=2 pkgdesc="List::Compare - Compare elements of two or more lists" arch=(i686 x86_64) license=('PerlArtistic') url="http://search.cpan.org/dist/${_realname}/" depends=('perlxml' 'perl>=5.10.0') +groups=('shepherd-dep') options=('!emptydirs') source=(ftp://ftp.cpan.org/pub/CPAN/authors/id/J/JK/JKEENAN/${_realname}-${pkgver}.tar.gz) md5sums=('7c730dd58cc31a5bbb8eb7006edd1704') diff --git a/abs/core-testing/perl_modules/perl-pathtools/PKGBUILD b/abs/core-testing/perl_modules/perl-pathtools/PKGBUILD index 11e69ab..db11a6f 100644 --- a/abs/core-testing/perl_modules/perl-pathtools/PKGBUILD +++ b/abs/core-testing/perl_modules/perl-pathtools/PKGBUILD @@ -1,7 +1,7 @@ pkgname=perl-pathtools pkgver=3.29 -pkgrel=1 +pkgrel=2 pkgdesc="get name of current working directory" arch=('i686' 'x86_64') url="http://search.cpan.org/~KWILLIAMS/Path-Class" @@ -10,7 +10,7 @@ license=('GPL' 'PerlArtistic') depends=('perl>=5.10.0') options=('!emptydirs') source=(http://search.cpan.org/CPAN/authors/id/S/SM/SMUELLER/PathTools-$pkgver.tar.gz) - +groups=('shepherd-dep') build() { cd $startdir/src/PathTools-$pkgver PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1 diff --git a/abs/core-testing/plextor-convertX-driver/PKGBUILD b/abs/core-testing/plextor-convertX-driver/PKGBUILD index fb503fb..a02f88f 100755 --- a/abs/core-testing/plextor-convertX-driver/PKGBUILD +++ b/abs/core-testing/plextor-convertX-driver/PKGBUILD @@ -2,22 +2,22 @@ pkgname=plextor-convertX-driver pkgver=0.9.8 -pkgrel=3 -_kernver=2.6.27-ARCH +pkgrel=4 +_kernver=2.6.28-LinHES pkgdesc="Drivers for Plextor tuners" arch=(i686 x86_64) url="http://nikosapi.org/software/WIS_Go7007" install="convertX.install" -source=("http://nikosapi.org/software/WIS_Go7007/wis-go7007-linux-0.9.8-2.tar.bz2" 'wis-go7007-2.6.26-nopage.diff' 'wis-go7007-linux-0.9.8-2-2.6.27.patch') +source=("http://go7007.imploder.org/wp-content/uploads/2009/02/wis-go7007-linux-098-4tar.bz2" 'wis-go7007-2.6.26-nopage.diff' 'wis-go7007-linux-0.9.8-2-2.6.27.patch') depends=('udev>=070' 'fxload') makedepends=('gcc') build() { # SET UP - cd $startdir/src/wis-go7007-linux-0.9.8-2 || return 1 - patch -Np1 -i ../wis-go7007-2.6.26-nopage.diff || return 1 - patch -Np1 -i ../wis-go7007-linux-0.9.8-2-2.6.27.patch || return 1 + cd $startdir/src/wis-go7007-linux-0.9.8-4 || return 1 +# patch -Np1 -i ../wis-go7007-2.6.26-nopage.diff || return 1 +# patch -Np1 -i ../wis-go7007-linux-0.9.8-2-2.6.27.patch || return 1 # build make clean || return 1 make || return 1 diff --git a/abs/core-testing/plextor-convertX-driver/convertX.install b/abs/core-testing/plextor-convertX-driver/convertX.install index 8dfd0b7..8081c6a 100755 --- a/abs/core-testing/plextor-convertX-driver/convertX.install +++ b/abs/core-testing/plextor-convertX-driver/convertX.install @@ -5,7 +5,7 @@ pre_install() { post_install() { # updating module dependencies echo ">>> Updating module dependencies. Please wait ..." - KERNEL_VERSION=2.6.17-STB + KERNEL_VERSION=2.6.28-LinHES depmod -v $KERNEL_VERSION > /dev/null 2>&1 /bin/true } @@ -13,7 +13,7 @@ post_install() { post_upgrade() { # updating module dependencies echo ">>> Updating module dependencies. Please wait ..." - KERNEL_VERSION=2.6.17-STB + KERNEL_VERSION=2.6.28-LinHES depmod -v $KERNEL_VERSION > /dev/null 2>&1 /bin/true } @@ -21,7 +21,7 @@ post_upgrade() { post_remove() { # updating module dependencies echo ">>> Updating module dependencies. Please wait ..." - KERNEL_VERSION=2.6.17-STB + KERNEL_VERSION=2.6.28-LinHES depmod -v $KERNEL_VERSION > /dev/null 2>&1 /bin/true } diff --git a/abs/core-testing/system-templates/PKGBUILD b/abs/core-testing/system-templates/PKGBUILD index 4d72aad..5a195c5 100755 --- a/abs/core-testing/system-templates/PKGBUILD +++ b/abs/core-testing/system-templates/PKGBUILD @@ -1,6 +1,6 @@ pkgname=system-templates pkgver=1.0 -pkgrel=18 +pkgrel=20 conflicts=( ) pkgdesc="Templates used for system configuration" depends=() diff --git a/abs/core-testing/system-templates/templates/samba/smb.conf.home b/abs/core-testing/system-templates/templates/samba/smb.conf.home deleted file mode 100755 index c0f3136..0000000 --- a/abs/core-testing/system-templates/templates/samba/smb.conf.home +++ /dev/null @@ -1,10 +0,0 @@ -[home] - path = /home/mythtv/ - public = yes - only guest = yes - writeable = yes - printable = no - force user = mythtv - force group = mythtv - create mask = 0755 - diff --git a/abs/core-testing/system-templates/templates/samba/smb.conf.media b/abs/core-testing/system-templates/templates/samba/smb.conf.media deleted file mode 100755 index 914a321..0000000 --- a/abs/core-testing/system-templates/templates/samba/smb.conf.media +++ /dev/null @@ -1,10 +0,0 @@ -[myth] - path = /myth - public = yes - only guest = yes - writeable = yes - printable = no - force user = mythtv - force group = mythtv - create mask = 0755 - diff --git a/abs/core-testing/system-templates/templates/samba/smb.conf.template b/abs/core-testing/system-templates/templates/samba/smb.conf.template index aef29eb..da1e89e 100644 --- a/abs/core-testing/system-templates/templates/samba/smb.conf.template +++ b/abs/core-testing/system-templates/templates/samba/smb.conf.template @@ -121,5 +121,4 @@ #============================ Share Definitions ============================== -include = /home/mythtv/templates/user.shares diff --git a/abs/extra-testing/community/vsftpd/PKGBUILD b/abs/extra-testing/community/vsftpd/PKGBUILD new file mode 100644 index 0000000..32a4007 --- /dev/null +++ b/abs/extra-testing/community/vsftpd/PKGBUILD @@ -0,0 +1,52 @@ +# $Id: PKGBUILD 29700 2009-03-11 22:18:56Z hugo $ +# Maintainer: Andreas Radke <andyrtr@archlinux.org> +# Contributor: judd <jvinet@zeroflux.org> + +pkgname=vsftpd +pkgver=2.1.0 +pkgrel=4 +pkgdesc="Very Secure FTP daemon" +arch=('i686' 'x86_64') +license=('GPL') +backup=(etc/vsftpd.conf etc/xinetd.d/vsftpd) +url="http://vsftpd.beasts.org/" +#makedepends=('vim') +depends=('glibc' 'pam' 'tcp_wrappers>=7.6-8' 'openssl>=0.9.8j-1' 'libcap>=2.16') +install=vsftpd.install +source=(ftp://vsftpd.beasts.org/users/cevans/vsftpd-$pkgver.tar.gz \ + vsftpd.xinetd vsftpd.d run) +md5sums=('7890b54e7ffa6106ffbdfda53f47fa41' + 'b07fd4609c70063c1d6b20142910c1a6' + 'e46ed8e4c4a6e6a3de59f60b98e4f569' + '8abbed7cc75f9a9d2944e0e83c8dd90d') + +build() { + cd ${srcdir}/${pkgname}-${pkgver} + # build-time config + sed \ + -e 's|^#undef VSF_BUILD_TCPWRAPPERS$|#define VSF_BUILD_TCPWRAPPERS|' \ + -e 's|^#undef VSF_BUILD_SSL$|#define VSF_BUILD_SSL|' \ + -i builddefs.h + make CFLAGS="${CFLAGS}" || return 1 + install -D -m755 vsftpd ${pkgdir}/usr/sbin/vsftpd || return 1 + install -D -m644 vsftpd.conf ${pkgdir}/etc/vsftpd.conf || return 1 + install -D -m644 vsftpd.8 ${pkgdir}/usr/share/man/man8/vsftpd.8 || return 1 + install -D -m644 vsftpd.conf.5 ${pkgdir}/usr/share/man/man5/vsftpd.conf.5 || return 1 + install -D -m644 ../vsftpd.xinetd ${pkgdir}/etc/xinetd.d/vsftpd || return 1 + install -D -m755 ../vsftpd.d ${pkgdir}/etc/rc.d/vsftpd || return 1 + mkdir -p $startdir/pkg/usr/share/empty +# ex ${pkgdir}/etc/vsftpd.conf <<_EOF +#2 +#i +## +## Use this to use vsftpd in standalone mode, otherwise it runs through (x)inetd +##listen=YES +#. +#w +#q +#_EOF +#} +# Below added for LinHES + mkdir -p $startdir/pkg/etc/sv/vsftpd/supervise + install -D -m755 $startdir/src/run $startdir/pkg/etc/sv/vsftpd/ +} diff --git a/abs/extra-testing/community/vsftpd/run b/abs/extra-testing/community/vsftpd/run new file mode 100644 index 0000000..1fd5202 --- /dev/null +++ b/abs/extra-testing/community/vsftpd/run @@ -0,0 +1,13 @@ +#!/bin/sh +exec 2>&1 +. /etc/profile +. /etc/systemconfig +export TERM=linux +. /etc/rc.conf +. /etc/rc.d/functions + +stat_runit "Starting VSFTPD" +export HOME=/root + +# Start vsftpd +/usr/sbin/vsftpd /etc/vsftpd.conf diff --git a/abs/extra-testing/community/vsftpd/vsftpd.d b/abs/extra-testing/community/vsftpd/vsftpd.d new file mode 100644 index 0000000..b43a6d0 --- /dev/null +++ b/abs/extra-testing/community/vsftpd/vsftpd.d @@ -0,0 +1,40 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +PID=`pidof -o %PPID /usr/sbin/vsftpd` +case "$1" in + start) + stat_busy "Starting vsftpd FTP Daemon" + if [ -z "$PID" ]; then + /usr/sbin/vsftpd & + PID=`pidof -o %PPID /usr/sbin/vsftpd` + if [ -z $PID ]; then + stat_fail + else + add_daemon vsftpd + stat_done + fi + else + stat_fail + fi + ;; + stop) + stat_busy "Stopping vsftpd FTP Daemon" + [ ! -z "$PID" ] && kill $PID &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon vsftpd + stat_done + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac diff --git a/abs/extra-testing/community/vsftpd/vsftpd.install b/abs/extra-testing/community/vsftpd/vsftpd.install new file mode 100644 index 0000000..3bbb2cc --- /dev/null +++ b/abs/extra-testing/community/vsftpd/vsftpd.install @@ -0,0 +1,22 @@ +# arg 1: the new package version +post_install() { + if [ -f lib/modules/`uname -r`/kernel/security/capability.ko ]; then + echo ">>> It appears that your current kernel has linux security" + echo ">>> capabilities built as a module. vsftpd requires this" + echo ">>> functionality to operate." + echo ">>>" + echo ">>> To activate the module, please load it now (modprobe capability)." + echo ">>> Also, you should add it to your MODULES array in rc.conf, so" + echo ">>> it will be activated automatically at boot-up." + fi +# Below added for LinHES + add_service.sh vsftpd +} + +post_upgrade() { + post_install $1 +} + +post_remove() { + remove_service.sh vsftpd +} diff --git a/abs/extra-testing/community/vsftpd/vsftpd.xinetd b/abs/extra-testing/community/vsftpd/vsftpd.xinetd new file mode 100644 index 0000000..eff2eb3 --- /dev/null +++ b/abs/extra-testing/community/vsftpd/vsftpd.xinetd @@ -0,0 +1,10 @@ +service ftp +{ + socket_type = stream + wait = no + user = root + server = /usr/sbin/vsftpd + log_on_success += HOST DURATION + log_on_failure += HOST + disable = yes +} diff --git a/abs/extra-testing/fuppes-svn/PKGBUILD b/abs/extra-testing/fuppes-svn/PKGBUILD index fd794b6..3c14ddd 100644 --- a/abs/extra-testing/fuppes-svn/PKGBUILD +++ b/abs/extra-testing/fuppes-svn/PKGBUILD @@ -3,15 +3,18 @@ pkgname=fuppes-svn pkgver=636 -pkgrel=2 +pkgrel=5 pkgdesc="A free, multiplatform Universal Plug and Play A/V MediaServer" arch=('i686' 'x86_64') url="http://fuppes.ulrich-voelkel.de/" license=('GPL2') depends=('pcre' 'libxml2' 'sqlite3' 'gettext' 'taglib' 'imagemagick' 'ffmpeg' 'libmp4v2' 'lame' 'libvorbis' 'libmpcdec' 'flac' 'faad2' 'libmad') makdepends=('pkgconfig' 'autoconf' 'subversion') -source=(fuppes-r634-archlinux.patch fuppes.diff) -md5sums=('5d9f6331cc91b64aab69449ce327b214' 'c495fa1bd9a870ae36820632434319ee') +install=fuppes.install +source=(fuppes-r634-archlinux.patch fuppes.diff fuppes.cfg run fuppes.ch) +md5sums=('5d9f6331cc91b64aab69449ce327b214' 'c495fa1bd9a870ae36820632434319ee' \ + 'b0cef07d8e60d01c8146a69870672e1f' 'd8615e017b9929498076c312f134b2ed' \ + '3c355b860f1b0d273f5aa8b2bea1bde6') _svnmod="fuppes" _svntrunk="https://fuppes.svn.sourceforge.net/svnroot/fuppes/trunk" @@ -36,5 +39,11 @@ build() make || return 1 make DESTDIR=$startdir/pkg install || return 1 + mkdir -p $startdir/pkg/etc/sv/fuppes/supervise + install -D -m755 $startdir/src/run $startdir/pkg/etc/sv/fuppes/ + mkdir -p $startdir/pkg/etc/fuppes + cp $startdir/src/fuppes.cfg $startdir/pkg/etc/fuppes + mkdir -p $startdir/pkg/etc/cron.hourly + install -D -m755 $startdir/src/fuppes.ch $startdir/pkg/etc/cron.hourly } diff --git a/abs/extra-testing/fuppes-svn/fuppes.cfg b/abs/extra-testing/fuppes-svn/fuppes.cfg new file mode 100644 index 0000000..beb81cf --- /dev/null +++ b/abs/extra-testing/fuppes-svn/fuppes.cfg @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fuppes_config version="0.7.2.3"> + <shared_objects> + <!--<dir>/mnt/music</dir>--> + <!--<itunes>/Users/.../iTunes.xml</itunes>--> + <dir>/myth/tv</dir> + <dir>/myth/video</dir> + <dir>/myth/music</dir> + <dir>/myth/gallery</dir> + <dir>/myth/pretty</dir> + </shared_objects> + <network> + <!--empty = automatic detection--> + <interface>192.168.1.253</interface> + <!--empty or 0 = random port--> + <http_port>81</http_port> + <!--list of ip addresses allowed to access fuppes. if empty all ips are allowed--> + <allowed_ips> + <!--<ip>192.168.0.1</ip>--> + </allowed_ips> + </network> + <content_directory> + <!--a list of possible charsets can be found under: + http://www.gnu.org/software/libiconv/--> + <local_charset>UTF-8</local_charset> + <!--libs used for metadata extraction when building the database. [true|false]--> + <use_imagemagick>true</use_imagemagick> + <use_taglib>true</use_taglib> + <use_libavformat>true</use_libavformat> + </content_directory> + <global_settings> + <temp_dir/> + <!--uuid is written to and read from <config-dir>/uuid.txt if set to true--> + <use_fixed_uuid>false</use_fixed_uuid> + </global_settings> + <device_settings> + <!--"default" settings are inhertied by specific devices and can be overwritten--> + <!--do NOT remove the "default" device settings--> + <!--all new file types have to be added to the default settings--> + <!--adding new file types just to a specific device will have no affect--> + <device name="default"> + <!--specify the maximum length for file names (0 or empty = unlimited)--> + <max_file_name_length>0</max_file_name_length> + <!--[file|container]--> + <playlist_style>file</playlist_style> + <show_childcount_in_title>false</show_childcount_in_title> + <enable_dlna>false</enable_dlna> + <transcoding_release_delay>4</transcoding_release_delay> + <file_settings> + <!--audio files--> + <file ext="mp3"> + <type>AUDIO_ITEM</type> + <mime_type>audio/mpeg</mime_type> + <dlna>MP3</dlna> + </file> + <file ext="ogg"> + <type>AUDIO_ITEM</type> + <mime_type>application/octet-stream</mime_type> + <transcode enabled="true"> + <ext>mp3</ext> + <mime_type>audio/mpeg</mime_type> + <dlna>MP3</dlna> + <http_encoding>chunked</http_encoding> + <decoder>vorbis</decoder> + <encoder>lame</encoder> + <bitrate>192</bitrate> + <samplerate>44100</samplerate> + </transcode> + </file> + <file ext="mpc"> + <type>AUDIO_ITEM</type> + <mime_type>application/octet-stream</mime_type> + <transcode enabled="true"> + <ext>mp3</ext> + <mime_type>audio/mpeg</mime_type> + <dlna>MP3</dlna> + <http_encoding>chunked</http_encoding> + <decoder>musepack</decoder> + <encoder>lame</encoder> + <bitrate>192</bitrate> + <samplerate>44100</samplerate> + </transcode> + </file> + <file ext="wav"> + <type>AUDIO_ITEM</type> + <mime_type>audio/x-wav</mime_type> + </file> + <file ext="flac"> + <type>AUDIO_ITEM</type> + <mime_type>audio/x-flac</mime_type> + <transcode enabled="true"> + <ext>mp3</ext> + <mime_type>audio/mpeg</mime_type> + <dlna>MP3</dlna> + <http_encoding>chunked</http_encoding> + <decoder>flac</decoder> + <encoder>lame</encoder> + <bitrate>192</bitrate> + <samplerate>44100</samplerate> + </transcode> + </file> + <file ext="wma"> + <type>AUDIO_ITEM</type> + <mime_type>audio/x-ms-wma</mime_type> + <dlna>WMAFULL</dlna> + </file> + <!--image files--> + <file ext="jpg"> + <ext>jpeg</ext> + <type>IMAGE_ITEM</type> + <mime_type>image/jpeg</mime_type> + <convert enabled="false"> + <!--<dcraw enabled="true">-q 0</dcraw>--> + <ext>png</ext> + <mime_type>image/png</mime_type> + <height>0</height> + <width>0</width> + <!--set "greater" to "true" if you only want to resize images greater than "height" or "width"--> + <greater>false</greater> + <!--set "less" to "true" if you only want to resize images less than "height" or "width"--> + <less>false</less> + <!--set "less" and "greater" to "false" if you always want to resize--> + </convert> + </file> + <file ext="bmp"> + <type>IMAGE_ITEM</type> + <mime_type>image/bmp</mime_type> + </file> + <file ext="png"> + <type>IMAGE_ITEM</type> + <mime_type>image/png</mime_type> + </file> + <file ext="gif"> + <type>IMAGE_ITEM</type> + <mime_type>image/gif</mime_type> + </file> + <!--video files--> + <file ext="mpg"> + <ext>mpeg</ext> + <type>VIDEO_ITEM</type> + <mime_type>video/mpeg</mime_type> + </file> + <file ext="mp4"> + <type>VIDEO_ITEM</type> + <mime_type>video/mp4</mime_type> + </file> + <file ext="avi"> + <type>VIDEO_ITEM</type> + <mime_type>video/x-msvideo</mime_type> + </file> + <file ext="wmv"> + <type>VIDEO_ITEM</type> + <mime_type>video/x-ms-wmv</mime_type> + </file> + <file ext="vob"> + <type>VIDEO_ITEM</type> + <mime_type>video/x-ms-vob</mime_type> + </file> + <file ext="vdr"> + <type>VIDEO_ITEM</type> + <mime_type>video/x-extension-vdr</mime_type> + <transcode enabled="true"> + <ext>vob</ext> + <mime_type>video/x-ms-vob</mime_type> + </transcode> + </file> + <file ext="flv"> + <type>VIDEO_ITEM</type> + <mime_type>application/x-flash-video</mime_type> + </file> + <file ext="asf"> + <type>VIDEO_ITEM</type> + <mime_type>video/x-ms-asf</mime_type> + </file> + <!--playlists--> + <file ext="pls"> + <type>PLAYLIST</type> + <mime_type>audio/x-scpls</mime_type> + </file> + <file ext="m3u"> + <type>PLAYLIST</type> + <mime_type>audio/x-mpegurl</mime_type> + </file> + </file_settings> + </device> + <!--For other device settings take a look at http://fuppes.ulrich-voelkel.de/wiki/index.php/Category:Device--> + <!--If you have more than one device it is a good idea to set the ip address as some devices may have conflicting "user agents".--> + <!--It is safe to remove unneeded devices--> + <device name="PS3" enabled="false"> + <user_agent>UPnP/1.0 DLNADOC/1.00</user_agent> + <user_agent>PLAYSTATION3</user_agent> + <!--<ip></ip>--> + <enable_dlna>true</enable_dlna> + <transcoding_release_delay>50</transcoding_release_delay> + <file_settings> + <file ext="ogg"> + <type>AUDIO_ITEM_MUSIC_TRACK</type> + <transcode enabled="true"> + <http_encoding>stream</http_encoding> + </transcode> + </file> + </file_settings> + </device> + <device name="Xbox 360" virtual="Xbox 360" enabled="false"> + <user_agent>Xbox/2.0.\d+.\d+ UPnP/1.0 Xbox/2.0.\d+.\d+</user_agent> + <user_agent>Xenon</user_agent> + <xbox360>true</xbox360> + <show_empty_resolution>true</show_empty_resolution> + <description_values> + <friendly_name>%s %v : 1 : Windows Media Connect</friendly_name> + <model_name>Windows Media Connect compatible (%s)</model_name> + <model_number>2.0</model_number> + </description_values> + </device> + </device_settings> +</fuppes_config> diff --git a/abs/extra-testing/fuppes-svn/fuppes.ch b/abs/extra-testing/fuppes-svn/fuppes.ch new file mode 100644 index 0000000..60960b5 --- /dev/null +++ b/abs/extra-testing/fuppes-svn/fuppes.ch @@ -0,0 +1,2 @@ +#!/bin/bash +/usr/bin/wget -O /dev/null -q http://localhost:81/presentation/options.html?db=update &> /dev/null diff --git a/abs/extra-testing/fuppes-svn/fuppes.install b/abs/extra-testing/fuppes-svn/fuppes.install new file mode 100644 index 0000000..a35aebe --- /dev/null +++ b/abs/extra-testing/fuppes-svn/fuppes.install @@ -0,0 +1,18 @@ +# arg 1: the new package version +post_install() { + sv stop mythbackend + mv /etc/sv/mythbackend/run /tmp + sed 's/logfile/noupnp\ --logfile/' </tmp/run >/etc/sv/mythbackend/run + sv start mythbackend + add_service.sh fuppes + sv start fuppes +} + +post_remove() { + sv stop fuppes + remove_service.sh fuppes + mv /etc/sv/mythbackend/run /tmp/run + sv stop mythbackend + sed 's/--noupnp\ --logfile/--logfile/' </tmp/run >/etc/sv/mythbackend/run + sv start mythbackend +} diff --git a/abs/extra-testing/fuppes-svn/run b/abs/extra-testing/fuppes-svn/run new file mode 100755 index 0000000..670a3dd --- /dev/null +++ b/abs/extra-testing/fuppes-svn/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec /usr/bin/fuppes --config-dir /etc/fuppes --database-file /data/srv/fuppes/fuppes.db --temp-dir /myth/tmp diff --git a/abs/extra-testing/perl-algorithm-diff/PKGBUILD b/abs/extra-testing/perl-algorithm-diff/PKGBUILD deleted file mode 100644 index 43d53c1..0000000 --- a/abs/extra-testing/perl-algorithm-diff/PKGBUILD +++ /dev/null @@ -1,23 +0,0 @@ -# This PKGBUILD was generated by cpan4pacman via CPANPLUS::Dist::Pacman -# Contributor: François Charette <firmicus ατ gmx δοτ net> - -pkgname=perl-algorithm-diff -pkgver=1.1902 -pkgrel=1 -pkgdesc="Compute intelligent differences between two files / lists" -arch=('i686' 'x86_64') -url="http://search.cpan.org/~TJMATHER/XML-RegExp" -license=('GPL' 'PerlArtistic') -depends=('perl>=5.10.0') -options=('!emptydirs') -source=(http://search.cpan.org/CPAN/authors/id/T/TY/TYEMQ/Algorithm-Diff-$pkgver.tar.gz) -md5sums=('ff3e17ae485f8adfb8857b183991fbce') - -build() { - cd $startdir/src/Algorithm-Diff-$pkgver - PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1 - make || return 1 - make install DESTDIR=$startdir/pkg || return 1 - find $startdir/pkg -name '.packlist' -delete - find $startdir/pkg -name '*.pod' -delete -} |