diff options
Diffstat (limited to 'abs/core/LinHES-config-svn')
29 files changed, 5699 insertions, 0 deletions
diff --git a/abs/core/LinHES-config-svn/LinHES-release b/abs/core/LinHES-config-svn/LinHES-release new file mode 100644 index 0000000..ecc4a3e --- /dev/null +++ b/abs/core/LinHES-config-svn/LinHES-release @@ -0,0 +1 @@ +LinHES R6.00.07 (Scale preview) diff --git a/abs/core/LinHES-config-svn/LinHES.install b/abs/core/LinHES-config-svn/LinHES.install new file mode 100644 index 0000000..a0a9d31 --- /dev/null +++ b/abs/core/LinHES-config-svn/LinHES.install @@ -0,0 +1,78 @@ +# This is a default template for a post-install scriptlet. You can +# remove any functions you don't need (and this header). + +# arg 1: the new package version +pre_install() { + rm -f /etc/issue + rm -f /etc/arch-release + +} + +# arg 1: the new package version +post_install() { + if [ ! -f /etc/blacklist.package ] + then + echo "List of packages to ignore" > /etc/blacklist.package + echo "one package per line" >> /etc/blacklist.package + fi + +LINE="mythtv ALL = NOPASSWD:/usr/MythVantage/bin/mythvantage" +LINE1="mythtv ALL = NOPASSWD:/usr/MythVantage/bin/MythVantage" +for i in "$LINE" "$LINE1" +do + cp /etc/sudoers /etc/sudoers.bak + grep -q "$i" /etc/sudoers + if [ $? != 0 ] + then + echo "$i" >> /etc/sudoers + visudo -cf /etc/sudoers + if [ ! $? = 0 ] + then + cp /etc/sudoers.bak /etc/sudoers + echo $i + echo "Error adding files" + exit 1 + fi + fi +done + + +} + +# arg 1: the new package version +# arg 2: the old package version +pre_upgrade() { + /bin/true +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + . /etc/profile + ps -ef|grep mysqld|grep -v grep + status=$? + echo "status $status" + if [ $status = 0 ] + then + restore_default_settings.sh -c load + fi + if [ ! -f /etc/blacklist.package ] + then + echo "List of packages to ignore" > /etc/blacklist.package + echo "one package per line" >> /etc/blacklist.package + fi +} + +# arg 1: the old package version +pre_remove() { + /bin/true +} + +# arg 1: the old package version +post_remove() { + /bin/true +} + +op=$1 +shift +$op $* diff --git a/abs/core/LinHES-config-svn/MythVantage.sh b/abs/core/LinHES-config-svn/MythVantage.sh new file mode 100755 index 0000000..286c908 --- /dev/null +++ b/abs/core/LinHES-config-svn/MythVantage.sh @@ -0,0 +1,3 @@ +export MV_ROOT=/usr/MythVantage +export PATH=$PATH:$MV_ROOT/bin +export TEMPLATES=$MV_ROOT/templates diff --git a/abs/core/LinHES-config-svn/PKGBUILD b/abs/core/LinHES-config-svn/PKGBUILD new file mode 100755 index 0000000..32645a2 --- /dev/null +++ b/abs/core/LinHES-config-svn/PKGBUILD @@ -0,0 +1,57 @@ +pkgname=LinHES-config-svn +pkgver=1.0 +pkgrel=299 +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 ) +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) + +install=LinHES.install +build() { + mkdir -p $startdir/pkg/etc + mkdir -p $startdir/pkg/usr/share/mythtv/themes/default + + MVDIR=$startdir/pkg/usr/MythVantage + 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/etc + +#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 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 + install -m 0755 soundconfig.sh $MVDIR/bin/soundconfig.sh + install -m 0755 networkconfig.sh $MVDIR/bin/networkconfig.sh + install -m 0755 create_master.sh $MVDIR/bin/create_master.sh + install -m 0755 build_diskless.sh $MVDIR/bin/build_diskless.sh + 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 + #Readme used for mythvantage -r + 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 + install -m 0755 LinHES-release $startdir/pkg/etc/LinHES-release + install -m 0755 issue $startdir/pkg/etc/issue + +# copy over the ui files + install -m 0755 install-ui.xml $startdir/pkg/usr/share/mythtv/themes/default/ + +#copy in the binaries + install -m 4755 mythinstall.bin $MVDIR/bin/MythVantage + cd $MVDIR/bin + ln -s MythVantage mythvantage + ln -s MythVantage mythinstall + cd - +} + diff --git a/abs/core/LinHES-config-svn/README b/abs/core/LinHES-config-svn/README new file mode 100644 index 0000000..a615389 --- /dev/null +++ b/abs/core/LinHES-config-svn/README @@ -0,0 +1,10 @@ +Thanks for giving this Preview Release of LinHES a try! +While the core of LinHes is quite stable, we still need to +implement some features. At the moment, LinHES is compiled for i686. If you have an i586 class system, LinHES won't work for you. We do intend for LinHES to be full i586 compatible. In addition, we still have to implement support for more remotes and blasters. The TV out of the PVR-350 isn't supported at this time. + +Support for LinHES can be obtained at: +http://linhes.org +irc.freenode.net #linhes + +Bugs can be reported at: +http://linhes.org/flyspray diff --git a/abs/core/LinHES-config-svn/add_service.sh b/abs/core/LinHES-config-svn/add_service.sh new file mode 100755 index 0000000..190d604 --- /dev/null +++ b/abs/core/LinHES-config-svn/add_service.sh @@ -0,0 +1,15 @@ +#!/bin/bash +SERVICE_DIR=/var/service +SCRIPT_DIR=/etc/sv +if [ -d $SCRIPT_DIR/$1 ] +then + if [ -d $SERVICE_DIR/$1 ] + then + echo "$1 already there" + else + ln -s $SCRIPT_DIR/$1 $SERVICE_DIR/$1 + echo "adding $1" + fi +else + echo "couldn't find $SCRIPT_DIR/$1" +fi diff --git a/abs/core/LinHES-config-svn/autocard.py b/abs/core/LinHES-config-svn/autocard.py new file mode 100755 index 0000000..03eecac --- /dev/null +++ b/abs/core/LinHES-config-svn/autocard.py @@ -0,0 +1,307 @@ +#!/usr/bin/python +# import MySQL module +#jm +import MySQLdb +import sys +import getopt +import socket +import os +import time +import string +import glob +from string import letters +from string import digits +def INSERTNULL_SOURCE(name,xmltvgrabber,userid,freqtable,lineupid,password,useeit): + cursor = db.cursor() + cursor.execute("INSERT INTO videosource(name,xmltvgrabber,userid,freqtable,lineupid,password,useeit) VALUES(%s,%s,%s,%s,%s,%s,%s);",(name,xmltvgrabber,userid,freqtable,lineupid,password,useeit)) + +def INSERTCARD_INTOMYTH(Device,Driver,Cardvendor): + global currenthostname + print Device + print Driver, + print Cardvendor + cursor = db.cursor() + insert = "false" + if Driver == "ivtv" : + cardtype="MPEG" + defaultinput="Tuner 1" + insert="true" + if Cardvendor == "pcHDTV HD3000 HDTV": + insert="false" + cardtype ="whocares" + + #print insert + if insert == "true" : + cursor.execute("INSERT INTO capturecard (videodevice,cardtype,defaultinput,hostname) VALUES(%s,%s,%s,%s);",(Device,cardtype,defaultinput,currenthostname)) + +def INSERTHDR_INTOMYTH(deviceid,tuner_number): + cardtype='HDHOMERUN' + defaultinput='MPEG2TS' + global currenthostname + print deviceid + print cardtype + print defaultinput + print tuner_number + cursor = db.cursor() + #print insert + cursor.execute("INSERT INTO capturecard (videodevice,cardtype,defaultinput,dbox2_port ,hostname) VALUES(%s,%s,%s,%s,%s);",(deviceid,cardtype,defaultinput,tuner_number,currenthostname)) + +def INSERTAUTOCARD(): + global cardlist + global currenthostname + # create a cursor + cursor = db.cursor() + + + for i in range( 1 , len(cardlist)): + insert = "false" +# print cardlist[i] + Device=cardlist[i][0] + Driver=cardlist[i][1] + Cardvendor=cardlist[i][2] + Businfo=cardlist[i][3] + if Driver == "ivtv" : + insert="true" + devicestatus="unused" + if Cardvendor == "pcHDTV HD3000 HDTV": + insert="false" + cardtype ="whocares" + if Driver == "hdr": + insert="true" + devicestatus="unused" + + if insert == "true" : + cursor.execute("delete from autocard where uniqid=%s;",(Businfo)) + if Driver=="hdr": + Cardvendor="HDHOMERUN Tuner 1" + cursor.execute("INSERT INTO autocard (dev,driver,description,uniqid,devicestatus,hostname) VALUES(%s,%s,%s,%s,%s,%s);",(Device,Driver,Cardvendor,Businfo,devicestatus,currenthostname)) + Cardvendor="HDHOMERUN Tuner 2" + cursor.execute("INSERT INTO autocard (dev,driver,description,uniqid,devicestatus,hostname) VALUES(%s,%s,%s,%s,%s,%s);",(Device,Driver,Cardvendor,Businfo,devicestatus,currenthostname)) + + else: + cursor.execute("INSERT INTO autocard (dev,driver,description,uniqid,devicestatus,hostname) VALUES(%s,%s,%s,%s,%s,%s);",(Device,Driver,Cardvendor,Businfo,devicestatus,currenthostname)) + + + +def PRINTINFO(): + global cardlist + + for list in cardlist: + if list != "_placeholder_": + print list + #print "-------------" + +def GATHER_HDR(): + global cardlist + command="/usr/bin/hdhomerun_config --discover" + results=os.popen(command,'r') + line=results.readline() + if line.strip().split()[0] == "no": + print "HDHOMERUN not detected" + else: + print line + hdrdevice=line.strip().split()[2] + print hdrdevice + Driver="hdr" + Device=hdrdevice + Cardtype="HDHOMERUN" + Businfo=hdrdevice + cardprops = [Device,Driver , Cardtype , Businfo] + cardlist.append(cardprops) + + +def GATHER_v4l_CARDS(): + global cardlist + cardlist=["_placeholder_"] + # print "Looking for v4l cards" + try: + filelist = os.listdir('/dev/v4l/') + except OSError: + filelist=" " + #fakelist=['/dev/v4l/video3', 'ivtv', 'WinTV PVR 500 (unit #2)', '0000:04:09.0'] + #cardlist.append(fakelist) + try: + filelist = glob.glob("/dev/v4l/video?") + Driver="" + Cardtype="" + Businfo="" + numcards = 0 + for Device in filelist: + #print card + numcards = numcards+1 + cmd = 'v4l2-ctl -D -d' + Device + for line in os.popen(cmd).readlines(): + #print line + pos = string.find(line,"Driver name") + if pos >=0: + splitline= line.split(':') + Driver=splitline[1].strip() + pos = string.find(line,"Card type") + if pos >=0: + splitline= line.split(':') + Cardtype=splitline[1].strip() + + pos = string.find(line,"Bus info") + if pos >=0: + splitline= line.split(':',1) + Businfo=splitline[1].strip() + + #print Device,Driver , Cardtype , Businfo,numcards + cardprops = [Device,Driver , Cardtype , Businfo] + cardlist.append(cardprops) + except IOError: + print "no v4l cards found" + sys.exit(2) + + +def WRITEUDEV_IVTV(): + global insertmyth + cursor = db.cursor() + #add ivtv,cid lookup loop through until empty. + cursor.execute("select distinct(uniqid) from autocard where driver='ivtv' and devicestatus='will-add'") + cidrows = cursor.fetchall() + for row in cidrows: + cid=row[0] + cursor.execute("select dev,driver,description,devicestatus,hostname from autocard where uniqid=%s limit 1;",(cid)) + result = cursor.fetchone() + description=result[2] + driver='DRIVERS==\"ivtv\"' + ATTRNAME='ATTR{name}=="ivtv? encoder MPG"' + KERNELS='KERNELS==\"' + KERNELS+=cid + KERNELS+="\"" + #filter out non digit or chars + keep=letters.join(digits) + description=filter(lambda c: c in keep, description) + devnode="ivtv/" + #devnode+=description + "_" + udevcid=cid.partition(":") + devnode+=udevcid[2] + devnode+="_video" + UDEV_RULE=driver +', '+ATTRNAME+', '+ KERNELS +', ' + 'NAME=\"' + devnode + '"' + print "Here is the udev rule" + print UDEV_RULE + filename='/etc/udev/rules.d/11-ivtv-'+cid+'.rules' + file = open(filename,'w') + file.write(UDEV_RULE) + if ( insertmyth == "true"): + devnode="/dev/"+devnode + INSERTCARD_INTOMYTH(devnode,"ivtv",description) + cursor.execute("update autocard set devicestatus='done' where uniqid=%s;",(cid)) +#now insert HDR + cursor.execute("select distinct(uniqid),description from autocard where driver='hdr' and devicestatus='will-add'") + cidrows = cursor.fetchall() + for row in cidrows: + if ( insertmyth == "true"): + deviceid=row[0] + #cardtype="HDHOMRUN" + #defaultinput="MPEG2TS" + dbox2_port=row[1] + tuner_number=dbox2_port.rpartition(' ')[2] + INSERTHDR_INTOMYTH(deviceid,tuner_number) + cursor.execute("update autocard set devicestatus='done' where uniqid=%s and description=%s;",(deviceid,dbox2_port)) + + + +def CLEARAUTOCARD(): + cursor = db.cursor() + cursor.execute("delete from autocard") + +def RELOADUDEV(): + print "relaoding udev rules" + os.system('udevcontrol reload_rules') + os.system('rmmod ivtv') + os.system('udevtrigger') + + +def usage(): + print " -h help" + print " -g gather and print out the found cards" + print " -w write out the udev rules" + print " -i insert cards into myth that are marked will-add(only used with -w)" + print " -r reload udev rules" + print " -c clear the autocard db" + +def main(argv): + global db + global cardlist + global currenthostname + currenthostname="" + writeudev="false" + global insertmyth + insertmyth ="false" + + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + try: + cursor = db.cursor() + cursor.execute("describe autocard;") + except MySQLdb.Error, e: + cursor.execute("create table autocard(dev varchar(50),driver varchar(50),description varchar(50),uniqid varchar(50), devicestatus varchar(50),hostname varchar(50));") + print "table created" + + if ( currenthostname == "" ): + currenthostname = socket.gethostname() + + + try: + opts, args = getopt.getopt(argv, "hgwircd", ["help", "gathercards", "writeudev" ,"insert" , "reloadudev" , "clearautocard"] ) + except getopt.GetoptError: + sys.exit(2) + for opt, arg in opts: + if opt in ("-h", "--help"): + usage() + sys.exit() + elif opt in ( "-g" , "--gathercards"): + GATHER_v4l_CARDS() + GATHER_HDR() + INSERTAUTOCARD() + PRINTINFO() + elif opt in ("-w", "--writeudev"): + writeudev="true" + elif opt in ("-i", "--insert"): + insertmyth="true" + elif opt in ( "-r" , "--reloadudev"): + RELOADUDEV() + elif opt in ( "-c" , "--clearautocard"): + CLEARAUTOCARD() + elif opt in ( "-d" ): + INSERTCARD_INTOMYTH("file:/myth/video/TripThe1939.mpeg","ivtv","Dummy tuner") + INSERTNULL_SOURCE("dummy","/bin/true","","default","NULL","NULL","0") + + if ( writeudev == "true"): + WRITEUDEV_IVTV() + + + + + + +if __name__ == "__main__": + main(sys.argv[1:]) + + + + + +#mysql> create table autocard(dev varchar(50),driver varchar(50),description varchar(50),uniqid varchar(50), devicestatus varchar(50),hostname varchar(50)); +#Query OK, 0 rows affected (0.14 sec) + +#mysql> describe autocard; +#+--------------+-------------+------+-----+---------+-------+ +#| Field | Type | Null | Key | Default | Extra | +#+--------------+-------------+------+-----+---------+-------+ +#| dev | varchar(50) | YES | | NULL | | +#| driver | varchar(50) | YES | | NULL | | +#| description | varchar(50) | YES | | NULL | | +#| uniqid | varchar(50) | YES | | NULL | | +#| devicestatus | varchar(50) | YES | | NULL | | +#| hostname | varchar(50) | YES | | NULL | | +#+--------------+-------------+------+-----+---------+-------+ + + + + + + + + diff --git a/abs/core/LinHES-config-svn/bpopup-ui.xml b/abs/core/LinHES-config-svn/bpopup-ui.xml new file mode 100755 index 0000000..df0598b --- /dev/null +++ b/abs/core/LinHES-config-svn/bpopup-ui.xml @@ -0,0 +1,164 @@ +<!-- + + This is a myth style theme file for mythwelcome + + (c) 2005 by a whole bunch of people associated with MythTV + +--> +<mythuitheme> + + <window name="welcome_screen"> + + <!-- + + First, define all the fonts we need on this screen + + --> + <font name="title" face="Arial"> + <color>#ffff00</color> + <dropcolor>#000000</dropcolor> + <size>24</size> + <shadow>3,3</shadow> + <bold>yes</bold> + </font> + + <font name="time" face="Arial"> + <color>#9999cc</color> + <size>18</size> + <bold>yes</bold> + </font> + + <font name="label" face="Arial"> + <color>#ffff00</color> + <dropcolor>#000000</dropcolor> + <size>18</size> + <shadow>3,3</shadow> + <bold>yes</bold> + </font> + + <font name="info" face="Arial"> + <color>#ffffff</color> + <size>18</size> + <bold>yes</bold> + </font> + + <font name="biginfo" face="Arial"> + <color>#ffffff</color> + <size>50</size> + <bold>yes</bold> + </font> + <font name="warning" face="Arial"> + <color>#ff0000</color> + <dropcolor>#000000</dropcolor> + <size>16</size> + <shadow>2,2</shadow> + <bold>yes</bold> + </font> + + <font name="buttons" face="Arial"> + <color>#ffff00</color> + <size>14</size> + <bold>yes</bold> + </font> + + <container name="main_display"> + <area>0,0,800,600</area> + + <textarea name="title" draworder="0" align="center"> + <multiline>no</multiline> + <font>title</font> + <area>50,40,700,40</area> + <value></value> + </textarea> + + <!-- + time + --> + <textarea name="time_text" draworder="0" align="right"> + <multiline>no</multiline> + <font>time</font> + <area>660,520,110,30</area> + <value></value> + </textarea> + + <textarea name="date_text" draworder="0" align="center"> + <multiline>no</multiline> + <font>time</font> + <area>0,60,800,70</area> + <value></value> + </textarea> + + <!-- + current myth status + --> + + <textarea name="status_text" draworder="1" align="center"> + <multiline>yes</multiline> + <font>info</font> + <area>20,70,760,60</area> + <value>MythTV is idle and will shutdown shortly.</value> + </textarea> + + <!-- + current recordings status + --> + + <textarea name="recording_label" draworder="1" align="center"> + <font>label</font> + <area>20,110,760,30</area> + <!--<value>Percent Complete </value>--> + <value></value> + </textarea> + + <textarea name="recording_text" draworder="1" align="hcenter"> + <multiline>yes</multiline> + <font>biginfo</font> + <area>20,110,760,150</area> + <value></value> + </textarea> + + <!-- + next scheduled recording status + --> + + <textarea name="scheduled_label" draworder="1" align="center"> + <font>label</font> + <area>20,320,760,30</area> + <value></value> + </textarea> + + <textarea name="scheduled_text" draworder="1" align="hcenter"> + <multiline>yes</multiline> + <font>biginfo</font> + <area>20,400,760,120</area> + <value></value> + </textarea> + + <!-- + scheduled recordings conflict warning + --> + + <textarea name="conflicts_text" draworder="1" align="center"> + <font>warning</font> + <area>20,490,760,30</area> + <value>WARNING: There are conflicting scheduled recordings!</value> + </textarea> + + <!-- + start frontend button + + <textbutton name="startfrontend_button" draworder="1"> + <position>81,535</position> + <font>buttons</font> + <image function="on" filename="mw_text_button_on.png"></image> + <image function="off" filename="mw_text_button_off.png"></image> + <image function="pushed" filename="mw_text_button_pushed.png"></image> + </textbutton> + + --> + + </container> + + </window> + +</mythuitheme> diff --git a/abs/core/LinHES-config-svn/build_diskless.sh b/abs/core/LinHES-config-svn/build_diskless.sh new file mode 100755 index 0000000..4dfd5fc --- /dev/null +++ b/abs/core/LinHES-config-svn/build_diskless.sh @@ -0,0 +1,143 @@ +#!/bin/bash +#CD=/mnt/cd +. /etc/profile +. /etc/systemconfig + +TFTP=/data/srv/tftp +CD=/data/srv/tftp/live +DESTCD=/data/srv/tftp/CD +BASE=/data/srv/tftp/masterbuild + +MODULES=$DESTCD/MythVantage/base/ +myip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1` +SRCFILES=$BASE/mnt/live/mnt/MythVantage/base/ + +function log () { +echo $1 +} + +function check_xvfb () { +export DISPLAY=127.0.0.1:25 + Xvfb -ac :25 & + +} + + +function create_base_image() { +echo $SRCFILES +if [ -f $SRCFILES/data.lzm ] +then + mkdir $HOST_IMG_DIR + cd $SRCFILES + echo "Creating image.." > $BASE/tmp/.install_state + LIST=`ls *.lzm` + for i in $LIST + do + echo $i + echo $i > $BASE/tmp/.install_percent + lzm2dir $i \/$HOST_IMG_DIR + done + + for i in sys proc dev tmp + do + mkdir /$HOST_IMG_DIR/$i + done + + chmod 777 /$HOST_IMG_DIR/tmp + mknod /$HOST_IMG_DIR/dev/null c 1 3 + mknod /$HOST_IMG_DIR/dev/null c 1 5 + mknod /$HOST_IMG_DIR/dev/console c 5 1 + chmod +s /$HOST_IMG_DIR/usr/bin/Xorg + chmod +s /$HOST_IMG_DIR/usr/bin/crontab + chmod +s /$HOST_IMG_DIR/usr/bin/sudo + chmod +s /$HOST_IMG_DIR/bin/mount + #copy fstab from masterbuild + cp -f $BASE/etc/fstab /$HOST_IMG_DIR/etc/fstab + echo "Done: installing data" > $BASE/tmp/.install_state + return 0 +else + echo "Error: no modules" > $BASE/tmp/.install_state + log "couldn't find modules to install" + return 1 +fi +} + +function configure_image () { + echo "Configuring system" > $BASE/tmp/.install_state + cp -f $BASE/etc/systemconfig $HOST_IMG_DIR/etc/systemconfig + chown root:mythtv $HOST_IMG_DIR/etc/systemconfig + chmod 775 "$HOST_IMG_DIR" /etc/systemconfig + cp /etc/mtab $HOST_IMG_DIR/etc/mtab + mount --bind /dev $HOST_IMG_DIR/dev + + chroot "$HOST_IMG_DIR" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,this_is_install +#copy syssettings template to here. + SE=$BASE$TEMPLATES/settings/syssettings + mkdir -p $HOST_IMG_DIR/$TEMPLATES/settings/syssettings + cp -rp $SE/* ${HOST_IMG_DIR}/$TEMPLATES/settings/syssettings + chown root:mythtv $HOST_IMG_DIR/etc/systemconfig + chown -R mythtv:mythtv $HOST_IMG_DIR/$TEMPLATES/settings/syssettings + chmod -R 775 $HOST_IMG_DIR/$TEMPLATES/settings/syssettings +#update remotedb with this host settings + OLDDISPLAY=$DISPLAY + check_xvfb + chroot $HOST_IMG_DIR $MV_ROOT/bin/MythVantage -t restore,default_1 + chroot $HOST_IMG_DIR $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings + if [ ! $? = 0 ] + then + touch $mountpoint/tmp/.dbsysfailed + chmod 777 $mountpoint/tmp/.dbsysfailed + else + #Run second time + chroot "$HOST_IMG_DIR" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,this_is_install + chroot "$HOST_IMG_DIR" $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL + fi +chroot "$HOST_IMG_DIR" $MV_ROOT/bin/systemconfig.sh advanced,this_is_install +cp -f $BASE/etc/X11/xorg.conf $HOST_IMG_DIR/etc/X11/xorg.conf +echo "Done" > $BASE/tmp/.install_state +DISPLAY=$OLDDISPLAY + +#cp /tmp/mythvantage_install.log $HOST_IMG_DIR/var/log/ +} + +function create_tftp_boot () { + + CFGFILE=$TFTP/pxelinux.cfg/01-$2 + echo "DEFAULT mythfe" > $CFGFILE + echo "LABEL mythfe" >> $CFGFILE + echo "kernel masterbuild/boot/vmlinuz26STB" >> $CFGFILE + echo "append vga=normal root=/dev/nfs rw netboot nfsroot=$myip:/data/srv/tftp/$1 ip=dhcp init=/sbin/runit" >> $CFGFILE + echo "TIMEOUT 2" >> $CFGFILE +} + +function create_nfs_export () { +echo "/data/srv/tftp/$1 *(rw,no_root_squash,anonuid=1000,anongid=1000) " >> /etc/exports +exportfs -arv +} + +#-------------------------------------------------------------------------------MAIN PROGRAM --------------------------------------------------------------------- +if [ x$1 = x -o x$2 = x ] +then + echo "usage: hostname macaddress" + exit 1 +fi + +image_name=$1 +mac_address=`echo $2| tr "[:upper:]" "[:lower:]"` + +echo "using image_name of $image_name" +echo "using mac_address of $mac_address" + +HOST_IMG_DIR=$TFTP/$1 + +create_base_image $image_name +configure_image +umount $HOST_IMG_DIR/dev +create_tftp_boot $image_name $mac_address +create_nfs_export $image_name + + + + +#create_dhcp_entry $mac_address + diff --git a/abs/core/LinHES-config-svn/checkout_MythVantage.sh b/abs/core/LinHES-config-svn/checkout_MythVantage.sh new file mode 100755 index 0000000..2583e6b --- /dev/null +++ b/abs/core/LinHES-config-svn/checkout_MythVantage.sh @@ -0,0 +1,45 @@ +#!/bin/bash +MYDIR=`pwd` +MYTHPATH="\/data\/LinHES-PKGBUILD\/abs\/core-testing\/mythtv\/trunk\/mythtv\/src\/mythtv" + +function setup_links { +rm mythinstall.bin +rm mythbeselect.bin +ln -s $MYDIR/src/MythVantage-app/mythinstall/mythinstall ./mythinstall.bin +ln -s $MYDIR/src/MythVantage-app/mythbeselect/mythbeselect ./mythbeselect.bin +} + +function dl_repo { +mkdir src +cd src +if [ ! -d MythVantage-app ] +then + git clone http://mythvantage.com/MythVantage-app.git/ + cd MythVantage-app + git checkout --track -b MYTHUI origin/MYTHUI + cd $MYDIR + setup_links + cd - +else + echo "updating exisiting tree" + cd MythVantage-app + git pull + git merge + cd - +fi + + +} + +dl_repo +sed -i "s/^MYTHPATH.*$/MYTHPATH\=\"$MYTHPATH\"/g" $MYDIR/src/MythVantage-app/mythinstall/mythinstall.pro +sed -i "s/#define __MVAPP__/\/\/#define __MVAPP__/g" $MYDIR/src/MythVantage-app/mythinstall/mv_common.h +sed -i "s/mythvantage/LinHES/g" $MYDIR/src/MythVantage-app/mythinstall/mv_common.h + +echo "INCLUDEPATH += /usr/include/mythtv" >> $MYDIR/src/MythVantage-app/mythbeselect/mythberestart.pro +echo "INCLUDEPATH += /usr/include/mythtv" >> $MYDIR/src/MythVantage-app/mythinstall/mythinstall.pro +cd $MYDIR/src/MythVantage-app/mythinstall && qmake +make || exit 1 +cd $MYDIR/src/MythVantage-app/mythbeselect && qmake +make ||exit 1 + diff --git a/abs/core/LinHES-config-svn/create_master.sh b/abs/core/LinHES-config-svn/create_master.sh new file mode 100755 index 0000000..1e641b4 --- /dev/null +++ b/abs/core/LinHES-config-svn/create_master.sh @@ -0,0 +1,57 @@ +#!/bin/bash +#CD=/mnt/cd +CD=/data/srv/tftp/live +DESTCD=/data/srv/tftp/CD +DEST=/data/srv/tftp/masterbuild +MODULES=$DESTCD/MythVantage/base/ +myip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1` + +mkdir -p $DESTCD +mkdir -p $DEST + +mount $CD +status=0 +if [ -f $CD/MythVantage/base/data.lzm ] +then + status=0 +else + status=1 +fi +if [ x$status = x0 ] +then + echo "copying to disk" + cp -rp $CD/* $DESTCD + cd $MODULES + for i in *.lzm + do + echo $i + lzm2dir $i \/$DEST + done + for i in sys proc dev tmp + do + mkdir $DEST/$i + done + chmod 777 /$DEST/tmp + mknod $DEST/dev/null c 1 3 + mknod $DEST/dev/null c 1 5 + mknod $DEST/dev/console c 5 1 + chmod +s $DEST/usr/bin/Xorg + chmod +s $DEST/usr/bin/crontab + chmod +s $DEST/usr/bin/sudo + chmod +s $DEST/bin/mount +fi +if [ ! -f $DEST/etc/fstab.bak ] +then + cp $DEST/etc/fstab $DEST/etc/fstab.bak +fi +tac $DEST/etc/fstab.bak|tail +4|tac > $DEST/etc/fstab +echo "$myip:/data/srv/tftp/masterbuild / nfs" >> $DEST/etc/fstab +echo "/data/srv/tftp/masterbuild *(rw,no_root_squash,anonuid=1000,anongid=1000)" >> /etc/exports + + +exportfs -arv + +#copy in the modules +mkdir -p $DEST/mnt/live/mnt/ +mv $DESTCD/* $DEST/mnt/live/mnt/ + diff --git a/abs/core/LinHES-config-svn/file_time_offset.py b/abs/core/LinHES-config-svn/file_time_offset.py new file mode 100755 index 0000000..f2973d0 --- /dev/null +++ b/abs/core/LinHES-config-svn/file_time_offset.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + + +import time +import os +import glob +import getopt +import sys +def main(argv): + filecount=0 +# root = "/tmp" +# offset = 4 + now = int(time.time()) + + + try: + opts, args = getopt.getopt(argv, "hs:d:") + except getopt.GetoptError: + sys.exit(2) + for opt, arg in opts: + if opt in ("-h", "--help"): + print "-s seconds -d /testdir" + print "default if 4 seconds" + sys.exit() + elif opt in ( "-s" ): + offset = int(arg) + elif opt in ("-d"): + root = arg + + for item in glob.glob(root+"/*"): + lastmodDate = os.path.getmtime(item) + tdiff= now-lastmodDate + #print tdiff, offset + + if tdiff > offset: + filecount+=1 + print filecount +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/abs/core/LinHES-config-svn/install-ui.xml b/abs/core/LinHES-config-svn/install-ui.xml new file mode 100755 index 0000000..2b3a043 --- /dev/null +++ b/abs/core/LinHES-config-svn/install-ui.xml @@ -0,0 +1,175 @@ +<!-- + + This is a myth style theme file for mythvantage + + (c) 2005 by a whole bunch of people associated with MythTV + +--> +<mythuitheme> + + <window name="welcome_screen"> + + <!-- + + First, define all the fonts we need on this screen + + --> + <font name="title" face="Arial"> + <color>#ffff00</color> + <dropcolor>#000000</dropcolor> + <size>20</size> + <shadow>3,3</shadow> + <bold>yes</bold> + </font> + + <font name="time" face="Arial"> + <color>#9999cc</color> + <size>18</size> + <bold>yes</bold> + </font> + + <font name="label" face="Arial"> + <color>#ffff00</color> + <dropcolor>#000000</dropcolor> + <size>18</size> + <shadow>3,3</shadow> + <bold>yes</bold> + </font> + + <font name="info" face="Arial"> + <color>#ffffff</color> + <size>18</size> + <bold>yes</bold> + </font> + + <font name="biginfo" face="Arial"> + <color>#ffffff</color> + <size>50</size> + <bold>yes</bold> + </font> + <font name="warning" face="Arial"> + <color>#ff0000</color> + <dropcolor>#000000</dropcolor> + <size>16</size> + <shadow>2,2</shadow> + <bold>yes</bold> + </font> + + <font name="buttons" face="Arial"> + <color>#ffff00</color> + <size>14</size> + <bold>yes</bold> + </font> + <font name="tinyinfo" face="Arial"> + <color>#9999cc</color> + <size>12</size> + <bold>no</bold> + </font> + + <container name="main_display"> + <area>0,0,800,600</area> + + <textarea name="title" draworder="0" align="center"> + <multiline>no</multiline> + <font>title</font> + <area>50,40,700,40</area> + <value>LinHES: The Linux Home Entertainment System </value> + </textarea> + + <!-- + time + --> + <textarea name="time_text" draworder="0" align="right"> + <multiline>no</multiline> + <font>time</font> + <area>660,520,110,30</area> + <value></value> + </textarea> + + <textarea name="date_text" draworder="0" align="hcenter"> + <multiline>yes</multiline> + <font>time</font> + <area>20,75,740,100</area> + <value></value> + </textarea> + + <!-- + current myth status + --> + + <textarea name="status_text" draworder="1" align="center"> + <multiline>yes</multiline> + <font>info</font> + <area>20,100,760,60</area> + <value>MythTV is idle and will shutdown shortly.</value> + </textarea> + + <!-- + current recordings status + --> + + <textarea name="recording_label" draworder="1" align="center"> + <font>label</font> + <area>20,140,760,30</area> + <!--<value>Percent Complete </value>--> + <value></value> + </textarea> + + <textarea name="recording_text" draworder="1" align="hcenter"> + <multiline>yes</multiline> + <font>biginfo</font> + <area>20,140,760,150</area> + <value></value> + </textarea> + + <!-- + next scheduled recording status + --> + + <textarea name="scheduled_label" draworder="1" align="center"> + <font>label</font> + <area>20,320,760,30</area> + <value></value> + </textarea> + + <textarea name="scheduled_text" draworder="1" align="hcenter"> + <multiline>yes</multiline> + <font>biginfo</font> + <area>20,400,760,120</area> + <value></value> + </textarea> + + <textarea name="mythvantage_text" draworder="1" align="right"> + <multiline>no</multiline> + <font>tinyinfo</font> + <area>20,560,760,30</area> + <value></value> + </textarea> + <!-- + scheduled recordings conflict warning + --> + + <textarea name="conflicts_text" draworder="1" align="center"> + <font>warning</font> + <area>20,490,760,30</area> + <value>WARNING: There are conflicting scheduled recordings!</value> + </textarea> + + <!-- + start frontend button + + <textbutton name="startfrontend_button" draworder="1"> + <position>81,535</position> + <font>buttons</font> + <image function="on" filename="mw_text_button_on.png"></image> + <image function="off" filename="mw_text_button_off.png"></image> + <image function="pushed" filename="mw_text_button_pushed.png"></image> + </textbutton> + + --> + + </container> + + </window> + +</mythuitheme> diff --git a/abs/core/LinHES-config-svn/install_db_chroot.sh b/abs/core/LinHES-config-svn/install_db_chroot.sh new file mode 100755 index 0000000..808dbb9 --- /dev/null +++ b/abs/core/LinHES-config-svn/install_db_chroot.sh @@ -0,0 +1,117 @@ +#!/bin/bash +. /etc/profile +. /etc/systemconfig + + +myhost=$hostname +hostname $myhost +echo $myhost > /etc/hostname +echo "$0 hostname is $hostname" + +. $MV_ROOT/bin/install_functions.sh +#myhost=`cat /etc/hostname` + +# Before this script is called, the mysqld that facilitated the installation is killed. +# We need to make sure to stop and start the mysqld that will be used post-install so +# that the database can be initialized. + +/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() { + # parameter: number of tries to start mysqld so far + PID=`pidof -o %PPID /usr/sbin/mysqld` + if [ -z "$PID" ]; then # mysqld isn't running + if [ $1 -gt 3 ]; then + echo "ERROR: Failed to start MySQL server in $1 attempts." + sleep 5 + exit 1 + else + echo "Tried $1 time(s) to start MySQL server." + return 1 + fi + else # mysqld is running + return 0 + fi + # should never get here + return 1 +} + +mysqld_tries=0 +# See if MySQL server is running; try several ways to start it if it's not. +while true; do + success_test $mysqld_tries + if [ $? -eq 0 ]; then + echo "MySQL server is running" + break + 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 + if [ $? -eq 0 ]; then + echo "MySQL server has been started" + break + 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 + if [ $? -eq 0 ]; then + echo "MySQL server has been installed and started" + break + else + echo "MySQL server would not start, even after (re-)installing it." + fi + fi + fi +done + +# At this point, MySQL server should be up and running + +while true; do + mysql -e "show databases;" + + if [ $? -eq 0 ]; then + pacman --noconfirm -R mythdb-initial + pacman --noconfirm -S mythdb-initial + $MV_ROOT/bin/restore_default_settings.sh -c load + DISPLAY=127.0.0.1:0 $MV_ROOT/bin/MythVantage -t restore,default_1 + $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings + $MV_ROOT/bin/systemconfig.sh misc,hostype,this_is_install + + update_db_settings HostServiceMythWEB "1" + echo 'UseMythWEB="1"' >> /etc/systemconfig + + #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 /var/lib/mysql/mythconverg ] + if [ -d /data/srv/mysql/mythconverg ]; then + # pacman --noconfirm -R webcalendar + # pacman --noconfirm --nodeps -S webcalendar + break + else + echo "Failed to create mythconverg database. Will re-try." + sleep 1 + fi +# if [ $SystemType = "Master_backend" ] +# then +# $MV_ROOT/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost +# fi + else + echo "Failed to look for databases. Will re-try." + sleep 1 + fi +done +/etc/rc.d/mysqld stop +#umount /proc diff --git a/abs/core/LinHES-config-svn/install_functions.sh b/abs/core/LinHES-config-svn/install_functions.sh new file mode 100755 index 0000000..4f6f7ed --- /dev/null +++ b/abs/core/LinHES-config-svn/install_functions.sh @@ -0,0 +1,621 @@ +#!/bin/bash +. /etc/profile +disk=$2 +mountpoint=new_boot + +#------------------------------------------- +MYTHDBUSER=mythtv +MYTHTVPASSWD=mythtv +CMDLINE=$(cat /proc/cmdline) +hostname=`hostname` +MYSQLCMD_C="mysql -u$MYTHDBUSER -p$MYTHTVPASSWD mythconverg -B --exec" +BASE="" + + +function update_db_settings () { + + echo "setting database value $1 to $2 for $hostname" + $MYSQLCMD_C "delete from settings where value='${1}' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set value='${1}', data='${2}' , hostname=\"$hostname\";" +} + +function random_theme () { +THEMES="basic-blue +basic-green +basic-red +basic-purple +basic-amber" + +theme=($THEMES) # Read into array variable. + +num_themes=${#theme[*]} # Count how many elements. + +pick=${theme[$((RANDOM%num_themes))]} +echo "Selected $pick as the theme" +update_db_settings Theme "$pick" +} + + +function splash_setup (){ + echo $CMDLINE | grep -q splash=silent + if [ $? -eq 0 ] + then + update_db_settings Hostbootsplash 1 + else + update_db_settings Hostbootsplash 0 + fi +} + + +function setupremote { + [ -e $BASE/etc/lircd.conf ] && mv -f $BASE/etc/lircd.conf $BASE/etc/lircd.conf.`date +%Y-%m-%d-%H-%M` + if [ -d $TEMPLATES/remotes/$Remotetype ] + then + cd $TEMPLATES/remotes/$Remotetype + for i in lircd* + do + cat $i >> $BASE/etc/lircd.conf + done + cp -f lircrc* $BASE/etc/lircrc 2> /dev/null + [ -e /etc/lircrc ] && chmod 755 /etc/lircrc + update_db_settings HostRemoteType "$Remotetype" + #special case for special remote + echo "Starting with support for $Remotetype" + if [ "$Remotetype" == "dvico" ] + then + /usr/sbin/lircd -d /dev/usb/hiddev0 + else + /usr/sbin/lircd -d /dev/lirc0 + fi + [ -e /root/.mythtv ] || mkdir /root/.mythtv 2>/dev/null + ln -s /etc/lircrc /root/.mythtv/lircrc 2>/dev/null + else + echo "Couldn't open directory $TEMPLATES/remotes/$Remotetype" + fi +} + +function scan_for_hpg_receiver() { +echo "Scanning for Hauppauge receiver" +for hpgid in `lspci -nm -d4444: |cut -d" " -f6- |tr -d '"'|tr " " :` +do + line=`grep $hpgid $TEMPLATES/remotes/i2c.id` + if [ $? -eq 0 ] + then + modprobe lirc_i2c + FoundReceiverType=`echo "$line"|cut -d"|" -f2` + Remotetype=`echo "$line"|cut -d"|" -f4` + statusline=`echo "$line"|cut -d"|" -f2,4` + echo "Found $statusline , $Remotetype" + update_db_settings HostReceiverType $FoundReceiverType + setupremote + break + fi + +done +} + + +function scan_for_usb_remote () { +found_remote=1 +echo "Scanning for usb receiver/remote" +while read line +do + USBID=`echo "$line"|cut -d"|" -f1` + lsusb -d "$USBID" > /dev/null 2>/dev/null + if [ $? -eq 0 ] + then + Remotetype=`echo "$line"|cut -d"|" -f2` + echo "Found $Remotetype" + setupremote + found_remote=0 + break + fi +done <$BASE/$TEMPLATES/remotes/receiver_usb.id +if [ $found_remote -eq 1 ] +then + scan_for_hpg_receiver +fi +echo "Scanning for TatIR..." +if lsusb | grep 04d8:0004 > /dev/null 2>/dev/null +then + /usr/bin/PyroUsb.py > /dev/null 2>&1 & +fi +} + +function rest_of_network () { + #netmask + echo $CMDLINE | grep -q netmask + if [ $? -eq 0 ] + then + TEMPVAR=${CMDLINE#*netmask=} + NETMASK=${TEMPVAR%% *} + /sbin/ifconfig eth0 $IP netmask $NETMASK + nm=`/usr/bin/nmconv.py -obits $NETMASK` + NETMASK="/$nm $NETMASK" + echo $NETMASK + update_db_settings HostNETMASK${MYTHDEFAULT} "$NETMASK" + else + echo "netmask not found" + fi + #gateway + echo $CMDLINE | grep -q gateway + if [ $? -eq 0 ] + then + TEMPVAR=${CMDLINE#*gateway=} + GATEWAY=${TEMPVAR%% *} + /sbin/route add default gw $GATEWAY + update_db_settings HostGW${MYTHDEFAULT} "$GATEWAY" + + else + echo "gateway not found" + fi + + #dns + echo $CMDLINE | grep -q dns + if [ $? -eq 0 ] + then + TEMPVAR=${CMDLINE#*dns=} + DNS=${TEMPVAR%% *} + echo "nameserver $DNS" >> /etc/resolv.conf + update_db_settings HostDNS${MYTHDEFAULT} "$DNS" + else + echo "DNS not found" + fi +} + +function init_network { + echo $CMDLINE |grep -q netdev + if [ $? -eq 0 ] + then + TEMPVAR=${CMDLINE#*netdev=} + MYTHDEFAULT=${TEMPVAR%% *} + else + MYTHDEFAULT="eth0" + fi + + + + echo $CMDLINE | grep -q ip + if [ $? -eq 0 ] + then + update_db_settings HostDefaulteth0 0 + update_db_settings HostDefault${MYTHDEFAULT} 1 + + update_db_settings HostActiveonbooteth0 0 + update_db_settings HostActiveonboot${MYTHDEFAULT} 1 + update_db_settings HostNetDevice ${MYTHDEFAULT} + + TEMPVAR=${CMDLINE#*ip=} + IP=${TEMPVAR%% *} + if [ "$IP" == "dhcp" ] + then + /sbin/dhcpcd $MYTHDEFAULT + update_db_settings HostUseDHCP${MYTHDEFAULT} 0 + else + /sbin/ifconfig ${MYTHDEFAULT} $IP + update_db_settings HostUseDHCP${MYTHDEFAULT} 1 + update_db_settings HostIP${MYTHDEFAULT} "$IP" + rest_of_network + fi + fi +} + +function init_remote { + echo $CMDLINE | grep -q remoteport + if [ $? -eq 0 ] + then + TEMPVAR=${CMDLINE#*remoteport=} + REMOTEPORT=${TEMPVAR%% *} + if [ "$ReceiverType" == "Serial" ] + then + if [ -e /dev/$REMOTEPORT ] + then + /usr/bin/setserial /dev/$REMOTEPORT uart none + /sbin/modprobe lirc_serial + update_db_settings HostReceiverType Serial + update_db_settings HostSerialPortlirc "$REMOTEPORT" + fi + fi + + fi + + echo $CMDLINE | grep -q remote + if [ $? -eq 0 ] + then + TEMPVAR=${CMDLINE#*remote=} + Remotetype=${TEMPVAR%% *} + setupremote + else + scan_for_usb_remote + fi +} + +#----------------------- + +#set -x + +partition_it () { +ROOT=$1 +DATA=$2 +SWAP=$3 + +if [ "$SWAP" != "NO" ] + then + SWAPLINE=",$SWAP,S" + MKSWAPCMD="mkswap /dev/${disk}2" + else + SWAPLINE=",0,0" + MKSWAPCMD="" + fi + +if [ "$DATA" == "ALL" ] +then + DATALINE=",,," + EXTRALINE="" +else + DATALINE=",$DATA,," + EXTRALINE=",0,," +fi +sfdisk /dev/$disk -uM << EOF +,$1,,* +$SWAPLINE +$DATALINE +$EXTRALINE +; +EOF + +$MKSWAPCMD +#sfdisk -l /dev/$disk +} + + +function fscmd () { + +case $1 in + reiserfs) FSCMDC="mkreiserfs -q -l ROOT" + ;; + + xfs) FSCMDC="mkfs -t $1 -f" + ;; + ext3) FSCMDC="mkfs.ext3" + ;; + jfs) FSCMDC="mkfs.jfs -q " + ;; + ext4) FSCMDC="mkfs.ext4" + ;; + *) FSCMDC="echo $1" + ;; +esac +} + +format_it () { + fscmd $1 + $FSCMDC /dev/${disk}1| tr -s [:cntrl:] \\n + fscmd $2 + $FSCMDC /dev/${disk}3| tr -s [:cntrl:] \\n +} + +mount_it () { + if [ ! -d \/$mountpoint ] + then + mkdir \/$mountpoint + fi + mount /dev/${disk}1 \/$mountpoint + mkdir \/$mountpoint/myth + mount /dev/${disk}3 \/$mountpoint/myth +} + +unmount_it () { + umount /dev/${disk}1 + umount /dev/${disk}3 + umount \/$mountpoint/myth + umount \/$mountpoint +} + + +copy_it () { + + if [ "$1" == "ALL" ] + then + echo "Transferring system" + unsquashfs -f -d /$mountpoint /.livesys/medium/system.sqf + else + echo "Upgrading system" + unsquashfs -e $1 -f -d /$mountpoint /.livesys/medium/system.sqf + fi + + for i in sys proc dev tmp + do + mkdir /$mountpoint/$i + + done + chmod 777 /$mountpoint/tmp + mknod /$mountpoint/dev/null c 1 3 + mknod /$mountpoint/dev/null c 1 5 + mknod /$mountpoint/dev/console c 5 1 + chmod +s /$mountpoint/usr/bin/Xorg + chmod +s /$mountpoint/usr/bin/crontab + chmod +s /$mountpoint/usr/bin/sudo + chmod +s /$mountpoint/bin/mount + +} + + +device_node () { + cd /dev + mknod hda b 3 0 + mknod hda1 b 3 1 + mknod hda2 b 3 2 + mknod hda3 b 3 3 + mknod hda4 b 3 4 + mknod hda5 b 3 5 + mknod hda6 b 3 6 + mknod hda7 b 3 7 + mknod hda8 b 3 8 + mknod sda b 8 0 + mknod sda1 b 8 1 + mknod sda2 b 8 2 + mknod sda3 b 8 3 + mknod sda4 b 8 4 + mknod sda5 b 8 5 + mknod sda6 b 8 6 + mknod sda7 b 8 7 + mknod sda8 b 8 8 + mknod sdb b 8 16 + mknod sdb1 b 8 17 + mknod sdb2 b 8 18 + mknod sdb3 b 8 19 + mknod sdb4 b 8 20 + mknod sdb5 b 8 21 + mknod sdb6 b 8 22 + mknod sdb7 b 8 23 + mknod sdb8 b 8 24 + cd - + } + + + + +function create_fstab() +{ +echo "creating fstab" +cat > /$mountpoint/etc/fstab << EOF +# <file system> <dir> <type> <options> <dump> <pass> +none /dev/pts devpts defaults 0 0 +none /dev/shm tmpfs defaults 0 0 +/dev/cdrom /media/cdrom auto ro,user,noauto,unhide 0 0 +/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0 +UUID=ROOTUID / auto defaults 0 1 +UUID=DATAUID /myth auto defaults 0 1 +UUID=SWAPUID swap swap defaults 0 0 +EOF + + +} + + +function find_uuid() { + uuid=`blkid -s UUID /dev/$1 |cut -d= -f2|cut -d\" -f2` + echo $uuid for $1 + FOUNDUUID=$uuid + +} + + +get_grub_map() { + [ -e /tmp/dev.map ] && rm /tmp/dev.map + /sbin/grub --no-floppy --device-map /tmp/dev.map <<EOF +quit +EOF +} + +mapdev() { + partition_flag=0 + device_found=0 + devs=$(cat /tmp/dev.map | grep -v fd | sed 's/ *\t/ /' | sed ':a;$!N;$!ba;s/\n/ /g') + linuxdevice=$(echo $1 | cut -b1-8) + if [ "$(echo $1 | egrep '[0-9]$')" ]; then + # /dev/hdXY + pnum=$(echo $1 | cut -b9-) + pnum=$(($pnum-1)) + partition_flag=1 + fi + for dev in $devs + do + if [ "(" == $(echo $dev | cut -b1) ]; then + grubdevice="$dev" + else + if [ "$dev" == "$linuxdevice" ]; then + device_found=1 + break + fi + fi + done + if [ "$device_found" == "1" ]; then + if [ "$partition_flag" == "0" ]; then + echo "$grubdevice" + else + grubdevice_stringlen=${#grubdevice} + grubdevice_stringlen=$(($grubdevice_stringlen - 1)) + grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen) + echo "$grubdevice,$pnum)" + fi + else + echo "DEVICE NOT FOUND" + fi +} + + +dogrub() { + get_grub_map + sync + ROOTDEV=/dev/$1 + echo $ROOTDEV + + bootdev=$(mapdev $ROOTDEV) + echo $bootdev + cp -a /$mountpoint/usr/lib/grub/i386-pc/* /$mountpoint/boot/grub/ + sync + # freeze xfs filesystems to enable grub installation on xfs filesystems + if [ -x /usr/sbin/xfs_freeze ]; then + #/usr/sbin/xfs_freeze -f /$mountpoint > /dev/null 2>&1 + echo "freezing xfs fs" + /usr/sbin/xfs_freeze -f /$mountpoint + if [ $? -eq 0 ] + then + sleep 40 + echo "unfreezing xfs" + /usr/sbin/xfs_freeze -u /$mountpoint + fi + fi + #$DESTDIR/sbin/grub-install --recheck --root-directory=$DESTDIR $bootdev >/tmp/grub.log 2>&1 + echo grub-install --recheck --root-directory=/$mountpoint $bootdev + grub-install --recheck --root-directory=/$mountpoint $bootdev + # unfreeze xfs filesystems + + + if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then + echo "Error installing GRUB. " + return 1 + fi + echo "GRUB was successfully installed." +} + +function removevg () { + LIST=`pvscan |grep $1|tr -s " " |cut -d" " -f 5` + for vg in $LIST + do + echo "Removing vg $vg" + vgremove -f -v $vg + done + + + + +} + + +case $1 in + partition_it ) + #drive ROOT DATA(ALL) SWAP(NO) + for i in `mount | grep $disk | awk ' { print $1 } '` + do + umount $i + done + swap=`cat /etc/fstab |grep $disk|grep swap|awk ' { print $1 } '` + swapoff $swap + removevg $disk + partition_it $3 $4 $5 + exit 0 + + ;; + format_it ) + device_node + + format_it $3 $4 + exit 0 + ;; + mount_it ) + mount_it + ;; + copy_it ) + copy_it $3 + + ;; + + + fstab_fix_it) + echo $@ >> /tmp/fstab.input + if [ ! -f /$mountpoint/etc/fstab ] + then + create_fstab + fi + #was 5 + if [ "$3" == "UPGRADE" ] + then + if [ ! -f /tmp/etc/KnoppMyth-version ] + then + if [ -f /tmp/etc/fstab ] + then + cp -f /tmp/etc/fstab /$mountpoint/etc/fstab + else + create_fstab + fi + else + create_fstab + fi + fi + + #search for UUID + FOUNDUUID="" + find_uuid ${2}1 + ROOTUUID=$FOUNDUUID + echo "--" + echo $ROOTUUID + echo "--" + FOUNDUUID="" + find_uuid ${2}2 + SWAPUUID=$FOUNDUUID + + FOUNDUUID="" + if [ "$4" == "" ] + then + #upgrade + find_uuid ${2}3 + elif [ "$5" == "FULL_INSTALL" ] + then + #install + find_uuid ${2}3 + else + #upgrade with non statndard myth + find_uuid $4 + fi + + DATAUUID=$FOUNDUUID + + + + sed -i -e "s/.*\/\ .*$/UUID=$ROOTUUID \/ auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab + sed -i -e "s/.*\/myth\ .*$/UUID=$DATAUUID \/myth auto defaults,noatime 0 1/g" /$mountpoint/etc/fstab + sed -i -e "s/.*swap\ .*$/UUID=$SWAPUUID swap swap defaults 0/g" /$mountpoint/etc/fstab + +#if Knoppmyth upgrade then loop through old fstab picking out vg + if [ -f /tmp/etc/KnoppMyth-version ] + then + if [ -f /tmp/etc/fstab ] + then + grep -q /dev/vg /tmp/etc/fstab + if [ $? -eq 0 ] + then + grep /dev/vg /tmp/etc/fstab >> /$mountpoint/etc/fstab + grep /dev/vg /tmp/etc/fstab | awk -v mount=$mountpoint ' { print "/" mount $2 }' |xargs mkdir + grep /dev/vg /tmp/etc/fstab | awk -v mount=$mountpoint ' { print "/" mount $2 }' |xargs chown -R mythtv:users + fi + fi + fi + ;; + + grub_it ) + + #grub-install --recheck --no-floppy --root-directory=/$mountpoint "(hd0)" + #fixing grub/menu.1st + dogrub ${disk} + FOUNDUUID="" + find_uuid ${disk}1 + ROOTUUID=$FOUNDUUID + sed -i -e "s/root=.\S*/root=\/dev\/disk\/by-uuid\/$ROOTUUID/g" /$mountpoint/boot/grub/menu.lst + mkinitcpio -g /$mountpoint/boot/kernel26.img + ;; + umount_it) + umount \/$mountpoint/myth + umount \/$mountpoint + ;; + update_db_it ) + update_db_settings "$2" "$3" + ;; + + +esac + + + diff --git a/abs/core/LinHES-config-svn/install_proxy.sh b/abs/core/LinHES-config-svn/install_proxy.sh new file mode 100755 index 0000000..32d01d7 --- /dev/null +++ b/abs/core/LinHES-config-svn/install_proxy.sh @@ -0,0 +1,717 @@ +#!/bin/bash +#chroot and /tmp +export TERM=vt100 +MVHOSTNAME=larch5 +. /etc/profile +TEMP_TEMPLATES=/tmp/templates +disk=$2 +rootfs=$3 +rootsize=$4 +datafs=$5 +datasize=$6 +swapsize=$7 +mountpoint="/new_boot" +run=$MV_ROOT/bin/install_functions.sh +. /etc/systemconfig 2>/dev/null +. $MV_ROOT/bin/networkconfig.sh +CMDLINE=$(cat /proc/cmdline) +BACKUPFILE="/myth/backup/mythconverg.sql.gz" + +#TEMPNET="Hostip"$default_interface +#eval MYTHIP=\$${TEMPNET} +function create_chroot_mnt_points() { + + echo "Creating directory for media in chroot" + mkdir -p $mountpoint/media/cdrom + mkdir -p $mountpoint/media/dvd + mkdir -p $mountpoint/mnt + +} +function cp_and_log () { + ls $1 >/dev/null 2>&1 + status=$? + if [ $status = 0 ] + then + echo "copying $1 to $2" + cp -rfp $1 $2 + else + echo "$1 is not present, skipping..." + fi + +} + +function mdadm_find () { + + PREFIX=$1 + if [ -e $PREFIX/etc/KnoppMyth-version ] + then + MDADM_CONF="/etc/mdadm/mdadm.conf" + else + MDADM_CONF="/etc/mdadm.conf" + fi + echo "Using $MDADM_CONF" +} + +progress () { +mypercent=`echo "$1" | cut -d. -f1` +if [ x$mypercent = x ] +then +echo "" > /tmp/.install_percent +else +echo "${mypercent}% complete" > /tmp/.install_percent +fi + + +} + +function apply_new_auth () { +#check if file is present + if [ -f /root/myth_user_call.out ] + then + #read in file, running each command in chroot + exec 4</root/myth_user_call.out + while read LINE <&4 + do + if [ ! x"$LINE" = x ] + then + #run commands in chroot + chroot "$mountpoint" $MV_ROOT/bin/myth_user_call -i $LINE > /tmp/user_auth.update + fi + done + rm -f /root/myth_user_call.out + else + echo "No new password changes to apply" + fi +} + + +function backup_sql_check { + if [ -f ${mountpoint}${BACKUPFILE} ] + then + echo "found ${mountpoint}${BACKUPFILE} " + rc=0 + else + echo "did not find ${mountpoint}${BACKUPFILE} " + rc=1 + fi + return $rc +} + +function mdadm_assemble_all { + + mdadm_find /tmp + mdadm --assemble --scan -c /tmp${MDADM_CONF} + MDLIST=`grep ARRAY /tmp${MDADM_CONF}|tr -s [:space:]|cut -d" " -f2` + for array in $MDLIST + do + echo "assembling array $array" + mdadm --assemble -c /tmp${MDADM_CONF} $array + sleep 2 + fsck -p $array + done + +} + +function upgrade_mount_search { + + MYTH_P=`cat /tmp/etc/fstab |grep -E /myth[[:space:]] | awk ' {print $1 '} ` + umount $mountpoint/myth + + #should probably just mdadm all the time + echo $MYTH_P |grep -q \/md. + if [ $? = 0 ] + then + mdadm_assemble_all + fi + + echo $MYTH_P |grep -q UUID + if [ $? = 0 ] + then + MUUID=`echo $MYTH_P|cut -d= -f2|tr -d \"` + echo blkid $MUUID + blkid -t UUID=$MUUID + if [ ! $? = 0 ] + then + echo "couldn't find $MUUID, starting md support" + mdadm_assemble_all + fi + mount -U $MUUID $mountpoint/myth + echo mount -U $MUUID $mountpoint/myth + MYTHMOUNT=`blkid -t UUID=$MUUID|cut -d: -f1` + MYTHMOUNT=`basename $MYTHMOUNT` + echo "MYTHMOUNT is $MYTHMOUNT" + else + mount $MYTH_P $mountpoint/myth + echo mount $MYTH_P $mountpoint/myth + MYTHMOUNT=`basename $MYTH_P` + echo "MYTHMOUNT is $MYTHMOUNT" + fi + sleep 2 + backup_sql_check + if [ $? = 1 ] + then + mkdir -p /new_boot/root/backup + if [ ! -e /tmp/mythconverg.sql.gz ] + then + echo "Couldn't find ANY database to restore, upgrade will continue but a new database will be installed." + else + cp_and_log /tmp/mythconverg.sql.gz /new_boot/root/backup/mythconverg.sql.gz + BACKUPFILE="/root/backup/mythconverg.sql.gz" + echo "setting BACKUPFILE to $BACKUPFILE" + fi + fi + return 0 +} + + +full_install () { + if [ -f /tmp/.this_is_upgrade ] + then + rm /tmp/.this_is_upgrade + fi + echo "Partitioning $disk" > /tmp/.install_state + progress 1 + sleep 1 + $run partition_it $disk $rootsize $datasize $swapsize + + echo "Formatting $disk" > /tmp/.install_state + progress 2 + sleep 1 + $run format_it $disk $rootfs $datafs + + echo "Preparing $disk" > /tmp/.install_state + progress 3 + sleep 1 + $run mount_it $disk + + startsize=`statgrab -M disk.|grep $disk.write_bytes|cut -d= -f 2|tr -d " "` + + echo "STARTSIZE=$startsize">/tmp/.startsize.io + echo "Creating $hostname" > /tmp/.install_state + + sleep 1 + $run copy_it $disk ALL + rm $mountpoint/etc/fstab + $run fstab_fix_it $disk $rootfs $datafs FULL_INSTALL + echo "Configuring system" > /tmp/.install_state + progress 100 + #progress 99 + sleep 1 + $run grub_it $disk + + + #echo "Configuring system" > /tmp/.install_state + #progress 100 + sleep 1 + cp_and_log /etc/systemconfig "$mountpoint"/etc + cp_and_log /root/xorg.conf.install "$mountpoint"/etc/X11/xorg.conf.install + #run save syssettings to save settings, then copy to new mountpoint + $MV_ROOT/bin/restore_default_settings.sh -c save -t syssettings -h $MVHOSTNAME -d localhost + SE=$TEMPLATES/settings/syssettings + mkdir -p ${mountpoint}$SE + #cp -rp $SE/* ${mountpoint}$SE/ + cp_and_log "$SE/*" "${mountpoint}$SE/" + chown root:mythtv "$mountpoint"/etc/systemconfig + chown -R mythtv:mythtv ${mountpoint}$SE + + chmod -R 775 ${mountpoint}$SE + chmod 775 "$mountpoint"/etc/systemconfig + mkdir -p "$mountpoint"/var/log/mythtv + chown mythtv "$mountpoint"/var/log/mythtv + #copy over any updates that might have occured + #cp -rp $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/ + cp_and_log "$MV_ROOT/bin/*.sh" "$mountpoint"$MV_ROOT/bin/ + chmod -R 755 ${mountpoint}/root + create_chroot_mnt_points + cp_and_log /etc/mtab "$mountpoint"/etc/mtab + # cp_and_log /etc/hostname "$mountpoint"/etc/hostname + apply_new_auth + + + if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ] + then + #installing DB to local machine + #turn off old live database, so the chroot one can start + echo "---------------------CHROOT INSTALLDB-------------------------" + /etc/rc.d/mysqld stop + mount --bind /dev "$mountpoint/dev" + mount --bind /proc "$mountpoint/proc" + chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" 2>&1 |tee /tmp/chrootdb.out + #chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" + chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install + echo "stopping mysql in chroot" + chroot "$mountpoint" /etc/rc.d/mysqld stop + kill_dhcp_chroot + sleep 2 + lsof |grep new_boot + umount -l "$mountpoint/dev" + umount -l "$mountpoint/proc" + + echo "---------------------END CHROOT INSTALLDB-------------------------" + /etc/rc.d/mysqld start + else + #update remotedb with this host settings + chroot "$mountpoint" DISPLAY=127.0.0.1:0 /usr/local/bin/MythVantage -t restore,default_1 + chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings + if [ ! $? = 0 ] + then + touch $mountpoint/tmp/.dbsysfailed + chmod 777 $mountpoint/tmp/.dbsysfailed + else + #Run second time + chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install + chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL + fi + fi + chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced + touch $mountpoint/home/mythtv/.configure && chmod 777 $mountpoint/home/mythtv/.configure + + echo "Done" > /tmp/.install_state + cp_and_log /tmp/mythvantage_install.log $mountpoint/var/log/ + $run umount_it $disk + +} + +function createsquashlist(){ +if [ -f $1 ] +then + rm -f +$1 +fi +for i in bin boot etc home lib opt root sbin usr var data +do +echo $i >> $1 +done + + +} + + + + +function upgrade () { + touch /tmp/.this_is_upgrade + + if [ ! x$rootfs = "xDo_not_format" ] + then + echo "Formatting $disk" > /tmp/.install_state + progress 2 + sleep 1 + $run format_it $disk $rootfs NO + fi + echo "Preparing $disk" > /tmp/.install_state + progress 3 + sleep 1 + $run mount_it $disk + startsize=`statgrab -M disk.|grep $disk.write_bytes|cut -d= -f 2|tr -d " "` + echo "STARTSIZE=$startsize">/tmp/.startsize.io + echo "Upgrading $hostname" > /tmp/.install_state + sleep 1 + cp_and_log /tmp/etc /new_boot/etc.old + cp_and_log /tmp/oss /new_boot/var/lib/oss.old + + + SQUASHLIST="/tmp/.squashlist" + createsquashlist $SQUASHLIST + $run copy_it $disk $SQUASHLIST + #copy back ssh keys + +# cp_and_log -rp /data/var/cache/pacman/pkg/* /new_boot/data/var/cache/pacman/pkg/ + cp_and_log "/new_boot/etc.old/ssh/*.pub" /new_boot/etc/ssh/ + cp_and_log "/new_boot/etc.old/ssh/*.key" /new_boot/etc/ssh/ + cp_and_log "/new_boot/etc.old/ssh/*key" /new_boot/etc/ssh/ + mdadm_find /tmp + cp_and_log /tmp${MDADM_CONF} /new_boot/etc + #cp_and_log /new_boot/etc.old/mdadm/mdadm.conf /new_boot/etc/ + cp_and_log /new_boot/etc.old/asound.state /new_boot/etc/ + if [ ! -f /tmp/etc/KnoppMyth-version ] + then + #passwd/shadow/group + cp_and_log /new_boot/etc.old/passwd /new_boot/etc/ + cp_and_log /new_boot/etc.old/shadow /new_boot/etc/ + cp_and_log /new_boot/etc.old/group /new_boot/etc/ + fi + mkdir -p "$mountpoint"/var/log/mythtv + chown mythtv "$mountpoint"/var/log/mythtv + if [ x$rootfs = "xDo_not_format" ] + then + rootfs=`grep \/\ /tmp/etc/fstab |awk ' { print $3 } '` + fi + #this is here to copy in the systemconfig file as soon as possible. + cp_and_log /etc/systemconfig "$mountpoint"/etc/systemconfig + echo "Configuring system" > /tmp/.install_state + progress 100 + backup_sql_check + if [ $? = 1 ] + then + upgrade_mount_search + fi + echo $run fstab_fix_it $disk UPGRADE $MYTHMOUNT + $run fstab_fix_it $disk UPGRADE $MYTHMOUNT + create_chroot_mnt_points + + #echo "Writing boot sector" > /tmp/.install_state + #progress 99 + sleep 1 + $run grub_it $disk + #echo "Configuring system" > /tmp/.install_state + #progress 100 + sleep 1 + cp_and_log /etc/mtab "$mountpoint"/etc/mtab + cp_and_log /etc/systemconfig "$mountpoint"/etc + cp_and_log /root/xorg.conf.install "$mountpoint"/etc/X11/xorg.conf.install +#make sure mythconverg.sql.gz is present + #backup_sql_check + #if [ $? = 1 ] + #then + # upgrade_mount_search + #fi + echo $CMDLINE | grep -q clean_upgrade + status=$? + if [ -f /tmp/etc/KnoppMyth-version -o $status = 0 ] + then + #run save syssettings to save settings, then copy to new mountpoint + $MV_ROOT/bin/restore_default_settings.sh -c save -t syssettings -h $MVHOSTNAME -d localhost + SE=$TEMPLATES/settings/syssettings + mkdir -p ${mountpoint}$SE + #cp -rfp $SE/* ${mountpoint}$SE/ + cp_and_log "$SE/*" "${mountpoint}$SE/" + chown root:mythtv "$mountpoint"/etc/systemconfig + chown -R mythtv:mythtv ${mountpoint}$SE + chmod -R 775 ${mountpoint}$SE + if [ ! $status = 0 ] + then + touch $mountpoint/home/mythtv/.kmupgrade && chmod 777 $mountpoint/home/mythtv/.kmupgrade + fi + fi + + + + cp_and_log "$MV_ROOT/bin/*.sh" "$mountpoint"$MV_ROOT/bin/ + chmod -R 755 ${mountpoint}/root + chown root:mythtv "$mountpoint"/etc/systemconfig + chmod 775 "$mountpoint"/etc/systemconfig + #mount /proc and /dev + mount --bind /dev "$mountpoint/dev" + mount --bind /proc "$mountpoint/proc" + + chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install + #wrap this in a network check_network, no need to update the db if the import worked. + ##### do I need to start mysql? + /etc/rc.d/mysqld stop + if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ] + then + echo $CMDLINE | grep -q clean_upgrade + status=$? + if [ $status = 0 ] + then + #new db as part of clean upgrade + echo "--------------------------------" + echo "clean upgrade installing new database" + echo "--------------------------------" + chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" |tee /tmp/chrootdb.out + echo "############################################" + echo "End Installing new database/clean" + echo "############################################" + else + #proceed as normal + if [ -f "$mountpoint"/$BACKUPFILE ] + then + echo "--------------------------------" + echo "Restoring database with $BACKUPFILE" + echo "--------------------------------" + chroot "$mountpoint" "$MV_ROOT/bin/restore_km_db_chroot.sh" "$BACKUPFILE" |tee /tmp/chrootdb_km.out + echo "############################################" + echo "End Restoring database" + echo "############################################" + else + echo "--------------------------------" + echo "Couldn't find backup file, installing new database" + echo "--------------------------------" + touch /tmp/.upgrade_db_failed + chroot "$mountpoint" "$MV_ROOT/bin/install_db_chroot.sh" |tee /tmp/chrootdb.out + echo "############################################" + echo "End Installing new database" + echo "############################################" + fi + fi + fi + + if [ -f /tmp/etc/KnoppMyth-version ] + then + chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t hostsettings + #change permissions of /myth (only needed on km->linhes) + chown -R mythtv:mythtv $mountpoint/myth + chown -R root:root $mountpoint/myth/backup + else + chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings + fi + # + #Run second time + chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install + chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced,this_is_install + echo "stopping mysql in chroot" + chroot "$mountpoint" /etc/rc.d/mysqld stop + apply_new_auth + kill_dhcp_chroot + umount -l "$mountpoint/dev" + umount -l "$mountpoint/proc" + + echo "Done" > /tmp/.install_state + cp_and_log /tmp/mythvantage_install.log $mountpoint/var/log/ + + $run umount_it $disk + /etc/rc.d/mysqld start +} + +function netboot-full_install () { + TEMPVAR=${CMDLINE#*nfsroot=} + NFSROOT=${TEMPVAR%% *} + NFSROOT=`echo $NFSROOT|cut -d: -f1` + MAC=`/sbin/ifconfig eth0|grep HWaddr| cut -d: -f2-|awk '{ print $3}'|tr : -` + URL="http://$NFSROOT:1337/diskless.py?HOSTNAME=$hostname&MAC=$MAC" + echo "calling $URL" + echo "Starting" > /tmp/.install_state + curl $URL + ${MV_ROOT}/bin/xconfig.sh +} + +# function killdhcp () { +# if [ -f /etc/dhcpc/dhcpcd-eth0.pid ] +# then +# pid=`cat /etc/dhcpc/dhcpcd-eth0.pid` +# kill -9 $pid +# rm -f /etc/dhcpc/dhcpcd-eth0.pid +# rm -f /var/run/dhcpcd* +# fi +# if [ -f /var/run/dhcpcd-eth0.pid ] +# then +# pid=`cat /var/run/dhcpcd-eth0.pid` +# kill -9 $pid +# rm -f /var/run/dhcpcd-eth0.pid* +# fi +# ip address flush dev eth0 +# } + + + +function SANE_SYSETTINGS () { +sed -e '/HOSTrootfstype/d' \ + -e '/HOSTrootfstype/d' \ + -e '/HOSTdatafstype/d' \ + -e '/HOSTOSsize/d' \ + -e '/HostUseALLdata/d' \ + -e '/HOSTDATAsize/d' \ + -e '/HOSTuprootfstype/d' \ + -e '/HostUseSWAP/d' \ + -e '/HOSTSWAPsize/d ' /tmp/templates/settings/syssettings/settings.txt > /tmp/settings.new + mv /tmp/settings.new /tmp/templates/settings/syssettings/settings.txt +} + +case $1 in + full_install_it ) full_install ;; + + NETBOOT) +echo "-----------------------------------------------------------------------3-----" + netboot-full_install ;; + + find_update) + + #TRY TO mount first partition of drive + #copy /etc/systemconfig to live, import settings into db + #umount drive + echo $CMDLINE | grep -q clean_upgrade + if [ $? = 1 ] + then + $run mount_it $disk + [ -e "/new_boot/root/backup/mythconverg.sql.gz" ] && cp /new_boot/root/backup/mythconverg.sql.gz /tmp + + + if [ -f /new_boot/etc/systemconfig ] + then + ###########ADD templates + mkdir -p $TEMP_TEMPLATES + cp_and_log /new_boot/$TEMPLATES $TEMP_TEMPLATES + SANE_SYSETTINGS + cp_and_log $TEMP_TEMPLATES/settings $TEMPLATES/ + cp_and_log /new_boot/etc/systemconfig /etc/systemconfig + cp_and_log /new_boot/etc /tmp/etc + cp_and_log /new_boot/var/lib/oss /tmp/oss + [ -e /tmp/etc/mdadm.conf ] && cp_and_log /tmp/etc/mdadm.conf /etc/ + + $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings -h $MVHOSTNAME -d 127.0.0.1 + else + cp_and_log /new_boot/etc /tmp/etc + [ -e /tmp/etc/mdadm.conf ] && cp_and_log /tmp/etc/mdadm.conf /etc/ + #now we search for the timezone and try to update + TZREGION=`cat /tmp/etc/timezone | cut -d"/" -f1` + TZSUB=`cat /tmp/etc/timezone | cut -d"/" -f2 -` + + + if [ $TZREGION = $TZSUB ] + then + $run update_db_it HostTimeZoneRegion "$TZREGION" + else + $run update_db_it HostTimeZoneRegion "$TZREGION" + $run update_db_it HostTimeZoneRegion_$TZREGION "$TZSUB" + fi + fi + backup_sql_check + echo $? + upgrade_mount_search + echo $? + $run umount_it $disk + fi + ;; + + upgrade_it) + upgrade + ;; + disk_model_it) + model="unknown" + size="xxx" + case $2 in + + h* ) + model=`cat /proc/ide/$2/model` + ;; + s*) model=`sginfo /dev/$2|grep Product|awk ' { print $2 } '` + ;; + esac + size=`parted /dev/$2 print |grep Disk|awk ' { print $3 } ' ` + echo ""$model" $size " >/tmp/model + ;; + network_check_it) + #Should never return from check_network + case $2 in + setup_network) + vnc_check + install_network_setup + ;; + + check_self) + myipdefault=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'` + echo "network check myself" + ifconfig + ping -c 1 $myipdefault + if [ ! $? = 0 ] + then + exit 3 + #can't ping yourself + fi + ;; + check_gw) + #check gateway + echo "network check gateway" + /sbin/route -n + mygwdefault=`/sbin/route -n |grep $default_interface|grep UG|awk '{ print $2}'` + echo "Default gateway seems to be $mygwdefault" + if [ ! x$mygwdefault = x ] + then + sleep 2 + ping -c 5 $mygwdefault + if [ ! $? = 0 ] + then + exit 4 + fi + fi + ;; + check_ns) + #check nameserver + echo " network check nameserver" + mydns=`cat /etc/resolv.conf|grep nameserver|head -1|awk '{ print $2}'` + ping -c 1 $mydns + if [ ! $? = 0 ] + then + exit 5 + fi + ;; + check_names) + echo "network check resolve names" + host google.com + if [ ! $? = 0 ] + then + exit 6 + fi + ;; + host_names) + #if host is found, then check to see if it's online + #if hoip matchs my ip assume it's ok + echo "network check my hostname $hostname" + hout=`host $hostname` + status=$? + #found host, now grab the ip + if [ $status = 0 ] + then + hoip=`echo $hout|awk '{print $4}'` + /sbin/ifconfig -a |grep -q $hoip + if [ $? = 0 ] + then + echo "DNS ip matches on of my ips" + status=0 + else + echo "IP in DNS but doesn't match mine, hostname is not safe to use" + status=7 + fi + else + echo "Couldn't find hostname in DNS, must be safe to use" + status=0 + fi + exit $status + ;; + + esac + exit 0 + ;; + + + * ) + if [ -f /tmp/.install_state ] + then + state=`cat /tmp/.install_state` + else + state=" " + fi + if [ x"${state}" = "xConfiguring system" ] + then + progress "" + else + + if [ -f /tmp/.startsize.io ] + then + . /tmp/.startsize.io + #finding the drive + ddrive=`df | grep $mountpoint | head -n1 | awk -F/ ' { print $3 } ' | cut -d" " -f 1|cut -b1,2,3 ` + used=`statgrab -M disk.|grep ${ddrive}.write_bytes|cut -d= -f 2|tr -d " "` + used=`echo $used-$STARTSIZE|bc` + #echo $used + fi + + if [ ! x$used = x ] + then + . /root/.install_size + #somehow find if it's an install or update + if [ -f /tmp/.this_is_upgrade ] + then + total=$UPGRADESIZE + else + total=$TOTALSIZE + fi + percent=`echo "scale=2 ; ($used/$total) * 100 " |bc ` + cond2=$(echo "$percent > 98" |bc ) + if [ $cond2 -eq 1 ] + then + percent=98 + fi + cond3=$(echo "$percent < 3" |bc ) + if [ $cond3 -eq 0 ] + then + progress $percent + fi + fi + fi + ;; +esac + + + diff --git a/abs/core/LinHES-config-svn/issue b/abs/core/LinHES-config-svn/issue new file mode 100644 index 0000000..3c01679 --- /dev/null +++ b/abs/core/LinHES-config-svn/issue @@ -0,0 +1 @@ +LinHes
\ No newline at end of file diff --git a/abs/core/LinHES-config-svn/live-install.sh b/abs/core/LinHES-config-svn/live-install.sh new file mode 100755 index 0000000..573bb1f --- /dev/null +++ b/abs/core/LinHES-config-svn/live-install.sh @@ -0,0 +1,28 @@ +#!/bin/bash +#redirect stderr to stdout, then rediret stdout to file +. /etc/profile +exec 2>&1 +exec > /tmp/mythvantage_install.log +. /etc/X11/STBWINDOWMANAGER +/usr/bin/nvidia-settings -a InitialPixmapPlacement=2 +keylaunch & +/usr/bin/tilda & +/usr/X11R6/bin/unclutter -root -idle 0 -jitter 400 -noevents & +export MALLOC_CHECK_=0 +if [ -f /opt/vmware/bin32/vmware-user-wrapper ] +then + /opt/vmware/bin32/vmware-user-wrapper & +fi +xhost + +CMDLINE=$(cat /proc/cmdline) +echo $CMDLINE |grep -q nfsroot +NFSROOT=$? +if [ x$NFSROOT = x1 ] +then + + unbuffer MythVantage & +else + NETBOOT=YES MythVantage & +fi + +exec $STBWINDOWMANAGER diff --git a/abs/core/LinHES-config-svn/myth_user_call b/abs/core/LinHES-config-svn/myth_user_call new file mode 100644 index 0000000..0479895 --- /dev/null +++ b/abs/core/LinHES-config-svn/myth_user_call @@ -0,0 +1,172 @@ +#!/bin/bash +#Wrapper script to manage USERNAME accounts + web security +# myth_USERNAME_all -c add -u USERNAME +# myth_USERNAME_all -c delete -u USERNAME +# myth_USERNAME_all -c pass -u USERNAME -p pass +# myth_USERNAME_all -c web -u USERNAME -p pass + +INIT_CHECK=TRUE +FULL_CALL="$@" +function CHROOT_CHECK { + INIT=`ps -p 1 -o comm=` + if [ x$INIT = xrunit ] + then + CHROOT_NEEDED=FALSE + else + CHROOT_NEEDED=TRUE + fi +} + +function store_commands () { + echo "$FULL_CALL" >> /root/myth_user_call.out + chmod 600 /root/myth_user_call.out +} + + +function add_user() { + if [ $CHROOT_NEEDED = TRUE ] + then + echo "calling myth_call_user in chroot to add user" + store_commands + else + echo "adding user $USERNAME" + useradd -m -s /bin/bash $USERNAME -G audio,video,optical,storage,users + fi + +} + + +function del_user() { + if [ $CHROOT_NEEDED = TRUE ] + then + echo "calling myth_call_user in chroot to delete user" + store_commands + else + echo "removing user $USERNAME" + userdel $USERNAME + fi + +} + + +function pass_change() { + if [ $CHROOT_NEEDED = TRUE ] + then + echo "calling myth_call_user in chroot to change password" + store_commands + else + echo "changing password for $USERNAME" + echo $USERNAME:$PASSWORD | chpasswd + fi + +} + + +function web_security { + + grep -q ${USERNAME}: /etc/lighttpd/lighttpd.user + if [ $? = 0 ] + then + #delete user + sed -i "/${USERNAME}\:/d" /etc/lighttpd/lighttpd.user + fi + echo "${USERNAME}:${PASSWORD}" >> /etc/lighttpd/lighttpd.user + +} + +function ARG_ERR() { + if [ x$OPTARG = "x" ] + then + echo "$SWITCH NEEDS AND ARG" + exit 11 + fi +} + + +function print_help { + + echo "Valid options are:" + echo " -c (add|delete|pass|web)" + echo " -u USERNAMEname" + echo " -p password" + exit 1 +} + +if [ $# -eq 0 ] +then + print_help +fi + +declare -r OPTSTRING="c:u:p:i" +while getopts "$OPTSTRING" SWITCH +do + case $SWITCH in + + c) ARG_ERR + OPERATION=$OPTARG + ;; + u) ARG_ERR + USERNAME=$OPTARG + ;; + p) ARG_ERR + PASSWORD=$OPTARG + ;; + i) INIT_CHECK=FALSE + + esac +done + +if [ $INIT_CHECK = TRUE ] +then + CHROOT_CHECK +else + CHROOT_NEEDED=FALSE +fi + +case $OPERATION in + add) + if [ x$USERNAME = x ] + then + print_help + fi + add_user + ;; + delete) + if [ x$USERNAME = x ] + then + print_help + fi + del_user + ;; + pass) + if [ x$USERNAME = x ] + then + print_help + fi + + if [ x$PASSWORD = x ] + then + print_help + fi + pass_change + ;; + + web) + if [ x$USERNAME = x ] + then + print_help + fi + + + if [ x$PASSWORD = x ] + then + print_help + fi + echo "adding webUSERNAME $USERNAME with pass $PASSWORD" + web_security + ;; + *) print_help + ;; +esac + + diff --git a/abs/core/LinHES-config-svn/networkconfig.sh b/abs/core/LinHES-config-svn/networkconfig.sh new file mode 100644 index 0000000..38b819a --- /dev/null +++ b/abs/core/LinHES-config-svn/networkconfig.sh @@ -0,0 +1,331 @@ +#!/bin/bash +#. /etc/profile +#. /etc/systemconfig +#BASE=/tmp +ETCNETDIR=$BASE/etc/net/ifaces + + + +function kill_dhcp () +{ +#for i in ${BASE}/etc/dhcpc/dhcpcd-*.pid +for i in ${BASE}/var/run/dhcpcd-*.pid +do + if [ -f ${i} ] + then + pid=`cat ${i}` + kill -9 $pid + rm -f ${i} + fi + if [ x$1 = xflush ] + then + for ifdev in eth0 wlan0 eth1 wlan1 + do + echo ${i} |grep $ifdev + status=$? + if [ $status = 1 ] + then + ip address flush $ifdev + fi + done + fi + +done + +} + +function kill_dhcp_chroot () +{ +#for i in ${BASE}/etc/dhcpc/dhcpcd-*.pid +for i in ${mountpoint}/var/run/dhcpcd-*.pid +do + if [ -f ${i} ] + then + pid=`cat ${i}` + kill -9 $pid + rm -f ${i} + fi +done + +} + + + +function setup_nameserver(){ +grep -q $1 ${BASE}/etc/resolv.conf +status=$? +if [ ! $status = 0 ] +then + echo "nameserver $1" >> ${BASE}/etc/resolv.conf +fi + +} + +function change_iface_state () { + if [ x$2 = xenabled ] + then + echo "setting $1 to active" + sed -i -e 's/^ONBOOT=.*$/ONBOOT=yes/g' $ETCNETDIR/$1/options + sed -i -e 's/^DISABLED=.*$/DISABLED=no/g' $ETCNETDIR/$1/options + else + echo "setting $1 to inactive" + if [ -e $ETCNETDIR/$1/options ] + then + sed -i -e 's/^ONBOOT=.*$/ONBOOT=no/g' $ETCNETDIR/$1/options + sed -i -e 's/^DISABLED=.*$/DISABLED=yes/g' $ETCNETDIR/$1/options + fi + /sbin/ifconfig $1 down + ip address flush $1 + fi + +} + +function setup_interfaces() { + local IS_WIRELESS + local ip + local netmask + local isactive + local dns + local UseDHCP + local GW + local ESSID + local KEY + local ENCRYPT + local TEMPNET + IS_WIRELESS=false + + #local ip + TEMPNET="Hostip"$1 + echo $TEMPNET + eval ip=\$${TEMPNET} + + TEMPNET=Hostnetmask$1 + eval netmask=\$${TEMPNET} + netmask=`echo "$netmask" | cut -d " " -f1` + + TEMPNET=HostActive$1 + eval isactive=\$${TEMPNET} + + TEMPNET=HostDNS$1 + eval dns=\$${TEMPNET} + + TEMPNET="HostUSEDHCP"$1 + eval UseDHCP=\$${TEMPNET} + + TEMPNET=HostGW$1 + eval GW=\$${TEMPNET} + + TEMPNET=HOST_iswireless$1 + eval wireless=\$${TEMPNET} + + + + + if [ x$wireless = x1 ] + then + IS_WIRELESS=TRUE + TEMPNET=HostESSID$1 + eval ESSID=\$${TEMPNET} + + TEMPNET="HostKey"$1 + eval KEY=\$${TEMPNET} + + TEMPNET=HostUseEncryption$1 + eval ENCRYPT=\$${TEMPNET} + fi + + + echo "Setup $1 in progress, wireless: $IS_WIRELESS" + + if [ ! -d $ETCNETDIR/$1 ] + then + mkdir -p $ETCNETDIR/$1 + fi + + if [ ! -f $ETCNETDIR/$1/options ] + then + cp -f $TEMPLATES/etcnet/eth/options $ETCNETDIR/$1/options + fi + + if [ x$isactive = x1 ] + then + change_iface_state $1 enabled + #echo "setting $1 to active" + #sed -i -e 's/^ONBOOT=.*$/ONBOOT=yes/g' $ETCNETDIR/$1/options + #sed -i -e 's/^DISABLED=.*$/DISABLED=no/g' $ETCNETDIR/$1/options + else + change_iface_state $1 disabled + #echo "setting $1 to inactive" + #sed -i -e 's/^ONBOOT=.*$/ONBOOT=no/g' $ETCNETDIR/$1/options + #sed -i -e 's/^DISABLED=.*$/DISABLED=yes/g' $ETCNETDIR/$1/options + fi + + if [ x$IS_WIRELESS = xTRUE ] + then + echo "setting $1 wireless" + sed -i -e 's/^CONFIG_WIRELESS=.*$/CONFIG_WIRLESS=yes/g' $ETCNETDIR/$1/options + #set the key and essid + echo "essid $ESSID" > $ETCNETDIR/$1/iwconfig + if [ x$ENCRYPT = x1 ] + then + echo "key $KEY" >> $ETCNETDIR/$1/iwconfig + fi + + else + echo "disabling wireless" + sed -i -e 's/^CONFIG_WIRLESS=.*$/CONFIG_WIRLESS=no/g' $ETCNETDIR/$1/options + fi + + + + + if [ x$UseDHCP = x0 ] + then + echo using dhcp + sed -i -e 's/^BOOTPROTO=.*$/BOOTPROTO=dhcp/g' $ETCNETDIR/$1/options + + else + echo "using static ip" + sed -i -e 's/^BOOTPROTO=.*$/BOOTPROTO=static/g' $ETCNETDIR/$1/options + echo "default via $GW" > $ETCNETDIR/$1/ipv4route + echo "$ip$netmask" > $ETCNETDIR/$1/ipv4address + setup_nameserver $dns + fi +} + + +function find_active () { +#HostActiveeth1="1" +rm -f ${BASE}/etc/resolv.conf +if [ x$MYTHDHCP = x1 ] + then + #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 + fi + +for i in eth0 eth1 wlan0 wlan1 +do + CURRENTIF="HostActive"$i + eval IFSTATE=\$${CURRENTIF} + echo $IFSTATE "---" + echo $i + if [ x$IFSTATE = x1 ] + then + setup_interfaces $i + else + change_iface_state $i disabled + fi +done + +} + +function setup_hostname { +#set the hostname +if [ ! x$hostname = x ] +then + echo $hostname > ${BASE}/etc/hostname + cat $BASE/etc/hosts |grep -v 127.0.0.1|grep -v $hostname > /tmp/hosts + #cat $BASE/etc/hosts |grep -v 127.0.0.1|grep -v $hostname | grep -v $ip > /tmp/hosts + + if [ x$MYTHDHCP = x1 ] + then + echo "127.0.0.1 localhost " > ${BASE}/etc/hosts + echo "$MYTHIP $hostname " >> ${BASE}/etc/hosts + else + echo "127.0.0.1 $hostname localhost " > ${BASE}/etc/hosts + fi + cat /tmp/hosts >> ${BASE}/etc/hosts +fi + +kill_dhcp +} + +function vnc_check() { + CMDLINE=$(cat /proc/cmdline) + echo $CMDLINE |grep -q vnc + USEVNC=$? + echo $CMDLINE |grep -q nfsroot + NETBOOT=$? + echo $USEVNC + if [ ! x$USEVNC = x0 ] + then + echo "not using vnc" + if [ ! x$NETBOOT = x0 ] + then + echo "not using netboot" + else + echo "using netboot" + USEVNC=0 + fi + + else + echo " using vnc" + fi +} + +function setup_MYTH_vars { + TEMPMYTH="Hostip"$default_interface + #echo $TEMPMYTH + eval MYTHIP=\$${TEMPMYTH} + + TEMPMYTH="HostUSEDHCP"$default_interface + eval MYTHDHCP=\$${TEMPMYTH} + + + +} + + + + +function start_network { +if [ ! $USEVNC = 0 ] +then + /etc/net/scripts/network.init reload + /etc/net/scripts/network.init restart +else + echo "VNC/NETBOOT in use, will NOT restart network" +fi + +} + +function setup_network { + setup_MYTH_vars + setup_hostname + find_active +} + + +function stop_network { +if [ ! $USEVNC = 0 ] +then + echo "stopping the network" + kill_dhcp flush + ip address flush dev eth0 2>&1 >/dev/null + ip address flush dev eth1 2>&1 >/dev/null + ip address flush dev wlan0 2>&1 >/dev/null + ip address flush dev wlan1 2>&1 >/dev/null +else + echo "VNC/NETBOOT in use, will NOT restart network" +fi + +} + + +#this is used by the install process to start the network +function install_network_setup { + setup_MYTH_vars + setup_hostname + stop_network + find_active + start_network + +} + + + + + + + diff --git a/abs/core/LinHES-config-svn/remove_service.sh b/abs/core/LinHES-config-svn/remove_service.sh new file mode 100755 index 0000000..6cc4b4f --- /dev/null +++ b/abs/core/LinHES-config-svn/remove_service.sh @@ -0,0 +1,8 @@ +#!/bin/bash +SERVICE_DIR=/var/service +SCRIPT_DIR=/etc/sv +if [ -e $SERVICE_DIR/$1 ] +then + echo "removing" + rm $SERVICE_DIR/$1 +fi diff --git a/abs/core/LinHES-config-svn/restore_default_settings.sh b/abs/core/LinHES-config-svn/restore_default_settings.sh new file mode 100755 index 0000000..dcf5e23 --- /dev/null +++ b/abs/core/LinHES-config-svn/restore_default_settings.sh @@ -0,0 +1,362 @@ +#!/bin/bash +. /etc/profile +. /etc/systemconfig +shopt -s -o nounset +echo $@ >> /tmp/restore.out +#TEMPLATES="/usr/share/templates/settings" +TEMPLATES="$TEMPLATES/settings" +TABLES="settings keybindings" +MYTHDBUSER=mythtv +MYTHTVPASSWD=mythtv +declare -r OPTSTRING="c:e:t:d:h:s:a:z:Ho" +Thistemplate="" +declare -i OVERRIDE=0 +declare -i EVERYTHING=0 + + +function CMD_DEFINE () { + #add override check + if [ x$Thistemplate = xsyssettings -a $OVERRIDE -eq 1 ] + then + MYSQLCMD="mysql --local-infile -s -u$MYTHDBUSER -p$MYTHTVPASSWD -h$ovdbhost mythconverg -B --exec" + MYSQLCMD_C="mysql -u$MYTHDBUSER -p$MYTHTVPASSWD -h$ovdbhost mythconverg -B --exec" + MYSQLCMD_UPDATE_HOST="UPDATE settings set data='$oldhostname' where value='HostMyhostname' and hostname=\"$hostname\";" + else + MYSQLCMD="mysql --local-infile -s -u$MYTHDBUSER -p$MYTHTVPASSWD -h$dbhost mythconverg -B --exec" + MYSQLCMD_C="mysql -u$MYTHDBUSER -p$MYTHTVPASSWD -h$dbhost mythconverg -B --exec" + MYSQLCMD_UPDATE_HOST="select hostname from settings;" + fi +} + +function SQL_DEFINE () { + thostname=`echo ${hostname}|tr -C [:alpha:] _` + echo "Using $thostname for temp table postfix" + + #$1 is the table name + if [ $1 = "settings" ] + then + ALTERSQL="Alter table temp_${1}_${thostname} add unique ( value )" + else + ALTERSQL=";" + fi + + CREATESQL="create table temp_${1}_${thostname} like $1;" + COPY_TMP_SQL="replace into temp_${1}_${thostname} (select * from $1 where hostname=\"$hostname\");" + INSERTSQL="LOAD DATA local INFILE '/tmp/$1.txt' REPLACE INTO TABLE temp_${1}_${thostname} FIELDS TERMINATED BY '\t';" + #INSERTSQL="LOAD DATA local INFILE '$TEMPLATES/$Thistemplate/$1.txt' REPLACE INTO TABLE temp_${1}_${hostname} FIELDS TERMINATED BY '\t';" + DROPSQL="delete from $1 where hostname=\"$hostname\";" + COPY_BCK_SQL="replace into $1 (select * from temp_${1}_${thostname} where hostname=\"$hostname\");" + DROP_TABLE="Drop table temp_${1}_${thostname}" +} + +function ARG_ERR() { + if [ x$OPTARG = "x" ] + then + echo "$SWITCH NEEDS AND ARG" + exit 11 + fi +} + +function ALSADEVICE () { +#ALSA:hw:1,4 + if [ x$Audiotype = xALSA ] + then + SoundDevice=ALSA:$SoundDevice + MixerDevice="ALSA:default" + else + MixerDevice="/dev/mixer" + fi + +} + + + +if [ $# -eq 0 ] +then + echo "Valid options are:" + echo " -c (save|restore|load|uhostname|BECONFIG|ZIP|ACCESSCONTROL)" + echo " -t (syssettings|hostsettings)" + echo " -d databasename" + echo " -h hostname" + echo " -s systemtype (master|slave|standalone|frontendonly)" + echo " -a ipaddress" + echo " -z zipcode" + echo " -o override (only used upgrade installs)" + exit 1 +fi + + + + +while getopts "$OPTSTRING" SWITCH +do + case $SWITCH in + # \?) echo "unkown option" + # exit 11 ;; + c) echo "$SWITCH" "$OPTARG" + ARG_ERR + OPERATION=$OPTARG + ;; + t) echo "$SWITCH" "$OPTARG" + ARG_ERR + Thistemplate=$OPTARG + + if [ x$Thistemplate = x"syssettings" ] + then + echo "template is syssettings" + loadhost=false + elif [ x$Thistemplate = x"hostsettings" ] + then + echo "template is hostsettings" + Thistemplate=syssettings + loadhost=true + else + echo "invalid template name" + exit 1 + fi + ;; + d) echo "$SWITCH" "$OPTARG" + ARG_ERR + if [ $OVERRIDE = 1 ] + then + ovdbhost=$OPTARG + else + dbhost=$OPTARG + fi + ;; + h) echo "$SWITCH" "$OPTARG" + ARG_ERR + if [ $OVERRIDE = 1 ] + then + oldhostname=$hostname + hostname=$OPTARG + else + hostname=$OPTARG + fi + + ;; + s) echo "$SWITCH" "$OPTARG" + ARG_ERR + SYSTEMTYPE=$OPTARG + ;; + a) echo "$SWITCH" "$OPTARG" + ARG_ERR + IP_ADDRESS=$OPTARG + ;; + z) echo "$SWITCH" "$OPTARG" + ARG_ERR + ZIPCODE=$OPTARG + ;; + o) OVERRIDE=1 + ;; + + esac +done + +echo $OVERRIDE + +#setup the Mysql commands +CMD_DEFINE + +$MYSQLCMD_C "show tables" > /dev/null +status=$? +if [ $status = 1 ] +then + echo "$@ failed" + echo "$@ failed" >> /tmp/restore.out + exit 1 +fi + + + + + + + +case $OPERATION in + + restore) + #used to restore settings from syssettings + if [ -d $TEMPLATES/$Thistemplate ] + then + cd $TEMPLATES/$Thistemplate + if [ $loadhost = false ] + then + for i in $TABLES + do + SQL_DEFINE $i + sed -e "s/REPLACEME/$hostname/g" $i.txt > /tmp/$i.txt + #echo $MYSQLCMD "$SELECTSQL" + echo $i + $MYSQLCMD "$CREATESQL" + $MYSQLCMD "$ALTERSQL" + $MYSQLCMD "$COPY_TMP_SQL" + $MYSQLCMD "$INSERTSQL" + $MYSQLCMD "$DROPSQL" + $MYSQLCMD "$COPY_BCK_SQL " + $MYSQLCMD "$DROP_TABLE " + #rm /tmp/$i.txt + done + fi + if [ $loadhost = true ] + then + #only load the settings table with values HOST + i=settings + SQL_DEFINE $i + sed -e "s/REPLACEME/$hostname/g" $i.txt > /tmp/$i.txt + echo $i + $MYSQLCMD "$CREATESQL" + $MYSQLCMD "$ALTERSQL" + $MYSQLCMD "$INSERTSQL" + $MYSQLCMD "$COPY_TMP_SQL" + $MYSQLCMD "$DROPSQL" + $MYSQLCMD "$COPY_BCK_SQL" + $MYSQLCMD "$DROP_TABLE " + fi + else + echo "couldn't find $TEMPLATES/$Thistemplate" + fi + ;; + + save) + + if [ ! -d $TEMPLATES/$Thistemplate ] + then + mkdir -p $TEMPLATES/$Thistemplate + fi + + cd $TEMPLATES/$Thistemplate + for i in $TABLES + do + EXTRACLAUSE="" + case $i in + settings) + EXTRACLAUSE="and not (value like \"BackendServerIP\") and not (value like \"locale\") order by value" + SQL="select value,data,'REPLACEME' as hostname from $i where hostname=\"$hostname\" "$EXTRACLAUSE" ;" + # SQL="select * from $i where hostname=\"$hostname\" "$EXTRACLAUSE" ;" + $MYSQLCMD_C "$SQL" > $TEMPLATES/$Thistemplate/$i.txt + ;; + keybindings) + SQL="select context,action,description,keylist,'REPLACEME' as hostname from $i where hostname=\"$hostname\" "$EXTRACLAUSE" ;" + $MYSQLCMD_C "$SQL" > $TEMPLATES/$Thistemplate/$i.txt + ;; + esac + # sed -e "s/$hostname/REPLACEME/g" $i > $i.txt && rm $i + + done + ;; + + load) + + #will load both default_1 and default_2 unless either file is not found + for i in default_1 default_2 + do + if [ -f $TEMPLATES/$i/settings.txt ] + then + echo $i + for tablename in $TABLES + do + #create table + CREATESQL="create table IF NOT EXISTS ${tablename}_${i} like $tablename;" + $MYSQLCMD_C "$CREATESQL" + #truncate table + TRUNCATESQL="truncate ${tablename}_${i} " + $MYSQLCMD_C "$TRUNCATESQL" + #load table + INSERTSQL="LOAD DATA local INFILE '$TEMPLATES/$i/$tablename.txt' REPLACE INTO TABLE ${tablename}_${i} FIELDS TERMINATED BY '\t';" + $MYSQLCMD_C "$INSERTSQL" + #update_hostname + UPDATEHOSTNAMESQL="update ${tablename}_${i} set hostname='$i' ; " + $MYSQLCMD_C "$UPDATEHOSTNAMESQL" + done + else + + echo "couldn't find $TEMPLATES/$i/settings.txt template to load" + fi + CREATESQL="create table IF NOT EXISTS settings_user1 like settings;" + $MYSQLCMD_C "$CREATESQL" + CREATESQL="create table IF NOT EXISTS settings_user2 like settings;" + $MYSQLCMD_C "$CREATESQL" + CREATESQL="create table IF NOT EXISTS settings_user3 like settings;" + $MYSQLCMD_C "$CREATESQL" + + CREATESQL="create table IF NOT EXISTS keybindings_user1 like keybindings;" + $MYSQLCMD_C "$CREATESQL" + CREATESQL="create table IF NOT EXISTS keybindings_user2 like keybindings;" + $MYSQLCMD_C "$CREATESQL" + CREATESQL="create table IF NOT EXISTS keybindings_user3 like keybindings;" + $MYSQLCMD_C "$CREATESQL" + done +;; + + + + BECONFIG) + if [ $SYSTEMTYPE = "master" ] + then + $MYSQLCMD_C "UPDATE settings set data='${IP_ADDRESS}' where value='MasterServerIP';" + $MYSQLCMD_C "delete from settings where value='BackendServerIP' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='${IP_ADDRESS}' , value='BackendServerIP' , hostname=\"$hostname\";" + fi + + if [ $SYSTEMTYPE = "slave" ] + then + $MYSQLCMD_C "delete from settings where value='BackendServerIP' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='${IP_ADDRESS}' , value='BackendServerIP' , hostname=\"$hostname\";" + fi + ;; + ZIP) + $MYSQLCMD_C "delete from settings where value='locale' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='$ZIPCODE' , value='locale' , hostname=\"$hostname\";" + $MYSQLCMD_C "delete from settings where value='MythMovies.ZipCode' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='$ZIPCODE', value='MythMovies.ZipCode' , hostname=\"$hostname\";" + ;; + MUSICFRONT) + ALSADEVICE + $MYSQLCMD_C "delete from settings where value='AudioOutputDevice' and hostname=\"$hostname\";" + $MYSQLCMD_C "delete from settings where value='MixerDevice' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='$SoundDevice', value='AudioOutputDevice' , hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='$MixerDevice', value='MixerDevice' , hostname=\"$hostname\";" + #need to reload the settings. + systemconfig.sh reloadfe + ;; + MUSICMYTH) + ALSADEVICE + $MYSQLCMD_C "delete from settings where value='MusicAudioDevice' and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='$SoundDevice', value='MusicAudioDevice' , hostname=\"$hostname\";" + ;; + uhostname) + #used when the hostname is changed. + TABLES="settings capturecard keybindings storagegroup recorded" + for i in $TABLES + do + USQL="update $i set hostname=\"$oldhostname\" where hostname=\"$hostname\" ;" + $MYSQLCMD_C "$USQL" + done + + ;; + USERJOBALLOW) + SQL="update settings set data='1' where value like 'JobAllowUserJob%' and hostname=\"$hostname\" ;" + $MYSQLCMD_C "$SQL" + ;; + + ACCESSCONTROL) + LIST="Hostaccessnetwork Hostaccesshostype HostaccesshostypeSystemtype Hostaccessmisc Hostaccesssleep Hostaccessadvanced HostaccessadvancedX Hostaccesssound" + + for i in $LIST + do + $MYSQLCMD_C "delete from settings where value=\"$i\" and hostname=\"$hostname\";" + $MYSQLCMD_C "REPLACE INTO settings set data='1', value=\"$i\" , hostname=\"$hostname\";" + done + SQL="update settings set data='0' where value='HostaccesshostypeSystemtype' and hostname=\"$hostname\" ;" + $MYSQLCMD_C "$SQL" + SQL="update settings set data='0' where value='Hostaccessuser' and hostname=\"$hostname\" ;" + $MYSQLCMD_C "$SQL" + ;; + esac + +#SELECT * INTO OUTFILE 'data.txt' +# FIELDS TERMINATED BY ',' +# FROM table2; + + diff --git a/abs/core/LinHES-config-svn/restore_km_db_chroot.sh b/abs/core/LinHES-config-svn/restore_km_db_chroot.sh new file mode 100644 index 0000000..e72e8c2 --- /dev/null +++ b/abs/core/LinHES-config-svn/restore_km_db_chroot.sh @@ -0,0 +1,61 @@ +#!/bin/bash +. /etc/profile +. /etc/systemconfig +. $MV_ROOT/bin/install_functions.sh + +myhost=$hostname +hostname $myhost +mount -t proc none /proc +DBFILE=$1 + +if [ $SystemType = "Master_backend" -o $SystemType = "Standalone" ] + then + #restore database + pacman --noconfirm -Sf mysql + status=1 + mysqlstatus=1 + while [ ! $status = 0 ] + do + /etc/rc.d/mysqld stop + sleep 1 + /etc/rc.d/mysqld start + mysqlstatus=$? + if [ $mysqlstatus = 0 ] + then + mysql -e "show databases;" + showstatus=$? + if [ $showstatus = 0 ] + then + #load database + pacman --noconfirm -R mythdb-initial + pacman --noconfirm -S mythdb-initial + + if [ -f $DBFILE ] + then + echo "restoring old database" + gunzip -c $DBFILE > /tmp/mythconverg.sql + mysql mythconverg < /tmp/mythconverg.sql + update_db_settings HostServiceMythWEB "1" + echo 'UseMythWEB="1"' >> /etc/systemconfig + else + echo "Could not restore old database, mythconverg.sql is missing." + touch /tmp/.upgrade_db_failed + fi + + if [ -d /data/srv/mysql/mythconverg ] + then + status=0 + fi + fi + fi + done + rm -f /tmp/mythconverg.sql + else + exit 0 + fi + +#/etc/rc.d/mysqld stop +#umount /proc + + + diff --git a/abs/core/LinHES-config-svn/soundconfig.sh b/abs/core/LinHES-config-svn/soundconfig.sh new file mode 100755 index 0000000..75998d6 --- /dev/null +++ b/abs/core/LinHES-config-svn/soundconfig.sh @@ -0,0 +1,254 @@ +#!/bin/bash +. /etc/systemconfig +. /etc/profile +echo $@ >/tmp/audio.call +#set -x +BASE="" +. /etc/profile +#TEMPLATES="/usr/share/templates" +#TESTFILE="$TEMPLATES/audio/space_battle_A.wav" +TESTFILE="/usr/share/sounds/alsa/Front_Center.wav" +OSSinstalled="false" + +function testaudio () { + +ossplay -d$AUDIODEVICE $TESTFILE + +} + +function load_alsa() { + + remove_service.sh alsa-utils +# cd /lib/modules/2.6.21-STB + KER=`uname -r` + cd /lib/modules/$KER/kernel/ + tar -xvf /lib/modules/alsa-$KER.tar + pacman -Sf --noconfirm alsa-lib + + depmod -a + cd - + udevadm trigger + udevadm settle + udevadm trigger + + add_service.sh alsa-utils + sleep 4 + sv start alsa-utils +} + + +function unload_alsa () { +#kill $(lsof -t /dev/dsp* /dev/audio* /dev/mixer* /dev/snd/*) && modprobe -r $(lsmod |grep ^snd |awk '{print $1}') + sv stop alsa-utils + remove_service.sh alsa-utils + rm -rf /dev/adsp* + rm -rf /dev/snd/* + rm -rf /dev/audio + modprobe -r $(lsmod |grep ^snd |awk '{print $1}') +} + +function unload_oss { + sv stop oss + soundoff + rm -rf /dev/dsp* + rm -rf /dev/oss* + rm -rf /dev/sndstat + remove_service.sh oss +} + +function installOSS { + echo "installing oss" + pacman -Q oss 2>/dev/null + if [ ! $? = 0 ] + then + pacman --noconfirm -Sf oss + fi + add_service.sh oss + sleep 4 + sv start oss +} + + +function SYNCXINE { +echo "modify xine config file" + if [ -f /data/home/mythtv/.xine/config ] + then + cp -f /data/home/mythtv/.xine/config $TEMPLATES/xine.config + else + cp $TEMPLATES/xine.config.template $TEMPLATES/xine.config + fi + + if [ x$Audiotype = xOSS ] + then + DEVICENUMBER=`echo $SoundDevice|awk -F/ ' { print $3 } '|tr -d dsp ` + sed -e "s/^.*audio.driver.*$/audio.driver:oss/" \ + -e "s/^.audio.device.oss_device_name.*$/audio.device.oss_device_name:\/dev\/dsp/" \ + -e "s/^.audio.devic.oss_device_number.*$/audio.device.oss_device_number:$DEVICENUMER/" \ + -e "s/^.*audio.output.speaker_arrangement:.*$/Audio.output.speaker_arrangement:PassThrough/" \ + $TEMPLATES/xine.config > /data/home/mythtv/.xine/config + else + cp $TEMPLATES/xine.config /data/home/mythtv/.xine/config + fi + +} + +function SYNCMPLAYER { +echo "modify mplayer not implmented yet" +} + +function SYNCMYTHMUSIC { +echo "sync mythmusic" +$MV_ROOT/bin/restore_default_settings.sh -c MUSICMYTH +} + +function SYNCMYTHFRONTEND { +echo "sync mythfrontend" +$MV_ROOT/bin/restore_default_settings.sh -c MUSICFRONT +} + + +function checkOSSinstalled () { + ossinfo |grep Version |grep -q OSS >/dev/null + resultcode=$? + echo $resultcode + if [ $resultcode = 0 ] + then + OSSinstalled='true' + else + OSSinstalled='false' + fi +} + +function sound_config_system { + + if [ x$syncXine = x1 ] + then + SYNCXINE + fi + if [ x$syncMplayer = x1 ] + then + SYNCMPLAYER + fi + if [ x$syncMythMusic = x1 ] + then + SYNCMYTHMUSIC + fi + if [ x$syncMythFrontend = x1 ] + then + SYNCMYTHFRONTEND + fi + +} + +function loadsound (){ + checkOSSinstalled + if [ x$AUDIOTYPE = xOSS -o x$AUDIOTYPE = xoss ] + #then + # if [ $OSSinstalled = "false" ] + then + while [ $OSSinstalled = "false" ] + do + unload_alsa + rm /tmp/.alsatest + installOSS + installOSS + sleep 2 + checkOSSinstalled + done + # fi + else + touch /tmp/.alsatest + unload_oss + load_alsa + load_alsa + rm /tmp/.alsatest + + fi + +} + + + + +#####################MAIN PROGRAM########################## + +declare -r OPTSTRING="i:t:d:" + +if [ $# -eq 0 ] +then + echo "Valid options are:" + echo " -i (oss|alsa) oss or alsa subsystem " + echo " -t (test|real|LOAD) " + echo " -d device" + exit 1 +fi + + + + +while getopts "$OPTSTRING" SWITCH +do + case $SWITCH in + \?) echo "unkown option" + exit 11 ;; + i) echo "$SWITCH" "$OPTARG" + AUDIOTYPE="$OPTARG" + ;; + d) echo "$SWITCH" "$OPTARG" + AUDIODEVICE=$OPTARG + ;; + t) echo "$SWITCH" "$OPTARG" + SOUNDOPTYPE="$OPTARG" + if [ x"$OPTARG" = xtest ] + then + TEST=true + else + TEST=false + fi + + + ;; + + esac +done + + + + +case $SOUNDOPTYPE in + REAL|real ) + loadsound + sound_config_system + ;; + test|TEST) + echo $@ > /tmp/audio.test + #loadsound + if [ x$AUDIOTYPE = xOSS -o x$AUDIOTYPE = xoss ] + then + echo "testing OSS $AUDIODEVICE " + ossplay -d$AUDIODEVICE $TESTFILE + else + echo "testing ALSA $AUDIODEVICE " + aplay --device=$AUDIODEVICE $TESTFILE + fi + + ;; + + LOAD|load) + loadsound + ;; + esac + + +exit 0 + + + + + + + + + + + diff --git a/abs/core/LinHES-config-svn/startx b/abs/core/LinHES-config-svn/startx new file mode 100755 index 0000000..0ffdf8c --- /dev/null +++ b/abs/core/LinHES-config-svn/startx @@ -0,0 +1,29 @@ +#!/bin/bash +. /etc/profile + +export USER=root +export HOME=/root +#TEMPLATES=/usr/share/templates + +CMDLINE=$(cat /proc/cmdline) +TEMPVAR=${CMDLINE#*ip=} +IP=${TEMPVAR%% *} +echo $CMDLINE |grep -q vnc +USEVNC=$? + +if [ x$USEVNC = x1 ] +then + $MV_ROOT/bin/xconfig.sh + cat /etc/X11/xorg.conf | sed -e 's/dev\/mouse/dev\/psaux/g'> /root/xorg.conf.install + startx /root/live-install.sh -- -config /root/xorg.conf.install -allowMouseOpenFail + else + #VNC + pacman -Sf --noconfirm tightvnc + cd /root + mkdir .vnc + echo mythvantage |vncpasswd -f > /root/.vnc/passwd + chmod 500 /root/.vnc/passwd + rm /root/.vnc/xstartup + ln -s /root/live-install.sh /root/.vnc/xstartup + vncserver +fi diff --git a/abs/core/LinHES-config-svn/systemconfig.sh b/abs/core/LinHES-config-svn/systemconfig.sh new file mode 100755 index 0000000..6d63f5c --- /dev/null +++ b/abs/core/LinHES-config-svn/systemconfig.sh @@ -0,0 +1,1368 @@ +#!/bin/bash +################################################################### +#Script to configure your system based off the values in /etc/systemconfig +#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 +. $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 + + # echo CLOCK="UTC" > ${BASE}/etc/conf.dclock + # echo CLOCK_SYSTOCH="yes" >> ${BASE}/etc/conf.d/clock + # echo TIMEZONE="$timezone" >> ${BASE}/etc/conf.d/clock +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 setupremote { + case $Remotetype in + no_remote) echo "No remote selected" + daemon_remove="lircd $daemon_remove" + ;; + tinker) echo "Remote in tinker mode" + ;; + *) echo "Setup remote" + mv ${BASE}/etc/lircd.conf ${BASE}/etc/lircd.conf.`date +%Y-%m-%d-%H-%M` + cd $TEMPLATES/remotes/$Remotetype + for i in lircd* + do + cat $i >> ${BASE}/etc/lircd.conf + done + cp -f lircrc* $BASE/etc/lircrc 2> /dev/null + if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ] + then + cat $TEMPLATES/LCD/$LCDtype/lircrc >> /etc/lircrc + cat $TEMPLATES/LCD/$LCDtype/lircd.conf >> /etc/lircd.conf + fi + if [ -f $TEMPLATES/transmit/$Blastertype/lircd.conf ] + then + cat $TEMPLATES/transmit/$Blastertype/lircd.conf >> ${BASE}/etc/lircd.conf + fi + chmod 755 /etc/lircrc + daemon_add="lircd $daemon_add" + sv hup lircd + + if [ ! -e /home/mythtv/.mythtv/lircrc ] + then + if [ ! -d /home/mythtv/.mythtv ] + then + mkdir /home/mythtv/.mythtv + chown mythtv:mythtv /home/mythtv/.mythtv + fi + + ln -s /etc/lircrc /home/mythtv/.mythtv/lircrc 2> /dev/null + fi + if [ ! -e /home/mythtv/.lircrc ] + then + + ln -s /etc/lircrc /home/mythtv/.lircrc 2> /dev/null + fi + + + ;; +esac + +} + +function setupblaster { + #cd $TEMPLATES/transmit/$Blastertype + #for i in lircd* + #do + # cat lircd.conf >> ${BASE}/etc/lircd.conf + #done + # REMOTE_NAME${BASE}/usr/bin/change_chan.sh=`grep name lircd.conf* |awk -F" " ' { print $2 } '` + sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > ${BASE}/usr/bin/change_chan.sh + chmod 755 ${BASE}/usr/bin/change_chan.sh + #channel change script change + setupremote + +} + +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_remove" + + ;; + esac + else + # disable evrouter + daemon_remove="evrouter Xvfb $daemon_remove" + fi + + + + +} + +function setupLCD { + case x$LCDtype in + xtinker) echo "do nothing" + ;; + xno_lcd) echo "disabling lcd" + sv down lcdd + load-modules-mythvantage.sh UNLOAD LCD + sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage + daemon_remove="lcdd $daemon_remove" + ;; + x) echo "empty lcd" ;; + + *) echo "setup lcd" + if [ -f $TEMPLATES/LCD/$LCDtype/modules ] + then + sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage + cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage + #should also modprobe + fi + + + if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ] + then + cp_and_log $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc + # install="lcdproc $install" + daemon_add="lcdd $daemon_add" + load-modules-mythvantage.sh + RESTART_FE="true" + RESTART_LCD="true" + fi + #check if lirc capable,if so then call setupremote + if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ] + then + setupremote + fi + ;; + esac + +} + + + +function scrubnfs { + cp_and_log /etc/fstab $TEMPLATES/fstab.conf.template + grep -v nfs $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab + } + +function setupfstab () { +# setupfstab $NFSserver $NFSshare $NFSmount + 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 + +} + +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 mythmovietime 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 ${BASE}/data/home/mythtv/templates/smb.conf ] + then + install -D -m755 ${BASE}/data/home/mythtv/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 nfslock 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 + + + + +#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 avahli" + 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 + +} + +#----------------------------------------------------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 + ;; + + this_is_install) MV_NEW_INSTALL="true" + ;; + + 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 +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 avahli portmap nfslock local-website $ser_install" + + + remove="none $ser_remove" + + daemon_add="mysql mythbackend avahi portmap nfslock 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 nfslock local-website myth2ipod mythtv-status $ser_install " + remove="$ser_remove" + + daemon_add="mysql mythbackend avahi portmap nfslock 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 nfslock $ser_install " + remove=" $ser_remove" + + daemon_add="mythbackend avahi portmap nfslock 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 nfslock avahi local-website $ser_install" + remove="mysql mythweb$postfix $ser_remove" + + daemon_add="avahi portmap nfslock 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 + #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 + + + +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 + diff --git a/abs/core/LinHES-config-svn/timezip.py b/abs/core/LinHES-config-svn/timezip.py new file mode 100755 index 0000000..31acd67 --- /dev/null +++ b/abs/core/LinHES-config-svn/timezip.py @@ -0,0 +1,231 @@ +#!/usr/bin/python +# import MySQL module +#used to import the zipcode/timezone/nfs info fromMBE +import MySQLdb +import sys +import getopt +import socket + + +def usage(): + print " -h --help" + print " -d --installdb" + print " -m --masterdb" + print " -n --hostname of current machine" + +def printvars(): + print "masterdb: " + masterdb + print "installdb:" + installdb + print "hostname: " + thishostname + print "BEhostname:" + BEhostname + print "zipcode:" + zipcode + print "timezone:" + tz + print "timezone region:" + tz_region + print "timezone subregion:" + tz_subregion + print "nfsip:" + nfsip + print "nfstoggle:" + nfstoggle + print "nfsmount:" + nfsmount + print "hobbitclient:" + hobbitclient +# connect +def selectvars(): + + global BEhostname + global zipcode + global tz + global tz_region + global tz_subregion + global nfsip + global nfstoggle + global nfsmount + global hobbitclient + + db = MySQLdb.connect(host=masterdb, user="mythtv", passwd="mythtv", db="mythconverg") + # create a cursor + cursor = db.cursor() + # execute SQL statement + cursor.execute("select hostname from settings where value='BackendServerIP' and data=(%s)",(masterdb)) + result = cursor.fetchone() + try: + BEhostname=result[0] + except TypeError: + BEhostname="" + + cursor.execute("select data from settings where value='HostZipcode' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + try: + zipcode = result[0] + except TypeError: + zipcode="" + + cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + try: + nfsip=result[0] + except TypeError: + nfsip="" + + cursor.execute("select data from settings where value='HostHaveCentralNFS' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + try: + nfstoggle=result[0] + except TypeError: + nfstoggle="" + + cursor.execute("select data from settings where value='HostNFSmountpoint' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + try: + nfsmount=result[0] + except TypeError: + nfsmount="" + + cursor.execute("select data from settings where value='HostTimeZone' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + try: + tz=result[0] + except TypeError: + tz="" +########## + cursor.execute("select data from settings where value='HostTimeZoneRegion' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + try: + tz_region=result[0] + except TypeError: + tz="" + tempsubregion="HostTimeZoneRegion_" + tz_region + + cursor.execute("select data from settings where value=%s and hostname=(%s)",(tempsubregion,BEhostname)) + result = cursor.fetchone() + try: + tz_subregion=result[0] + except TypeError: + tz_subregion="" +############### + if ( thishostname != BEhostname ): + cursor.execute("select data from settings where value='GlobalServiceHobbitserver'") + result = cursor.fetchone() + try: + hobbitclient=result[0] + except TypeError: + hobbitclient="1" + + + +def insertvars(): + + db = MySQLdb.connect(host=installdb, user="mythtv", passwd="mythtv", db="mythconverg") + cursor = db.cursor() +#inserting the zipcode + cursor.execute("select * from settings where value='HostZipcode' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if ( zipcode!="" ): + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostZipcode',(%s),(%s))",(zipcode,thishostname)) + print "inserting zipcode" + else: + cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostZipcode'",(zipcode,thishostname)) + print "updating zipcode" + +#inserting the timezone + cursor.execute("select * from settings where value='HostTimeZone' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if ( tz != ""): + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostTimeZone',(%s),(%s))",(tz,thishostname)) + print "inserting timezone" + else: + cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostTimeZone'",(tz,thishostname)) + print "updating timezone" + + cursor.execute("select * from settings where value='HostTimeZoneRegion' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if ( tz != ""): + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostTimeZoneRegion',(%s),(%s))",(tz_region,thishostname)) + print "inserting timezone region" + else: + cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostTimeZoneRegion'",(tz_region,thishostname)) + print "updating timezone region" + + tempsubregion="HostTimeZoneRegion_" + tz_region + cursor.execute("select * from settings where value=%s and hostname=(%s)",(tempsubregion,thishostname)) + result = cursor.fetchone() + if ( tz != ""): + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ((%s),(%s),(%s))",(tempsubregion,tz_subregion,thishostname)) + print "inserting timezone subregion" + else: + cursor.execute("update settings set data=(%s) where hostname=(%s) and value=(%s)",(tempsubregion,tz_subregion,thishostname)) + print "updating timezone subregion" + + +#start of NFSIP + cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if ( nfsip != ""): + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostCentralNFSIP',(%s),(%s))",(nfsip,thishostname)) + print "inserting nfsip" + + if (nfstoggle != ""): + cursor.execute("select data from settings where value='HostHaveCentralNFS' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostHaveCentralNFS',(%s),(%s))",(nfstoggle,thishostname)) + print "inserting nfstoggle" + + if ( nfsmount !="") : + cursor.execute("select data from settings where value='HostNFSmountpoint' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostNFSmountpoint',(%s),(%s))",(nfsmount,thishostname)) + print "inserting nfsmountpoint" + +#hobbitclient + cursor.execute("select * from settings where value='HostServiceHobbitclient' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if ( tz != ""): + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostServiceHobbitclient',(%s),(%s))",(hobbitclient,thishostname)) + print "inserting hobbitcleint" + else: + cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostServiceHobbitclient'",(hobbitclient,thishostname)) + print "updating hobbitclient" + + +def main(argv): + global masterdb + global installdb + global thishostname + thishostname="" + global BEhostname + global zipcode + global tz + global tz_region + global tz_subregion + + global nfsip + global hobbitclient + try: + opts, args = getopt.getopt(argv, "hm:d:n:", ["help", "masterdb=", "installdb=" , "hostname=" ] ) + except getopt.GetoptError: + sys.exit(2) + for opt, arg in opts: + if opt in ("-h", "--help"): + usage() + sys.exit() + elif opt in ( "-d" , "--installdb"): + installdb = arg + elif opt in ("-m", "--masterdb"): + masterdb = arg + elif opt in ("-n", "--hostname"): + thishostname = arg + + if ( thishostname == "" ): + thishostname = socket.gethostname() + + selectvars() + printvars() + insertvars() +if __name__ == "__main__": + main(sys.argv[1:]) + diff --git a/abs/core/LinHES-config-svn/timezone.bin b/abs/core/LinHES-config-svn/timezone.bin Binary files differnew file mode 100755 index 0000000..cff931a --- /dev/null +++ b/abs/core/LinHES-config-svn/timezone.bin diff --git a/abs/core/LinHES-config-svn/xconfig.sh b/abs/core/LinHES-config-svn/xconfig.sh new file mode 100755 index 0000000..e2a48ed --- /dev/null +++ b/abs/core/LinHES-config-svn/xconfig.sh @@ -0,0 +1,305 @@ +#!/bin/bash +#NVPKGS="ati-dri xf86-video-ati xf86-video-radeonhd intel-dri xf86-video-intel unichrome-dri xf86-video-unichrome xf86-video-mga xf86-video-savage xf86-video-trident" +NVPKGS="ati-dri xf86-video-ati xf86-video-radeonhd intel-dri xf86-video-intel xf86-video-mga xf86-video-savage xf86-video-trident" +BASE="" +. /etc/profile +NVIDIA_96XX="$TEMPLATES/xorg/96xx_supported.txt" +#TEMPLATES="/usr/share/templates" +MYTHHOME=$BASE/home/mythtv + +function Xvalues { + CMDLINE=$(cat /proc/cmdline) + echo "$CMDLINE" | grep -q forceXvesa + if [ $? = 0 ] + then + VGACARDTYPE=vesa + else + VGACARDTYPE=`lspci | grep -i vga | sort -r | head -n 1 | cut -d: -f3 | cut -d" " -f2` + VGAPCIID=`lspci | grep -i vga | sort -r | head -n 1 | cut -d" " -f1` + CARDID=`lspci -n | grep "$VGAPCIID" | grep 10de | cut -d" " -f3 | cut -d: -f2` + VENDORID=`lspci -n | grep "$VGAPCIID" | grep 10de | cut -d" " -f3 | cut -d: -f1` + fi + echo "$VGACARDTYPE" + currentmode=`cat "$BASE/etc/X11/xorg.conf" | grep Modes | awk -Fs '{ print $2 }'` +} + +function presetupX { + if [ -f /etc/sysconfig/IGNORE_X ] + then + echo "Will not run xconfig.sh due to presence of /etc/sysconfig/IGNORE_X" + return 1 + else + if [ "$XIgnoreConfig" = 1 ] + then + echo "Using User supplied X" + if [ -f "$MYTHHOME/templates/xorg.user" ] + then + cp -f "$MYTHHOME/templates/xorg.user" "$XORG_CONF" + else + echo "Didn't find the file" + echo "Copy your config file to $MYTHHOME/templates/xorg.user" > "$XORG_CONF" + fi + else + if [ "$XUseAdvanced" = 1 ] + then + setupAdvancedX + else + setupX + fi + fi + fi + +} + +function setupAdvancedX { + echo "#doing the advanced" > /tmp/options + Xcategory=`echo "$Xresadvanced" | cut -d_ -f1` + Xres=`echo "$Xresadvanced" | cut -d_ -f2` + echo "$Xcategory" + if [ "$Xcategory" = "Nvidia" ] + then + Xres="" + if [ "$XnVidia1080p" = "1" ] + then + Xres="${Xres} \"1920x1080_60\"" + fi + if [ "$XnVidia1080i" = "1" ] + then + Xres="${Xres} \"1920x1080_60i\"" + fi + if [ "$XnVidia720p" = "1" ] + then + Xres="${Xres} \"1280x720_60\"" + fi + if [ "$XnVidia480p" = "1" ] + then + Xres="${Xres} \"720x480_60\"" + fi + ML="\t Modes ${Xres}" + else + + ML="\t Modes \"${Xres}\"" + fi +# echo $ML + case $Xcardtype in + NVIDIA|nVidia) + case $Xconnection in + DVI) ConnectedMonitor=DFP ;; + vga) ConnectedMonitor=CRT;; + Auto) ConnectedMonitor=Auto;; + TV) ConnectedMonitor=TV + echo "Option \"TVStandard\" \"$XTVstandard\"" >>/tmp/options + echo "Option \"TVOutFormat\" \"$XTVconnection\"" >> /tmp/options + ;; + esac + if [ "$ConnectedMonitor" = Auto ] + then + echo "auto connection" + else + echo "Option \"ConnectedMonitor\" \"$ConnectedMonitor\"" >> /tmp/options + echo "Option \"FlatPanelProperties\" \"Scaling = centered, Dithering = enabled\"" >> /tmp/options + echo "Option \"DigitalVibrance\" \"0\"" >> /tmp/options + fi + + if [ "$XignoreEDID" = 1 ] + then + EDIDvalue=true + EDIDFREQ=false + DS=" DisplaySize $XDisplaysize" + HS=" HorizSync $XHsync" + VR=" VertRefresh $XVrefresh" + else + EDIDvalue=false + EDIDFREQ=true + DS="# Display size edid used " + HS="# Hsync edid used " + VR="# Vertrefresh edid used " + fi + echo "Option \"UseEdidFreqs\" \"$EDIDFREQ\"" >> /tmp/options + echo "Option \"IgnoreEDID\" \"$EDIDvalue\"" >> /tmp/options + + + sed -e "s/^.*Modes.*$/${ML}/" \ + -e "/INSERT MODELINE/r $TEMPLATES/xorg/modeline.$Xcategory" \ + -e "s/^.*DisplaySize.*$/ $DS/" \ + -e "s/^#.*HorizSync.*$/ $HS/g" \ + -e "s/^#.*VertRefresh.*$/ $VR/g" \ + -e "/INSERT HERE/r /tmp/options" "$TEMPLATES/xorg/xorg.conf.nvidia" > "$XORG_CONF" + ;; + + ati|ATI) + case $Xconnection in + DVI) ConnectedMonitor="tmds1,nocrt1,notv";; + VGA) ConnectedMonitor="crt1,notmds1,notv" ;; + TV) ConnectedMonitor="tv,nocrt1,notmds1" + echo "Option \"TVStandard\" \"$XTVstandard\"" >>/tmp/options + echo "Option \"TVFormat\" \"$XTVconnection\"" >> /tmp/options + ;; + esac + if [ "$XignoreEDID" = 1 ] + then + DS=" DisplaySize $XDisplaysize" + HS=" HorizSync $XHsync" + VR=" VertRefresh $XVrefresh" + else + DS="# Display size edid used " + HS="# Hsync edid used " + VR="# Vertrefresh edid used " + fi + + echo "Option \"ForceMonitors\" \"$ConnectedMonitor\"" >> /tmp/options + + sed -e "s/^.*Modes.*$/\t $ML/" \ + -e "/INSERT MODELINE/r $TEMPLATES/xorg/modeline.$Xcategory" \ + -e "s/^.*DisplaySize.*$/ $DS/" \ + -e "s/^#.*HorizSync.*$/ $HS/g" \ + -e "s/^#.*VertRefresh.*$/ $VR/g" \ + -e "/INSERT HERE/r /tmp/options" "$TEMPLATES/xorg/xorg.conf.ati" > "$XORG_CONF" + ;; + + via|VIA|Via|S3) + # Need to add appropriate Modules, Device and DRI sections + # See the http://www.mythtv.org/wiki/XvMC wiki page + echo "no via here" + ;; + + *) + echo "unknown card type" + ;; + esac +} + + +function setupX { + Xvalues + #echo "$currentmode ____ ${Xres}" + #if [ "${currentmode}" != \"${Xres}\" ] + if [ x = x ] + then + case $VGACARDTYPE in + nVidia) + sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.nvidia" > "$XORG_CONF" + if [ "$TESTMODE" != "test" ] + then + #nvidia check right here + grep -qi "$CARDID" "$NVIDIA_96XX" + if [ $? = 0 ] + then + #install 96xx drivers + echo "installing nvidia 96xx drivers" + pacman --noconfirm -R $NVPKGS > /dev/null 2>&1 + pacman --noconfirm -S nvidia-96xx nvidia-96xx-utils > /dev/null 2>&1 + else + #install latest drivers + echo "installing current nvidia drivers" + pacman --noconfirm -R $NVPKGS > /dev/null 2>&1 + pacman --noconfirm -S nvidia nvidia-utils > /dev/null 2>&1 + fi + fi + echo "/usr/lib/libXvMCNVIDIA_dynamic.so.1" > "$XVMC_CONFIG" + ;; + + # VMware) + # sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.vmware" > "$XORG_CONF" + # ;; + + VIA|S3) + # There are actually multiple options here + # xf86-video-openchrome + # xf86-video-unichrome + # There is also a seperate driver for the Unichrome Pro + sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.via" > "$XORG_CONF" + if [ "$TESTMODE" != "test" ] + then + if [ "$OPENCHROME" = "1" ] + then + pacman --noconfirm -R nvidia nvidia-utils > /dev/null 2>&1 + pacman --noconfirm -S libgl unichrome-dri xf86-video-openchrome > /dev/null 2>&1 + else + pacman --noconfirm -R nvidia nvidia-utils > /dev/null 2>&1 + pacman --noconfirm -S libgl unichrome-dri xf86-video-unichrome > /dev/null 2>&1 + fi + fi + # I'm making educated guesses here... + if lspci | grep "VGA" | grep -qi "Unichrome Pro" + then + if [ -f "/usr/lib/libchromeXvMCPro.so.1" ] + then + echo "/usr/lib/libchromeXvMCPro.so.1" > "$XVMC_CONFIG" + else + echo "/usr/lib/libviaXvMCPro.so.1" > "$XVMC_CONFIG" + fi + else + if [ -f "/usr/lib/libchromeXvMC.so.1" ] + then + echo "/usr/lib/libchromeXvMC.so.1" > "$XVMC_CONFIG" + else + echo "/usr/lib/libviaXvMC.so.1" > "$XVMC_CONFIG" + fi + fi + ;; + + Intel) + sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.intel" > "$XORG_CONF" + if [ "$TESTMODE" != "test" ] + then + pacman --noconfirm -R nvidia-utils > /dev/null 2>&1 + pacman --noconfirm -S libgl > /dev/null 2>&1 + fi + echo "/usr/lib/libIntelXvMC.so.1" > "$XVMC_CONFIG" + ;; + + vesa|InnoTek) + sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.vesa" > "$XORG_CONF" + ;; + + *) + XCONF=/root/xorg.conf.new + XCONFB=/etc/X11/xorg.conf.install + X -configure + if [ -f "$XCONF" ] + then + echo "Using $XCONF" + grep -v Modes "$XCONF" | sed -e "/Depth.*16/a Modes \"${Xres}\" " -e "/Depth.*24/a Modes \"${Xres}\"" -e 's/dev\/mouse/dev\/psaux/g'> "$XORG_CONF" + elif [ -f "$XCONFB" ] + then + echo "Using $XCONFB" + sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$XCONFB" > "$XORG_CONF" + else + echo "Xorg configuration failed" + fi + rm -f "$XCONF" 2>&1 > /dev/null + ;; + esac + fi + +} + +#MAIN +TESTMODE="$1" +if [ "$TESTMODE" = "test" ] +then + XORG_CONF="/tmp/xorg.conf.test" + XVMC_CONFIG="/tmp/XvMCConfig.test" + XUseAdvanced="1" + XIgnoreConfig="${2}" + Xcardtype="${3}" + XIgnoreEDID="${4}" + Xconnection="${5}" + XHsync="${6}" + XVrefresh="${7}" + Xresadvanced="${8}" + XTVstandard="${9}" + XTVconnection="${10}" + XDisplaysize="${11}" +else + if [ -f /etc/systemconfig ] + then + . /etc/systemconfig + else + Xres="800x600" + fi + XORG_CONF="/etc/X11/xorg.conf" + XVMC_CONFIG="/etc/X11/XvMCConfig" +fi +presetupX |