diff options
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/share/rbup/rbup.sh.2017-05-21.01 | 247 |
1 files changed, 0 insertions, 247 deletions
diff --git a/usr/share/rbup/rbup.sh.2017-05-21.01 b/usr/share/rbup/rbup.sh.2017-05-21.01 deleted file mode 100755 index 631319a..0000000 --- a/usr/share/rbup/rbup.sh.2017-05-21.01 +++ /dev/null @@ -1,247 +0,0 @@ -#!/bin/sh -# Filename: rbup.sh -# Location: /usr/share/rbup/ -# Author: bgstack15@gmail.com -# Startdate: 2017-05-21 09:25:16 -# Title: Script that Performs Regular Backups -# Purpose: Allows customizable jobs from an easy config file -# Package: rbup -# History: -# 2016 -# Usage: -# Reference: ftemplate.sh 2017-04-17a; framework.sh 2017-04-17a -# /mnt/bgirton/Backups/bup_data.sh which itself was modified from darmok:/usr/local/bin/sync_smash.sh -# dnskeepalive.sh from package bgscripts-core -# Improve: -fiversion="2017-04-29a" -rbupversion="2017-05-21a" - -usage() { - less -F >&2 <<ENDUSAGE -usage: rbup.sh [-duV] [-c <conffile>] [ -j <jobname>] -version ${rbupversion} - -d debug Show debugging info, including parsed variables. - -u usage Show this usage block. - -V version Show script version number. - -i infile Overrides default infile value. Default is none. - -c conffile Use this conf instead of default, which is /etc/rbup/rbup.conf - -j jobname Run only this job. Can be repeated. -Return values: -0 Normal -1 Help or version info displayed -2 Count or type of flaglessvals is incorrect -3 Incorrect OS type -4 Unable to find dependency -5 Not run as root or sudo -6 Unable to mount destination -7 Invalid checksum(s) on file(s) -ENDUSAGE -} - -# DEFINE FUNCTIONS -get_conf() { - # call: get_conf /etc/rbup/rbup.conf [ job1 [ job2 ... ] ] - # copied in from dnskeepalive, but modified - local _infile="$1" - #local _tmpfile1="$( mktemp -p /tmp/rbup )" - shift; local _requestedzones="default $@" - local _zone="" - grep -viE '^\s*((#).*)?$' "${_infile}" | while read _line; - do - local _left="$( echo "${_line}" | cut -d'=' -f1 )" - # check if line is a zone [rbup:default] - if echo "${_left}" | grep -qiE '^\[rbup:.*\]'; - then - _zone="$( echo "${_left}" | sed -r -e 's/^.*://;s/\]$//;' )" - echo "new zone ${_zone}" - else - eval "_thisval=\"\${${_left}}\"" - if test -z "${_thisval}" && { test -z "$@" || echo "${_requestedzones}" | grep -qiE "${_zone}"; }; - then - echo "${_line}" >> "/tmp/rbup/${_zone}.conf" - echo "${_line} added to /tmp/rbup/${_zone}.conf" - fi - fi - done - #test -f "${_tmpfile1}" && . "${_tmpfile1}" 1>/dev/null 2>&1 - #/bin/rm -rf "${_tmpfile1}" -} - -reset_vars() { - for word in $( set | grep -oIE "^RBUP_.+=" | sed -r -e 's/=$//;' ); do unset ${word}; done -} - -log() { - # WORKHERE: figure out how logging will work - echo "$@" -} - -# DEFINE TRAPS - -clean_rbup() { - #use at end of entire script if you need to clean up tmpfiles - test "${RBUP_CLEANUP}"="1" || rm -rf "${tmpdir}" 1>/dev/null 2>&1 - : -} - -CTRLC() { - #trap "CTRLC" 2 - [ ] #useful for controlling the ctrl+c keystroke - clean_rbup -} - -CTRLZ() { - #trap "CTRLZ" 18 - [ ] #useful for controlling the ctrl+z keystroke -} - -parseFlag() { - flag="$1" - hasval=0 - case ${flag} in - # INSERT FLAGS HERE - "d" | "debug" | "DEBUG" | "dd" ) setdebug; ferror "debug level ${debug}";; - "u" | "usage" | "help" | "h" ) usage; exit 1;; - "V" | "fcheck" | "version" ) ferror "${scriptfile} version ${rbupversion}"; exit 1;; - #"i" | "infile" | "inputfile" ) getval;infile1=${tempval};; - esac - - debuglev 10 && { test ${hasval} -eq 1 && ferror "flag: ${flag} = ${tempval}" || ferror "flag: ${flag}"; } -} - -# DETERMINE LOCATION OF FRAMEWORK -while read flocation; do if test -x ${flocation} && test "$( ${flocation} --fcheck )" -ge 20170111; then frameworkscript="${flocation}"; break; fi; done <<EOFLOCATIONS -./framework.sh -${scriptdir}/framework.sh -~/bin/bgscripts/framework.sh -~/bin/framework.sh -~/bgscripts/framework.sh -~/framework.sh -/usr/local/bin/bgscripts/framework.sh -/usr/local/bin/framework.sh -/usr/bin/bgscripts/framework.sh -/usr/bin/framework.sh -/bin/bgscripts/framework.sh -/usr/share/bgscripts/framework.sh -EOFLOCATIONS -test -z "${frameworkscript}" && echo "$0: framework not found. Aborted." 1>&2 && exit 4 - -# INITIALIZE VARIABLES -# variables set in framework: -# today server thistty scriptdir scriptfile scripttrim -# is_cronjob stdin_piped stdout_piped stderr_piped sendsh sendopts -. ${frameworkscript} || echo "$0: framework did not run properly. Continuing..." 1>&2 -infile1= -outfile1= -logfile=${scriptdir}/${scripttrim}.${today}.out -interestedparties="bgstack15@gmail.com" -tmpdir=/tmp/rbup -mkdir -p "${tmpdir}" 2>/dev/null || { ferror "${script}: 4. Unable to make ${tmpdir} temporary directory. Aborted."; exit 4; } - -# REACT TO OPERATING SYSTEM TYPE -case $( uname -s ) in - Linux) [ ];; - FreeBSD) [ ];; - *) echo "${scriptfile}: 3. Indeterminate OS: $( uname -s )" 1>&2 && exit 3;; -esac - -## REACT TO ROOT STATUS -#case ${is_root} in -# 1) # proper root -# [ ] ;; -# sudo) # sudo to root -# [ ] ;; -# "") # not root at all -# #ferror "${scriptfile}: 5. Please run as root or sudo. Aborted." -# #exit 5 -# [ ] -# ;; -#esac - -# SET CUSTOM SCRIPT AND VALUES -#setval 1 sendsh sendopts<<EOFSENDSH # if $1="1" then setvalout="critical-fail" on failure -#/usr/share/bgscripts/send.sh -hs # setvalout maybe be "fail" otherwise -#/usr/local/bin/send.sh -hs # on success, setvalout="valid-sendsh" -#/usr/bin/mail -s -#EOFSENDSH -#test "${setvalout}" = "critical-fail" && ferror "${scriptfile}: 4. mailer not found. Aborted." && exit 4 - -# VALIDATE PARAMETERS -# objects before the dash are options, which get filled with the optvals -# to debug flags, use option DEBUG. Variables set in framework: fallopts -validateparams - "$@" - -# CONFIRM TOTAL NUMBER OF FLAGLESSVALS IS CORRECT -#if test ${thiscount} -lt 2; -#then -# ferror "${scriptfile}: 2. Fewer than 2 flaglessvals. Aborted." -# exit 2 -#fi - -# CONFIGURE VARIABLES AFTER PARAMETERS - -## START READ CONFIG FILE TEMPLATE -get_conf /home/bgirton-local/rpmbuild/SOURCES/rbup-0.0-1/etc/rbup/rbup.conf -#oIFS="${IFS}"; IFS="$( printf '\n' )" -#infiledata=$( ${sed} ':loop;/^\/\*/{s/.//;:ccom;s,^.[^*]*,,;/^$/n;/^\*\//{s/..//;bloop;};bccom;}' "${infile1}") #the crazy sed removes c style multiline comments -#IFS="${oIFS}"; infilelines=$( echo "${infiledata}" | wc -l ) -#{ echo "${infiledata}"; echo "ENDOFFILE"; } | { -# while read line; do -# # the crazy sed removes leading and trailing whitespace, blank lines, and comments -# if test ! "${line}" = "ENDOFFILE"; -# then -# line=$( echo "${line}" | sed -e 's/^\s*//;s/\s*$//;/^[#$]/d;s/\s*[^\]#.*$//;' ) -# if test -n "${line}"; -# then -# debuglev 8 && ferror "line=\"${line}\"" -# if echo "${line}" | grep -qiE "\[.*\]"; -# then -# # new zone -# zone=$( echo "${line}" | tr -d '[]' ) -# debuglev 7 && ferror "zone=${zone}" -# else -# # directive -# varname=$( echo "${line}" | awk -F= '{print $1}' ) -# varval=$( echo "${line}" | awk -F= '{$1=""; printf "%s", $0}' | sed 's/^ //;' ) -# debuglev 7 && ferror "${zone}${varname}=\"${varval}\"" -# # simple define variable -# eval "${zone}${varname}=\${varval}" -# fi -# ## this part is untested -# #read -p "Please type something here:" response < ${thistty} -# #echo "${response}" -# fi -# else - -## REACT TO BEING A CRONJOB -#if test ${is_cronjob} -eq 1; -#then -# [ ] -#else -# [ ] -#fi - -# SET TRAPS -trap "CTRLC" 2 -#trap "CTRLZ" 18 -trap "clean_rbup" 0 - -# MAIN LOOP -#{ - [ ] - for word in $( cd "${tmpdir}"; find -type f -regextype grep ! -regex './default.conf' ! -regex './cli.conf' ); - do - echo "working on ${word}" - reset_vars - . /tmp/rbup/default.conf - . /tmp/rbup/"${word}" - set | grep -iE "^RBUP_" - done -#} | tee -a ${logfile} - -# EMAIL LOGFILE -#${sendsh} ${sendopts} "${server} ${scriptfile} out" ${logfile} ${interestedparties} - -## STOP THE READ CONFIG FILE -#exit 0 -#fi; done; } |