From 53247f3bab6eb7210e1dc9a10c8f2b5cebefcd54 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 7 Jan 2009 20:05:59 -0600 Subject: correct minor typo in mythvantage.app --- abs/core-testing/LinHES-config/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index 1058a17..c0eaf2b 100755 --- a/abs/core-testing/LinHES-config/PKGBUILD +++ b/abs/core-testing/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=1.0 -pkgrel=148 +pkgrel=149 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 ) -- cgit v0.12 From 99d3b01af539881a92ff4ae8a1fda0dbfc7cfaa7 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 7 Jan 2009 21:25:11 -0600 Subject: Remove writing boot sector from the progress log. Also stop the Progress dialog from ever reaching 100% complete. closes FS#78 --- abs/core-testing/LinHES-config/PKGBUILD | 2 +- abs/core-testing/LinHES-config/install_proxy.sh | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index c0eaf2b..44cb38a 100755 --- a/abs/core-testing/LinHES-config/PKGBUILD +++ b/abs/core-testing/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=1.0 -pkgrel=149 +pkgrel=152 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 ) diff --git a/abs/core-testing/LinHES-config/install_proxy.sh b/abs/core-testing/LinHES-config/install_proxy.sh index 8462e9c..e29417e 100755 --- a/abs/core-testing/LinHES-config/install_proxy.sh +++ b/abs/core-testing/LinHES-config/install_proxy.sh @@ -124,14 +124,15 @@ full_install () { $run copy_it $disk ALL rm $mountpoint/etc/fstab $run fstab_fix_it $disk $rootfs $datafs FULL_INSTALL - - progress 99 + echo "Configuring system" > /tmp/.install_state + progress 100 + #progress 99 sleep 1 $run grub_it $disk - echo "Configuring system" > /tmp/.install_state - progress 100 + #echo "Configuring system" > /tmp/.install_state + #progress 100 sleep 1 cp_and_log /etc/systemconfig "$mountpoint"/etc #run save syssettings to save settings, then copy to new mountpoint @@ -264,13 +265,14 @@ function upgrade () { #this is here to copy in the systemconfig file as soon as possible. cp_and_log /etc/systemconfig "$mountpoint"/etc/systemconfig - - echo "Writing boot sector" > /tmp/.install_state - progress 99 + echo "Configuring system" > /tmp/.install_state + progress 100 + #echo "Writing boot sector" > /tmp/.install_state + #progress 99 sleep 1 $run grub_it $disk - echo "Configuring system" > /tmp/.install_state - progress + #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 @@ -602,10 +604,10 @@ echo "-----------------------------------------------------------------------3-- total=$TOTALSIZE fi percent=`echo "scale=2 ; ($used/$total) * 100 " |bc ` - cond2=$(echo "$percent > 100" |bc ) + cond2=$(echo "$percent > 98" |bc ) if [ $cond2 -eq 1 ] then - percent=100 + percent=98 fi cond3=$(echo "$percent < 3" |bc ) if [ $cond3 -eq 0 ] -- cgit v0.12 From 6eb0dfa50945f3af9d2da2171b43e71a32600cd2 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 7 Jan 2009 21:32:23 -0600 Subject: fix the upgrade process as well. --- abs/core-testing/LinHES-config/PKGBUILD | 2 +- abs/core-testing/LinHES-config/install_proxy.sh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index 44cb38a..1e2ede9 100755 --- a/abs/core-testing/LinHES-config/PKGBUILD +++ b/abs/core-testing/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=1.0 -pkgrel=152 +pkgrel=153 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 ) diff --git a/abs/core-testing/LinHES-config/install_proxy.sh b/abs/core-testing/LinHES-config/install_proxy.sh index e29417e..670238b 100755 --- a/abs/core-testing/LinHES-config/install_proxy.sh +++ b/abs/core-testing/LinHES-config/install_proxy.sh @@ -261,12 +261,13 @@ function upgrade () { then rootfs=`grep \/\ /tmp/etc/fstab |awk ' { print $3 } '` fi - $run fstab_fix_it $disk UPGRADE - - #this is here to copy in the systemconfig file as soon as possible. + #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 + $run fstab_fix_it $disk UPGRADE + + #echo "Writing boot sector" > /tmp/.install_state #progress 99 sleep 1 -- cgit v0.12 From 8aaf1c6cb3aca9ee0c95b9b5464c6fa40587e56b Mon Sep 17 00:00:00 2001 From: James Meyer Date: Thu, 8 Jan 2009 11:14:10 -0600 Subject: new mythvantage.app that places locks around the install buttons. This will prevent to installs from running at the same time. closes FS#81 --- abs/core-testing/LinHES-config/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index 1e2ede9..aac97cc 100755 --- a/abs/core-testing/LinHES-config/PKGBUILD +++ b/abs/core-testing/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=1.0 -pkgrel=153 +pkgrel=154 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 ) -- cgit v0.12 From eb00fec42b6ccd143a145c89fff284969aa738be Mon Sep 17 00:00:00 2001 From: Tom Culliton Date: Sat, 10 Jan 2009 20:55:28 -0500 Subject: Updates to make the backup and restore scripts work for Arch Linux and be more portable in general. Also use the library facilities for checking on the existence of prerequisites. --- abs/core-testing/LinHES-system/bin/backupcommon | 143 ++++++++++++++------- abs/core-testing/LinHES-system/bin/checkbackup | 2 +- abs/core-testing/LinHES-system/bin/checkrestore | 2 +- abs/core-testing/LinHES-system/bin/library.sh | 164 ++++++++++++++++++++++++ abs/core-testing/LinHES-system/bin/mythbackup | 30 ++--- abs/core-testing/LinHES-system/bin/mythrestore | 22 ++-- abs/core-testing/LinHES-system/bin/rollback.sh | 20 +++ 7 files changed, 310 insertions(+), 73 deletions(-) mode change 100755 => 100644 abs/core-testing/LinHES-system/bin/backupcommon create mode 100755 abs/core-testing/LinHES-system/bin/library.sh create mode 100755 abs/core-testing/LinHES-system/bin/rollback.sh diff --git a/abs/core-testing/LinHES-system/bin/backupcommon b/abs/core-testing/LinHES-system/bin/backupcommon old mode 100755 new mode 100644 index a5ed7c0..9b75db3 --- a/abs/core-testing/LinHES-system/bin/backupcommon +++ b/abs/core-testing/LinHES-system/bin/backupcommon @@ -1,12 +1,16 @@ #!/bin/bash +. /usr/LH/bin/library.sh || { + echo 1>&2 "Can not load common library!" + exit 1 +} + #---------------------------------------------------------------------------- DATABASE="mythconverg" -DATABASE_DIR="/var/lib/mysql/$DATABASE" +DATABASE_DIR="/data/srv/mysql/$DATABASE" BACKUP_LIST="./root ./home ./etc - ./var/www/mythweb/.htaccess ./var/lib/alsa/asound.state" -RESTORE_LIST="./root ./home ./etc/mythtv/modules ./etc/lirc ./etc/htdigest - ./etc/apache2/apache2.conf ./var/www/mythweb/.htaccess + ./var/lib/alsa/asound.state" +RESTORE_LIST="./root ./home ./etc/mythtv/modules ./etc/lirc ./etc/X11/xorg.conf ./etc/asound.conf ./etc/default/aumix ./var/lib/alsa/asound.state ./etc/mplayer/mplayer.conf ./etc/localtime ./etc/timezone" @@ -41,14 +45,54 @@ BACKUP_EXTRAS="$BACKUP_DIR/backup.list" RESTORE_EXTRAS="$BACKUP_DIR/restore.list" BACKUP_TAR="$BACKUP_DIR/savedfiles.tar" BACKUP_SQL="$BACKUP_DIR/$DATABASE.sql" -DROP_SQL="/usr/local/share/knoppmyth/drop.sql" +#DROP_SQL="/usr/local/share/knoppmyth/drop.sql" +UTIL_DIR="/usr/LH/bin" # Do we really still need to update from myth-0.11 to myth-0.12 ? UPDATE_SQL="/usr/share/mythtv/sql/0.11-to-0.12.sql" -UPDATE_FILES="/usr/local/bin/restore_fixups.sh" +UPDATE_FILES="$UTIL_DIR/restore_fixups.sh" COMPRESSION=".gz" SOUNDS="/usr/share/sounds" PLAYER="/usr/bin/aplay" #---------------------------------------------------------------------------- +AWK=/bin/awk +BASH=/bin/bash +BUNZIP2=/bin/bunzip2 +BZIP2=/bin/bzip2 +CAT=/bin/cat +CHMOD=/bin/chmod +CHOWN=/bin/chown +EGREP=/bin/egrep +GREP=/bin/grep +GUNZIP=/bin/gunzip +GZIP=/bin/gzip +LS=/bin/ls +MV=/bin/mv +RM=/bin/rm +SED=/bin/sed +TAR=/bin/tar +TR=/bin/tr +DIFF=/usr/bin/diff +FIND=/usr/bin/find +MD5SUM=/usr/bin/md5sum +MYISAMCHK=/usr/bin/myisamchk +MYSQL=/usr/bin/mysql +MYSQLADMIN=/usr/bin/mysqladmin +MYSQLDUMP=/usr/bin/mysqldump +MYTHSHUTDOWN=/usr/bin/mythshutdown +SORT=/usr/bin/sort +WC=/usr/bin/wc +SV=/sbin/sv + +#---------------------------------------------------------------------------- + +require file+r+x $AWK $BASH $BUNZIP2 $BZIP2 $CAT $CHMOD $CHOWN $EGREP $GREP \ + $GUNZIP $GZIP $LS $MV $RM $SED $TAR $TR $DIFF $FIND $MD5SUM \ + $MYISAMCHK $MYSQL $MYSQLADMIN $MYSQLDUMP $MYTHSHUTDOWN \ + $SORT $WC $SV + +#require file+r "$DROP_SQL" + +require dir+r+w+x /tmp "$BACKUP_DIR" "$DATABASE_DIR" play_sound () { ($PLAYER $SOUNDS/$1 >& /dev/null)& @@ -56,26 +100,26 @@ play_sound () { # Filter against an exclude list like the black list or the ignore list above filter_list () { - /bin/grep -vxF "$*" | - /usr/bin/sort -u + $GREP -vxF "$*" | + $SORT -u } # Some people just can't read or follow directions... :-/ # This should track the directory names in the default backup list above # We also use this to short circuit a certain incredibly dumb stunt filter_redundant () { - filter_list "$(echo $BACKUP_LIST ./myth | /usr/bin/tr -s ' ' '\n')" | - /bin/egrep -v '^\./(root|home|etc|myth)/' | - /usr/bin/sort -u + filter_list "$($TR -s ' ' '\n' <<<"$BACKUP_LIST ./myth")" | + $EGREP -v '^\./(root|home|etc|myth)/' | + $SORT -u } get_extras () { # One entry per line, and normalize the prefix - /usr/bin/tr ' ' '\n' <"$1" | - /usr/bin/awk '/^$/ {next} - /^\.\// {print $0 ; next} - /^\// {print "." $0 ; next} - { print "./" $0}' + $TR ' ' '\n' <"$1" | + $AWK '/^$/ {next} + /^\.\// {print $0 ; next} + /^\// {print "." $0 ; next} + { print "./" $0}' } [ -f "$BACKUP_EXTRAS" ] && @@ -101,10 +145,10 @@ esac shrink () { case "$COMPRESSION" in .gz) - /bin/gzip -9 "$@" + $GZIP -9 "$@" ;; .bz2) - /bin/bzip2 -9 "$@" + $BZIP2 -9 "$@" ;; *) ;; @@ -114,13 +158,13 @@ shrink () { expand () { case "$*" in *.gz) - /bin/gunzip "$@" + $GUNZIP "$@" ;; *.bz2) - /bin/bunzip2 "$@" + $BUNZIP2 "$@" ;; -c\ *) - /bin/cat $2 /dev/null + $CAT $2 /dev/null ;; -t\ *) return 0 @@ -133,8 +177,8 @@ expand () { } single_format () { - candidates=$(/bin/ls -1 "$1.gz" "$1.bz2" "$1" 2>/dev/null) - case $(echo "$candidates" | /usr/bin/wc -l) in + candidates=$($LS -1 "$1.gz" "$1.bz2" "$1" 2>/dev/null) + case $($WC -l <<<"$candidates") in 1) return 0 # One is good! ;; 0) echo "Error, no $1 found!" @@ -161,10 +205,10 @@ backup_roller () { # Gets the rollover sequence to use. for i in "$@" ; do for c in .gz .bz2 "" ; do for f in $BACKUP_SQL $BACKUP_TAR ; do - /bin/rm -f $f$c$prev_i + $RM -f $f$c$prev_i if [ -f "$f$c$i" ] ; then echo "Moving $f$c$i to $f$c$prev_i" - /bin/mv -f $f$c$i $f$c$prev_i + $MV -f $f$c$i $f$c$prev_i fi done done @@ -174,17 +218,17 @@ backup_roller () { # Gets the rollover sequence to use. # Given "subset A B" return true if is A a subset of B subset () { - cnt=$(/usr/bin/diff $1 $2 | /bin/grep '^<' | /usr/bin/wc -l) + cnt=$($DIFF $1 $2 | $GREP '^<' | $WC -l) [ "$cnt" -eq 0 ] && return 0 - /usr/bin/diff $1 $2 + $DIFF $1 $2 } mysql_cmd () { - /usr/bin/mysql -u root $DATABASE -sBe "$*" + $MYSQL -u root $DATABASE -sBe "$*" } mysql_stdin () { - /usr/bin/mysql -u root $DATABASE -sB + $MYSQL -u root $DATABASE -sB } check_files () { @@ -205,14 +249,14 @@ check_files () { echo "Generating a list of the backup contents..." { expand -c $BACKUP_TAR$c | - /bin/tar tf - $OBJECT_LIST $EXCLUSION | - /bin/sed '/\/$/s///' | + $TAR tf - $OBJECT_LIST $EXCLUSION | + $SED '/\/$/s///' | filter_list "$IGNORE_LIST" >$SAVED_FILES - } 2>&1 | /bin/sed -e '/Error exit delayed from previous errors/d' + } 2>&1 | $SED -e '/Error exit delayed from previous errors/d' echo "Generating a list of the directory contents..." cd / - /usr/bin/find $OBJECT_LIST \( -type d -or -type f -or -type l \) -print | + $FIND $OBJECT_LIST \( -type d -or -type f -or -type l \) -print | filter_list "$IGNORE_LIST" >$LIVE_FILES echo "Comparing directory versus backup contents..." @@ -224,11 +268,11 @@ check_files () { subset $SAVED_FILES $LIVE_FILES ;; *) - /usr/bin/diff $LIVE_FILES $SAVED_FILES + $DIFF $LIVE_FILES $SAVED_FILES ;; esac FILE_STATUS=$? - /bin/rm $LIVE_FILES $SAVED_FILES + $RM $LIVE_FILES $SAVED_FILES if [ $FILE_STATUS -eq 0 ] ; then echo "Live and saved file lists match." else @@ -240,11 +284,11 @@ check_files () { has_records () { filename="$1" description="$2" - if [ $(/usr/bin/wc -l < "$filename") -eq 0 ] ; then + if [ $($WC -l < "$filename") -eq 0 ] ; then echo "Warning, could not get record counts from $description!" return 1 fi - if [ $(/usr/bin/awk '{cnt+=$2} END {print cnt}' < "$filename") -eq 0 ] ; then + if [ $($AWK '{cnt+=$2} END {print cnt}' < "$filename") -eq 0 ] ; then echo "Warning, total record count from $description is zero!" return 1 fi @@ -267,22 +311,22 @@ check_tables () { echo "Generating a list of tables and record counts in the DB dump..." expand -c "$BACKUP_SQL$c" | - /usr/bin/awk '/CREATE TABLE/ { tbl = $3; gsub("`","",tbl); records[tbl] = 0; } \ + $AWK '/CREATE TABLE/ { tbl = $3; gsub("`","",tbl); records[tbl] = 0; } \ /INSERT INTO/ { tbl = $3; gsub("`","",tbl); \ n = split(substr($0,index($0,"VALUES (")+7),vals,"\\),\\("); \ records[tbl] += n; } \ END { for (tbl in records) print tbl, records[tbl]; }' | - /bin/sed 's/mythlog [0-9]*/mythlog 0/' | - /usr/bin/sort >$SAVED_TABLES + $SED 's/mythlog [0-9]*/mythlog 0/' | + $SORT >$SAVED_TABLES has_records "$SAVED_TABLES" "DB dump" || return 1 echo "Generating a list of tables and record counts in the live DB..." for tbl in $(mysql_cmd "show tables") ; do mysql_cmd "select '$tbl', count(*) from $tbl" done | - /usr/bin/tr -s '\t' ' ' | - /bin/sed 's/mythlog [0-9]*/mythlog 0/' | - /usr/bin/sort >$LIVE_TABLES + $TR -s '\t' ' ' | + $SED 's/mythlog [0-9]*/mythlog 0/' | + $SORT >$LIVE_TABLES has_records "$LIVE_TABLES" "live DB" || return 1 echo "Comparing live versus saved tables..." @@ -291,11 +335,11 @@ check_tables () { subset $SAVED_TABLES $LIVE_TABLES ;; *) # backup must exactly match the database - /usr/bin/diff $LIVE_TABLES $SAVED_TABLES + $DIFF $LIVE_TABLES $SAVED_TABLES ;; esac TABLE_STATUS=$? - /bin/rm $LIVE_TABLES $SAVED_TABLES + $RM $LIVE_TABLES $SAVED_TABLES if [ $TABLE_STATUS -eq 0 ] ; then echo "Live and saved table lists match." else @@ -314,4 +358,13 @@ check_files_and_tables () { return $STATUS } +stop_mysqld () { $SV stop mysql ; } +start_mysqld () { $SV start mysql ; } + +stop_mythbackend () { $SV stop mythbackend ; } +start_mythbackend () { $SV start mythbackend ; } + +lock_myth () { $MYTHSHUTDOWN --lock ; } +unlock_myth () { $MYTHSHUTDOWN --unlock ; } + true # Make sure that this shows success diff --git a/abs/core-testing/LinHES-system/bin/checkbackup b/abs/core-testing/LinHES-system/bin/checkbackup index 129e5ff..b6d8587 100755 --- a/abs/core-testing/LinHES-system/bin/checkbackup +++ b/abs/core-testing/LinHES-system/bin/checkbackup @@ -1,7 +1,7 @@ #!/bin/bash #---------------------------------------------------------------------------- -. $LinHES_ROOT/bin/backupcommon || { +. /usr/LH/bin/backupcommon || { echo 1>&2 "Can not load common settings!" exit 1 } diff --git a/abs/core-testing/LinHES-system/bin/checkrestore b/abs/core-testing/LinHES-system/bin/checkrestore index 73eb6bc..ef0360c 100755 --- a/abs/core-testing/LinHES-system/bin/checkrestore +++ b/abs/core-testing/LinHES-system/bin/checkrestore @@ -1,7 +1,7 @@ #!/bin/bash #---------------------------------------------------------------------------- -. $LinHES_ROOT/bin/backupcommon || { +. /usr/LH/bin/backupcommon || { echo 1>&2 "Can not load common settings!" exit 1 } diff --git a/abs/core-testing/LinHES-system/bin/library.sh b/abs/core-testing/LinHES-system/bin/library.sh new file mode 100755 index 0000000..2049de3 --- /dev/null +++ b/abs/core-testing/LinHES-system/bin/library.sh @@ -0,0 +1,164 @@ +msg () { # A status reporting function + [ "${VERBOSE:-0}" -gt 0 ] && echo "$*" +} + +error () { # An error reporting function + echo 1>&2 "$*" +} + +fatal () { # Report an error and exit with a failure code + error "$*" + exit 1 +} + +# The only non builtin this uses is tr... +require () { # Check prerequisites + e=0 + props="$1" ; shift + for obj in "$@" ; do + [ -z "$obj" ] && continue # Too late to do anything itelligent... + problems="" + for prop in $(/bin/tr '+,' ' ' <<<"$props") ; do + case "$prop" in + e|exists) # kind of useless... + [ -e "$obj" ] || problems="$problems, does not exist" ;; + f|file) + [ -f "$obj" ] || problems="$problems, is not a file" ;; + d|dir) + [ -d "$obj" ] || problems="$problems, is not a directory" ;; + l|symlink) + [ -L "$obj" ] || problems="$problems, is not a symlink" ;; + nosymlink) + [ -L "$obj" ] && problems="$problems, is a symlink" ;; + r|readable) + [ -r "$obj" ] || problems="$problems, is not readable" ;; + w|writable) + [ -w "$obj" ] || problems="$problems, is not writable" ;; + x|executable) + [ -x "$obj" ] || problems="$problems, is not executable" ;; + *) + fatal "Programmer error, unknown property: '$prop'" ;; + esac + done + if [ -n "$problems" ] ; then + error "Error: '$obj'$problems." + e=1 + fi + done + [ "$e" -ne 0 ] && fatal "Errors noted above are fatal." +} + +require file+r+x /bin/bash /bin/grep /bin/rm /bin/tr \ + /usr/bin/basename /usr/bin/env \ + /usr/bin/mysql /usr/bin/sort + +if [ -n "$DEBUG" ] ; then + for debug_opt in $(/bin/tr ',' ' ' <<<"$DEBUG") ; do + echo '============================================================' + echo "==== $debug_opt" + + # Note that the order you specifiy these debug options in matters. + # I recommend always listing log first. For example: + # export DEBUG=log,env,set,trace + case "$debug_opt" in + env) /usr/bin/env | /usr/bin/sort ;; + set) set ;; + trace) set -vx ;; + log) logfile="/tmp/$(/usr/bin/basename $0).$$.debug" + /bin/rm -f "$logfile" # Try to avoid privilege escalation bugs + echo "Redirecting stdout and stderr to '$logfile'" + exec >"$logfile" 2>&1 ;; + *) error "Unknown debug option '$debug_opt'" ;; + esac + done + echo '============================================================' +fi + +must_be_root () { # For things which must be run as root + [ $(/usr/bin/id -u) -ne 0 ] && fatal "You must run this script as root!" +} + +must_be_mythtv () { # For things which must be run as mythtv (su if possible) + case $(/usr/bin/id -nu) in + mythtv) ;; # Continue + root) /bin/su - mythtv -c "$0 $*" ; exit $? ;; + *) fatal "You must run this script at mythtv or root!" ;; + esac +} + +# Use a variable so you can override it. +DATABASE="mythconverg" + +mysql_cmd () { # Execute SQL from the command line + /usr/bin/mysql -u root "$DATABASE" -sBe "$*" +} + +mysql_stdin () { # Execute SQL from stdin + /usr/bin/mysql -u root "$DATABASE" -sB +} + +machine_clause () { # Helper function + if [ -z "$1" ] ; then + echo "(hostname = '' or hostname is null)" + else + echo "hostname = '$1'" + fi +} + +get_all_setting_names () { # List setting names + case "$#" in + 0) MACHINE_CLAUSE="" ;; + 1) MACHINE_CLAUSE="where $(machine_clause "$1")" ;; + *) fatal "Programmer error, get_all_names must be passed 0 or 1 args, got $#" ;; + esac + mysql_cmd "select distinct value from settings $MACHINE_CLAUSE order by value" +} + +get_all_setting_values () { # List settings + case "$#" in + 0) MACHINE_CLAUSE="" ;; + 1) MACHINE_CLAUSE="where $(machine_clause "$1")" ;; + *) fatal "Programmer error, get_all_values must be passed 0 or 1 args, got $#" ;; + esac + mysql_cmd "select value, data, hostname from settings $MACHINE_CLAUSE order by hostname, value, data" +} + +get_setting_value () { # Get the data for a setting (may return multiples!) + case "$#" in + 1) MACHINE_CLAUSE="" ;; + 2) MACHINE_CLAUSE="and $(machine_clause "$2")" ;; + *) fatal "Programmer error, get_value must be passed 1 or 2 args, got $#" ;; + esac + mysql_cmd "select data from settings where value = '$1' $MACHINE_CLAUSE" +} + +set_setting_value () { # Insert or update aome setting + case "$#" in + 2) RECORD_CNT=$(get_value "$1" | wc -l) ;; + 3) RECORD_CNT=$(get_value "$1" "$3" | wc -l) ;; + *) fatal "Programmer error, set_value must be passed 2 or 3 args, got $#" ;; + esac + MACHINE_CLAUSE="" + if [ "$RECORD_CNT" -eq 0 ] ; then + [ -n "$3" ] && MACHINE_CLAUSE=", $(machine_clause "$3")" + mysql_cmd "insert into settings set value = '$1', data = '$2' $MACHINE_CLAUSE" + else + [ "$#" -eq 3 ] && MACHINE_CLAUSE="and $(machine_clause "$3")" + mysql_cmd "update settings set data = '$2' where value = '$1' $MACHINE_CLAUSE" + fi +} + +delete_setting_value () { # Totally remove some setting + case "$#" in + 1) MACHINE_CLAUSE="" ;; + 2) MACHINE_CLAUSE="and $(machine_clause "$2")" ;; + *) fatal "Programmer error, get_value must be passed 1 or 2 args, got $#" ;; + esac + mysql_cmd "delete from settings where value = '$1' $MACHINE_CLAUSE" +} + +# Filter against a newline seperated exclude list +filter_list () { + /bin/grep -vxF "$*" | + /usr/bin/sort -u +} diff --git a/abs/core-testing/LinHES-system/bin/mythbackup b/abs/core-testing/LinHES-system/bin/mythbackup index dfba611..d3cc4e8 100755 --- a/abs/core-testing/LinHES-system/bin/mythbackup +++ b/abs/core-testing/LinHES-system/bin/mythbackup @@ -1,18 +1,18 @@ #!/bin/bash #---------------------------------------------------------------------------- -. $LinHES_ROOT/bin/backupcommon || { +. /usr/LH/bin/backupcommon || { echo 1>&2 "Can not load common settings!" exit 1 } #---------------------------------------------------------------------------- +# Prevent mythshutdown from shutting down the system in the middle... +lock_myth + # Play a sound to let you know I'm starting. play_sound init.wav -# Prevent mythshutdown from shutting down the system in the middle... -/usr/bin/mythshutdown --lock - # Keep a chain of recent backups, echo "Starting rollover of old backups, this may take a while..." [ -f "$BACKUP_SQL" ] && shrink $BACKUP_SQL @@ -23,16 +23,16 @@ echo "Rollover completed." # Start with the database backup, first we make sure it's healthy, and # then we can dump it. # Doing this while the backend is active would be BAD. -/etc/init.d/mythtv-backend stop +stop_mythbackend # Stop, check, and fix $DATABASE db to ensure clean copy, then restart it. -/etc/init.d/mysql stop +stop_mysqld cd $DATABASE_DIR -/usr/bin/myisamchk -f *.MYI -/etc/init.d/mysql stop ; /etc/init.d/mysql start +$MYISAMCHK -f *.MYI +start_mysqld # Dumps the $DATABASE database -/usr/bin/mysqldump -c -u root $DATABASE > $BACKUP_SQL +$MYSQLDUMP -c -u root $DATABASE > $BACKUP_SQL shrink $BACKUP_SQL # Now to backup the other files, no fooling around, grab everything in the @@ -41,13 +41,13 @@ shrink $BACKUP_SQL # gather all the things in the list into a nice tidy bundle cd / -/bin/tar cvf $BACKUP_TAR $BACKUP_LIST 2>&1 | - /bin/sed -e '/Error exit delayed from previous errors/d' +$TAR cvf $BACKUP_TAR $BACKUP_LIST 2>&1 | + $SED -e '/Error exit delayed from previous errors/d' shrink $BACKUP_TAR # If you can't read this you've got no business restoring from it anyway. -/bin/chown root:root $BACKUP_TAR* $BACKUP_SQL* -/bin/chmod go-rwx $BACKUP_TAR* $BACKUP_SQL* +$CHOWN root:root $BACKUP_TAR* $BACKUP_SQL* +$CHMOD go-rwx $BACKUP_TAR* $BACKUP_SQL* echo "Sanity checking your backup..." play_sound testing.wav @@ -63,9 +63,9 @@ else fi # Now we can restart the backend. -/etc/init.d/mythtv-backend stop ; /etc/init.d/mythtv-backend start +start_mythbackend # Unlock the system again... -/usr/bin/mythshutdown --unlock +unlock_myth exit $STATUS diff --git a/abs/core-testing/LinHES-system/bin/mythrestore b/abs/core-testing/LinHES-system/bin/mythrestore index c13d357..7fce371 100755 --- a/abs/core-testing/LinHES-system/bin/mythrestore +++ b/abs/core-testing/LinHES-system/bin/mythrestore @@ -1,10 +1,7 @@ #!/bin/bash -# Let's prevent mythshutdown from shutting down the system. -/usr/bin/mythshutdown --lock - #---------------------------------------------------------------------------- -. $LinHES_ROOT/bin/backupcommon || { +. /usr/LH/bin/backupcommon || { echo 1>&2 "Can not load common settings!" exit 1 } @@ -18,7 +15,7 @@ do_file_updates() { # A function because we need to do this in two places do_db_updates() { # We need to redo this since we just restored the old settings... - /usr/bin/mythshutdown --lock + lock_myth # This is gross, but makes sure that the lock count has a sane value... mysql_cmd "update settings set data = '1' where value = 'MythShutdownLock'" @@ -37,11 +34,14 @@ do_db_updates() { mysql_cmd "drop table mythweb_sessions" >/dev/null 2>&1 } +# Let's prevent mythshutdown from shutting down the system. +lock_myth + # Play a sound to let you know I'm starting. play_sound restore.wav # Doing this while the backend is active could be BAD. -/etc/init.d/mythtv-backend stop +stop_mythbackend # If the standard backup file exists we try to restore the files based # on our restore list. @@ -49,8 +49,8 @@ if compression=$(compression_type "$BACKUP_TAR") ; then echo "Starting the restore of files..." cd / expand -c $BACKUP_TAR$compression | - /bin/tar xpvf - $RESTORE_LIST $EXCLUSION 2>&1 | - /bin/sed -e '/Error exit delayed from previous errors/d' + $TAR xpvf - $RESTORE_LIST $EXCLUSION 2>&1 | + $SED -e '/Error exit delayed from previous errors/d' echo "Completed the restore of files." fi @@ -58,9 +58,9 @@ fi if compression=$(compression_type "$BACKUP_SQL") ; then echo "Starting the DB restore, this can take a while..." echo "Clearing out the existing skeleton..." - mysql_stdin < $DROP_SQL + #mysql_stdin < $DROP_SQL echo "Recreating the db..." - /usr/bin/mysqladmin -u root create $DATABASE + $MYSQLADMIN -u root create $DATABASE echo "Restoring the data (long)..." expand -c $BACKUP_SQL$compression | mysql_stdin echo "Doing any needed db updates..." @@ -87,6 +87,6 @@ do_db_updates do_file_updates # Now it's more or less safe to restart the backend. -/etc/init.d/mythtv-backend stop ; /etc/init.d/mythtv-backend start +start_mythbackend exit $STATUS diff --git a/abs/core-testing/LinHES-system/bin/rollback.sh b/abs/core-testing/LinHES-system/bin/rollback.sh new file mode 100755 index 0000000..12897da --- /dev/null +++ b/abs/core-testing/LinHES-system/bin/rollback.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#---------------------------------------------------------------------------- +. /usr/LH/bin/backupcommon || { + echo 1>&2 "Can not load common settings!" + exit 1 +} +#---------------------------------------------------------------------------- + +require file+r+x $MYTHSHUTDOWN + +# Prevent mythshutdown from shutting down the system in the middle... +lock_myth + +echo "Starting rollback of old backups" +backup_roller '' .1 .2 .3 .4 .5 .6 .7 .8 .9 .10 .11 .12 .13 .14 .15 .16 .17 .18 .19 +echo "Rollback completed." + +# Unlock the system again... +unlock_myth -- cgit v0.12 From 8cd0a2c03be58a6b03f05da0565286819897720a Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Sat, 10 Jan 2009 20:55:40 -0500 Subject: Added Hauppauge HD-PVR drivers --- abs/extra-testing/mercurial/ChangeLog | 17 ++++++++++++ abs/extra-testing/mercurial/PKGBUILD | 35 +++++++++++++++++++++++++ abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD | 27 +++++++++++++++++++ abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install | 23 ++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 abs/extra-testing/mercurial/ChangeLog create mode 100644 abs/extra-testing/mercurial/PKGBUILD create mode 100644 abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD create mode 100644 abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install diff --git a/abs/extra-testing/mercurial/ChangeLog b/abs/extra-testing/mercurial/ChangeLog new file mode 100644 index 0000000..fa0df00 --- /dev/null +++ b/abs/extra-testing/mercurial/ChangeLog @@ -0,0 +1,17 @@ + +2009-01-03 Douglas Soares de Andrade + + * Updated for i686: 1.1.2 + +2008-12-02 Douglas Soares de Andrade + + * Updated for i686: 1.1 + +2008-08-17 Douglas Soares de Andrade + + * Updated for i686: 1.0.2 + +2008-07-10 Douglas Soares de Andrade + + * Updated for i686: 1.0.1 + diff --git a/abs/extra-testing/mercurial/PKGBUILD b/abs/extra-testing/mercurial/PKGBUILD new file mode 100644 index 0000000..74de74a --- /dev/null +++ b/abs/extra-testing/mercurial/PKGBUILD @@ -0,0 +1,35 @@ +# $Id: PKGBUILD 23135 2009-01-03 12:10:17Z douglas $ +# Contributor: Jeff Mickey +# Contributor: Giovanni Scafora +# Contributor: David 'SleepyDog' +# Maintainer: Douglas Soares de Andrade + +pkgname=mercurial +pkgver=1.1.2 +pkgrel=1 +pkgdesc="A scalable distributed SCM tool" +url="http://www.selenic.com/mercurial" +license=("GPL") +depends=('python>=2.5') +source=(http://www.selenic.com/mercurial/release/$pkgname-$pkgver.tar.gz) +arch=('i686' 'x86_64') + +build() { + cd $startdir/src/$pkgname-$pkgver + python setup.py install --root $startdir/pkg + + install -d $startdir/pkg/usr/share/man/{man1,man5} + install -m644 doc/hg.1 $startdir/pkg/usr/share/man/man1 + install -m644 doc/{hgrc.5,hgignore.5} $startdir/pkg/usr/share/man/man5 + install -m755 contrib/hgk $startdir/pkg/usr/bin + install -m644 -D contrib/zsh_completion $startdir/pkg/usr/share/zsh/site-functions/_hg + install -m644 -D contrib/bash_completion $startdir/pkg/etc/bash_completion.d/hg + install -d $startdir/pkg/usr/share/emacs/site-lisp + install -m644 contrib/{mq.el,mercurial.el} $startdir/pkg/usr/share/emacs/site-lisp + install -m644 -D contrib/vim/HGAnnotate.vim $startdir/pkg/usr/share/vim/syntax/HGAnnotate.vim + + # Autoloading plugins to vim = no good. + # install -d $startdir/pkg/usr/share/vim/plugin + # install -m644 contrib/vim/{hg-menu.vim,hgcommand.vim,patchreview.vim} $startdir/pkg/usr/share/vim/plugin +} +md5sums=('4fd3b9a2e5dcd025840c3849b136bec8') diff --git a/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD b/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD new file mode 100644 index 0000000..7464266 --- /dev/null +++ b/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD @@ -0,0 +1,27 @@ +# $Id: PKGBUILD 5936 2008-07-21 20:24:16Z thomas $ +# Maintainer: Cecil Watson + +pkgname=v4l-dvb-hdpvr +_kernver=2.6.26-ARCH +pkgver=1 +pkgrel=1 +pkgdesc="V4L-DVB drivers for HD-PVR from mercurial" +arch=('i686' 'x86_64') +license=('GPL2') +url="http://linuxtv.org/" +depends=('kernel26') +replaces=(v4l-dvb) +makedepends=(kernel-headers) +install=v4l-dvb.install +source=() + +build() { + cd $startdir/src/ + hg clone http://hg.jannau.net/hdpvr/ || return 1 + cd hdpvr + make KERNDIR=/lib/modules/$_kernver/build \ + DESTDIR=$startdir/pkg KERNELRELEASE=$_kernver all || return 1 + make KERNDIR=/lib/modules/$_kernver/build \ + DESTDIR=$startdir/pkg KERNELRELEASE=$_kernver install || return 1 + rm -fr $startdir/pkg/lib/modules/$_kernver/modules* +} diff --git a/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install b/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install new file mode 100644 index 0000000..c87bb82 --- /dev/null +++ b/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install @@ -0,0 +1,23 @@ +# arg 1: the new package version +post_install() { + KERNEL_VERSION='2.6.26-ARCH' + depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + KERNEL_VERSION='2.6.26-ARCH' + depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 + +} + +# arg 1: the old package version +post_remove() { + KERNEL_VERSION='2.6.26-ARCH' + depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 +} + +op=$1 +shift +$op $* -- cgit v0.12 From c9a21e49990da76516f862b690aa8e7ceda42e46 Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Sat, 10 Jan 2009 21:21:13 -0500 Subject: renamed install file --- .../v4l-dvb-hdpvr/v4l-dvb-hdpvr.install | 23 ++++++++++++++++++++++ abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install | 23 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb-hdpvr.install delete mode 100644 abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install diff --git a/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb-hdpvr.install b/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb-hdpvr.install new file mode 100644 index 0000000..c87bb82 --- /dev/null +++ b/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb-hdpvr.install @@ -0,0 +1,23 @@ +# arg 1: the new package version +post_install() { + KERNEL_VERSION='2.6.26-ARCH' + depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + KERNEL_VERSION='2.6.26-ARCH' + depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 + +} + +# arg 1: the old package version +post_remove() { + KERNEL_VERSION='2.6.26-ARCH' + depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 +} + +op=$1 +shift +$op $* diff --git a/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install b/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install deleted file mode 100644 index c87bb82..0000000 --- a/abs/extra-testing/v4l-dvb-hdpvr/v4l-dvb.install +++ /dev/null @@ -1,23 +0,0 @@ -# arg 1: the new package version -post_install() { - KERNEL_VERSION='2.6.26-ARCH' - depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 -} - -# arg 1: the new package version -# arg 2: the old package version -post_upgrade() { - KERNEL_VERSION='2.6.26-ARCH' - depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 - -} - -# arg 1: the old package version -post_remove() { - KERNEL_VERSION='2.6.26-ARCH' - depmod -ae -v $KERNEL_VERSION > /dev/null 2>&1 -} - -op=$1 -shift -$op $* -- cgit v0.12 From c18b7a805648a5920424454ec5237d699ce4eecc Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Sat, 10 Jan 2009 21:24:44 -0500 Subject: changed install file --- abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD b/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD index 7464266..d10c398 100644 --- a/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD +++ b/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD @@ -12,7 +12,7 @@ url="http://linuxtv.org/" depends=('kernel26') replaces=(v4l-dvb) makedepends=(kernel-headers) -install=v4l-dvb.install +install=v4l-dvb-hdpvr.install source=() build() { -- cgit v0.12 From ae4a3db9403d07e987efc351701eb5429baff635 Mon Sep 17 00:00:00 2001 From: Nathan Harris Date: Sun, 11 Jan 2009 13:27:23 -0500 Subject: added make dependency for mercurial --- abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD b/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD index d10c398..f2bc1d3 100644 --- a/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD +++ b/abs/extra-testing/v4l-dvb-hdpvr/PKGBUILD @@ -11,7 +11,7 @@ license=('GPL2') url="http://linuxtv.org/" depends=('kernel26') replaces=(v4l-dvb) -makedepends=(kernel-headers) +makedepends=(kernel-headers mercurial) install=v4l-dvb-hdpvr.install source=() -- cgit v0.12