mirror of
https://github.com/erenfro/systemrescue-backup.git
synced 2024-12-22 08:11:07 -05:00
Code cleanup as module loader progresses
This commit is contained in:
parent
cd9f398eaa
commit
961f42f1fe
4 changed files with 47 additions and 28 deletions
|
@ -94,8 +94,9 @@ run-parts() {
|
||||||
: ;; # Ignore package management files
|
: ;; # Ignore package management files
|
||||||
*)
|
*)
|
||||||
if [[ -x "$script" ]]; then
|
if [[ -x "$script" ]]; then
|
||||||
|
echoreg -d "+ Executing Script: $script"
|
||||||
if ! "$script"; then
|
if ! "$script"; then
|
||||||
echoerr "$script failed"
|
echoerr "! Failed Script: $script ($?)"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -124,7 +125,7 @@ load-parts() {
|
||||||
*)
|
*)
|
||||||
if [[ -r "$script" ]]; then
|
if [[ -r "$script" ]]; then
|
||||||
set -e
|
set -e
|
||||||
echoreg -d "Loading script: $script"
|
echoreg -d "+ Loading Module: $script"
|
||||||
source "$script"
|
source "$script"
|
||||||
set +e
|
set +e
|
||||||
fi
|
fi
|
||||||
|
@ -153,7 +154,9 @@ load_module() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echoreg -d "Loading Modules in: ${scriptPath}/${module}/${submod}/"
|
||||||
load-parts "${scriptPath}/${module}/${submod}"
|
load-parts "${scriptPath}/${module}/${submod}"
|
||||||
|
echoreg -d "Loaded Modules in: ${scriptPath}/${module}/${submod}/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
src/recovery/init/001_default
Normal file
1
src/recovery/init/001_default
Normal file
|
@ -0,0 +1 @@
|
||||||
|
echoreg -d "Loaded Recovery Initialization"
|
67
src/srb
67
src/srb
|
@ -1,4 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# SystemRescue-Backup
|
||||||
|
#
|
||||||
|
# SystemRescue-Backup is free software; you can distribut it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the license, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# SystemRescue-Backup is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with SystemRescue-Backup; it not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
#
|
||||||
|
# Authors:
|
||||||
|
# See https://github.com/erenfro/systemrescue-backup/graphs/contributors
|
||||||
|
|
||||||
scriptPath="$(dirname "$(readlink -f "$0")")"
|
scriptPath="$(dirname "$(readlink -f "$0")")"
|
||||||
#configPath="$(dirname "$(readlink -f "${scriptPath}/../config")")"
|
#configPath="$(dirname "$(readlink -f "${scriptPath}/../config")")"
|
||||||
|
@ -24,34 +44,36 @@ showHelp() {
|
||||||
echo "Global Options:"
|
echo "Global Options:"
|
||||||
echo " --debug, -d Enable Debug Logging"
|
echo " --debug, -d Enable Debug Logging"
|
||||||
echo " --help, -h Show this help"
|
echo " --help, -h Show this help"
|
||||||
|
echo " --version, -v Show current SystemRescue Backup version"
|
||||||
echo
|
echo
|
||||||
echo "Options (per command):"
|
echo "Options (per command):"
|
||||||
|
|
||||||
if [[ -z "$section" || "$section" == "backup" ]]; then
|
if [[ -z "$section" || "$section" == "backup" ]]; then
|
||||||
echo "backup:"
|
echo "backup:"
|
||||||
echo " --exclude <pattern> Exclude devices matching the pattern from backup or restore."
|
echo " --exclude=<pattern> Exclude devices matching the pattern from backup"
|
||||||
echo " --exclude-file <file> Exclude devices listed in the specified file from backup or restore."
|
echo " --exclude-file=<file> Exclude devices listed in the specified file from backup"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$section" || "$section" == "restore" ]]; then
|
if [[ -z "$section" || "$section" == "restore" ]]; then
|
||||||
echo "restore:"
|
echo "restore:"
|
||||||
echo " --exclude <pattern> Exclude devices matching the pattern from backup or restore."
|
echo " --exclude=<pattern> Exclude devices matching the pattern from restore"
|
||||||
echo " --exclude-file <file> Exclude devices listed in the specified file from backup or restore."
|
echo " --exclude-file=<file> Exclude devices listed in the specified file from restore"
|
||||||
echo " --rename <old> <new> Rename a device during the restore process."
|
echo " --rename=\"<old> <new>\" Rename a device during the restore process"
|
||||||
echo " --no-uuid Disable restoring of UUIDs during restore."
|
echo " --no-uuid Disable restoring of UUIDs during restore"
|
||||||
|
echo " --no-partition Disable restoring of disk partitions during restore"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$section" || "$section" == "recovery" ]]; then
|
if [[ -z "$section" || "$section" == "recovery" ]]; then
|
||||||
echo "recovery:"
|
echo "recovery:"
|
||||||
echo " --sysrecue-cd-version=ver System Rescue CD version to use: $systemrescue_cd_version"
|
echo " --cd-version=ver System Rescue CD version to use: $systemrescue_cd_version"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
echo " $0 backup --exclude /dev/sda1"
|
echo " $0 backup --exclude=/dev/sda1"
|
||||||
echo " $0 restore --rename /dev/sda /dev/sdb"
|
echo " $0 restore --rename=\"/dev/sda /dev/sdb\""
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +82,7 @@ showHelp() {
|
||||||
# Main function to handle command-line arguments and invoke appropriate functions
|
# Main function to handle command-line arguments and invoke appropriate functions
|
||||||
main() {
|
main() {
|
||||||
local help=false
|
local help=false
|
||||||
|
local -a positional_args
|
||||||
#if [[ "$1" == "--help" ]]; then
|
|
||||||
# showHelp
|
|
||||||
# exit 0
|
|
||||||
#fi
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
@ -78,18 +96,18 @@ main() {
|
||||||
debug=true;
|
debug=true;
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
#--*|-*)
|
-v|--version)
|
||||||
# echo "Unknown option $1"
|
echo "SystemRescue Backup version v${systemrescue_version}"
|
||||||
# exit 1
|
exit 0
|
||||||
# ;;
|
;;
|
||||||
*)
|
*)
|
||||||
POSITIONAL_ARGS+=("$1") # save positional arg
|
positional_args+=("$1") # save positional arg
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
set -- "${POSITIONAL_ARGS[@]}" # restore positional args
|
set -- "${positional_args[@]}" # restore positional args
|
||||||
|
|
||||||
if $help; then
|
if $help; then
|
||||||
showHelp "$1"
|
showHelp "$1"
|
||||||
|
@ -97,10 +115,6 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
version)
|
|
||||||
echo "SystemRescue Backup version v${systemrescue_version}"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
backup)
|
backup)
|
||||||
echo "SystemRescue Backup -- Backup Mode"
|
echo "SystemRescue Backup -- Backup Mode"
|
||||||
;;
|
;;
|
||||||
|
@ -111,8 +125,9 @@ main() {
|
||||||
shift
|
shift
|
||||||
while [[ "$#" -gt 0 ]]; do
|
while [[ "$#" -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--sysrecue-cd-version=*)
|
--cd-version=*)
|
||||||
systemrescue_cd_version="${1#*=}"
|
systemrescue_cd_version="${1#*=}"
|
||||||
|
echoreg -d "SystemRescueCD Version arg = $systemrescue_cd_version"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -124,7 +139,7 @@ main() {
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "SystemRescue Backup -- Recovery CD"
|
echo "SystemRescue Backup -- Recovery CD"
|
||||||
echo "opt: $*"
|
echoreg -d "opt: $*"
|
||||||
if ! load_module recovery init; then
|
if ! load_module recovery init; then
|
||||||
exit_fail 200 "FATAL: Failed to load recovery init module. ($?)"
|
exit_fail 200 "FATAL: Failed to load recovery init module. ($?)"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue