summaryrefslogtreecommitdiffstats
path: root/abs
diff options
context:
space:
mode:
Diffstat (limited to 'abs')
-rw-r--r--abs/core/LinHES-system/fix_myth_mount.py51
-rw-r--r--abs/core/LinHES-system/fix_myth_mount.sh22
-rw-r--r--abs/core/LinHES-system/lh_system_all_host_update8
-rw-r--r--abs/core/LinHES-system/lh_system_backup_job64
-rw-r--r--abs/core/LinHES-system/lh_system_host_update56
-rw-r--r--abs/core/LinHES-system/lh_system_restore_job76
6 files changed, 277 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/fix_myth_mount.py b/abs/core/LinHES-system/fix_myth_mount.py
new file mode 100644
index 0000000..9f3cc54
--- /dev/null
+++ b/abs/core/LinHES-system/fix_myth_mount.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python2
+import os
+import sys
+cmd="cp -f /etc/fstab /etc/fstab.backup.pre_acl"
+os.system(cmd)
+f = open('/etc/fstab', 'r')
+fstab=f.readlines()
+f.close()
+mp='/data/mnt/d1'
+
+def check_fstab_mount():
+ #first check if media/d1 is in list, if not add it.
+ newfstab=[]
+ mnt_in_fstab=False
+ for line in fstab:
+ split_line=line.split()
+ try:
+ if split_line[1] == mp :
+ print "found mountpoint if fstab"
+ mnt_in_fstab = True
+ break
+ except: pass
+ return mnt_in_fstab
+
+def add_mnt_to_fstab():
+ newfstab=[]
+ for line in fstab:
+ newfstab.append(line)
+ split_line=line.split()
+ try:
+ if split_line[1] == "/myth":
+ split_line[1] = mp
+ new_line='\t'.join(split_line)+"\n"
+ newfstab.append(new_line)
+ except:
+ pass
+
+ return newfstab
+
+
+
+if check_fstab_mount() == False:
+ print "I need to add it"
+ newfstab=add_mnt_to_fstab()
+ f = open('/tmp/fstab', 'w')
+ for i in newfstab:
+ f.write(i)
+ #f.write("\n")
+ f.close()
+
+
diff --git a/abs/core/LinHES-system/fix_myth_mount.sh b/abs/core/LinHES-system/fix_myth_mount.sh
new file mode 100644
index 0000000..2ed9783
--- /dev/null
+++ b/abs/core/LinHES-system/fix_myth_mount.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+function checkmount {
+ mounted=1
+ for i in `cat /proc/mounts | cut -d' ' -f2`; do
+ if [ "x$1" = "x$i" ]; then
+ mounted=0
+ break
+ fi
+
+ done
+ return $mounted
+}
+
+checkmount $1
+rc=$?
+
+if [ $rc == 0 ]
+then
+ echo "fs is mounted"
+else
+ echo "fs is not mounted"
+fi \ No newline at end of file
diff --git a/abs/core/LinHES-system/lh_system_all_host_update b/abs/core/LinHES-system/lh_system_all_host_update
new file mode 100644
index 0000000..98fe668
--- /dev/null
+++ b/abs/core/LinHES-system/lh_system_all_host_update
@@ -0,0 +1,8 @@
+#!/bin/bash
+results=`cat /data/srv/xymon/server/etc/hosts.cfg|grep -v ^#|awk '{print $2}' `
+for i in $results
+do
+ echo "$i"
+ echo "-------------------------------------------"
+ sudo /usr/bin/func $i call pacman update_system $1
+done
diff --git a/abs/core/LinHES-system/lh_system_backup_job b/abs/core/LinHES-system/lh_system_backup_job
new file mode 100644
index 0000000..3abd5f9
--- /dev/null
+++ b/abs/core/LinHES-system/lh_system_backup_job
@@ -0,0 +1,64 @@
+#!/bin/bash
+#process that uses this system backup script
+# - myth_mtc.py
+# - supplemental web, process.py backup
+#
+echo "#########################################################"
+echo "Starting backup "
+. /etc/profile
+. /etc/systemconfig
+BACKUPDIR=/myth/system_backups
+DATE=`date +%F_%H-%M`
+mkdir -p $BACKUPDIR/$DATE
+
+#backup db
+pacman -Q mysql 2>/dev/null
+if [ $? = 0 ]
+then
+ mysqldump mythconverg > $BACKUPDIR/$DATE/mythconverg
+ mysqldump ncid > $BACKUPDIR/$DATE/ncid
+fi
+
+#backup etc
+cp -rp /etc $BACKUPDIR/$DATE/etc
+cp -rp /var/lib/oss $BACKUPDIR/$DATE/oss
+
+#backup func keys
+cp -rp /data/srv/func $BACKUPDIR/$DATA/func
+
+#make_zip file
+cd $BACKUPDIR
+tar -zcvf $BACKUPDIR/backup.$DATE.tgz $DATE
+
+if [ -d $BACKUPDIR/$DATE ]
+then
+ rm -rf $BACKUPDIR/$DATE
+fi
+
+if [ -f /data/srv/hobbit/server/ext/hbnotes.py ]
+then
+ /data/srv/hobbit/server/ext/hbnotes.py
+ chown nobody:nobody /data/srv/httpd/htdocs/hobbit/notes/* 2> /dev/null >/dev/null
+
+
+fi
+
+
+#Remote copy
+if [ x$RemoteBackup = x1 ]
+then
+ localRemoteCheck=`echo $RemoteBackupDir | cut -d: -f1`
+ if [ x$localRemoteCheck = xdir ]
+ then
+ localRemotedir=`echo $RemoteBackupDir | cut -d: -f2`
+ cmd="cp $BACKUPDIR/backup.$DATE.tgz $localRemotedir"
+ echo "copying$BACKUPDIR/backup.$DATE.tgz to $localRemotedir "
+ else
+ /usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/backup.$DATE.tgz --remotepath $BACKUPDIR/backup.$DATE.tgz
+
+ echo "copying$BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:/data/database_backup/"
+ fi
+ $cmd
+fi
+
+echo "#########################################################"
diff --git a/abs/core/LinHES-system/lh_system_host_update b/abs/core/LinHES-system/lh_system_host_update
new file mode 100644
index 0000000..1a4d714
--- /dev/null
+++ b/abs/core/LinHES-system/lh_system_host_update
@@ -0,0 +1,56 @@
+#!/bin/bash
+# Process that call this script
+# func update
+# supplemental web
+echo "#####################################################"
+echo "Starting update"
+. /etc/profile
+
+if [ x$1 = x ]
+then
+ . /etc/systemconfig
+else
+Hostupdateplan=$1
+fi
+
+
+case $Hostupdateplan in
+ "Myth_only")
+ echo "Updating myth packages"
+ postfix=`cat $INSTALL_DIR/usr/local/share/mythtv/.releasetype`
+ for mythl in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather mythcontrols mythgallery mythmovietime mythmusic mythsmolt mythvideo mythweb mythtv
+ do
+ mythlist="$mythlist $mythl$postfix"
+ done
+
+ pacman -Sy
+ list=`pacman -Qu $pkg |grep Targets`
+ for pkg in LinHES-config LinHES-system mythinstall $mythlist
+ do
+ echo $list|grep -q $pkg
+ if [ $? = 0 ]
+ then
+ echo "Updating $pkg"
+ pacman --noconfirm -S $pkg
+ else
+ echo "$pkg is up to date"
+ fi
+ done
+ ;;
+ "All")
+ echo ""
+ echo "Updating ALL packages"
+ pacman -Sy
+ pacman --noconfirm -Sfu
+ ;;
+ "None")
+ echo ""
+ echo "Updating NO packages"
+ ;;
+ *) echo ""
+ echo "Unknown $Hostupdateplan, skipping updates"
+ ;;
+esac
+
+
+echo "##################################################################################"
diff --git a/abs/core/LinHES-system/lh_system_restore_job b/abs/core/LinHES-system/lh_system_restore_job
new file mode 100644
index 0000000..9c66e2a
--- /dev/null
+++ b/abs/core/LinHES-system/lh_system_restore_job
@@ -0,0 +1,76 @@
+#!/bin/bash
+# This script is used to perform a quick restore of a database that was backed up via the nightly system backup
+# The restore only does the database it does NOT restore system files (even if they are in the backup file)
+#
+BACKUPDIR=/myth/system_backups
+backupfile=$1
+
+function usage(){
+ echo "------------------------------------------------------"
+ echo "This program will restore the database from a system backup."
+
+ echo "Files are expected to be in the $BACKUPDIR"
+ echo "usage:"
+ echo ""
+ echo "lh_system_restore_job \$filename [yes]"
+ echo ""
+ echo "example: lh_system_restore_job backup.2011-12-22_15-34.tgz "
+ echo ""
+ echo ""
+
+ echo "If the script is passed a second argument, it will not cleanup the the restore dir."
+ echo "------------------------------------------------------"
+
+ exit 1
+ }
+
+
+
+if [ x$backupfile = x ]
+then
+ usage
+fi
+
+. /etc/profile
+
+RESTOREDIR=$BACKUPDIR/restore
+DIR=`echo $backupfile |cut -d. -f2`
+CSQL="create database mythconverg;"
+DSQL="drop database mythconverg; "
+MYSQL="mysql -u mythtv -pmythtv"
+
+
+
+mkdir -p $RESTOREDIR
+cp $BACKUPDIR/$backupfile $RESTOREDIR
+cd $RESTOREDIR && tar -xf $backupfile && cd $DIR
+
+if [ -f mythconverg ]
+then
+ #drop the db
+ $MYSQL -e "$DSQL"
+ #create the db
+ $MYSQL -e "$CSQL"
+ #restore the database_backup
+ echo "Restoring the database $DIR"
+ $MYSQL mythconverg < mythconverg
+ if [ $? = 0 ]
+ then
+ echo "Done"
+ else
+ echo "An error occured"
+ fi
+ else
+ echo "Couldn't file a file to restore"
+fi
+
+
+#cleanup
+if [ x$2 = x ]
+then
+ echo "Cleaning up the restore dir"
+ rm -rf $RESTOREDIR/$DIR
+ rm -f $RESTOREDIR/$backupfile
+else
+ echo "Not doing a cleanup of $RESTOREDIR"
+fi