mirror of
https://github.com/erenfro/systemrescue-backup.git
synced 2024-12-22 00:01:09 -05:00
Updated with successful build of SystemRecue-Backup CD
This commit is contained in:
parent
3a2d0fbb4e
commit
0cc9efc3a8
10 changed files with 247 additions and 63 deletions
119
src/functions.sh
119
src/functions.sh
|
@ -15,17 +15,6 @@ scriptPath="$(dirname "$(readlink -f "$0")")"
|
||||||
configPath="$(readlink -f "${scriptPath}/../config")"
|
configPath="$(readlink -f "${scriptPath}/../config")"
|
||||||
debug=false
|
debug=false
|
||||||
|
|
||||||
if [[ ! -r "${configPath}/srb.cfg" ]]; then
|
|
||||||
# Start searching for common configuration paths
|
|
||||||
if [[ -r "$HOME/.config/systemrescue-backup/srb.cfg" ]]; then
|
|
||||||
configPath="$HOME/.config/systemrescue-backup"
|
|
||||||
elif [[ -r "/etc/systemrescue-backup/srb.cfg" ]]; then
|
|
||||||
configPath="/etc/systemrescue-backup"
|
|
||||||
else
|
|
||||||
echoerr "Warning: No configuration file path found. Defaults will be used."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
### Utility & Common Functions
|
### Utility & Common Functions
|
||||||
|
@ -35,6 +24,23 @@ is_bin_in_path() {
|
||||||
builtin type -P "$1" &>/dev/null
|
builtin type -P "$1" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if argument is number.
|
||||||
|
is_num() {
|
||||||
|
[[ -n "$1" && "$1" -eq "$1" ]] 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Convert signal name to signal number.
|
||||||
|
to_sig_num() {
|
||||||
|
if is_num "$1"; then
|
||||||
|
# Signal is already number.
|
||||||
|
kill -l "$1" >/dev/null # Check that signal number is valid.
|
||||||
|
echo "$1" # Return result.
|
||||||
|
else
|
||||||
|
# Convert to signal number.
|
||||||
|
kill -l "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echoreg() {
|
echoreg() {
|
||||||
if [[ "$1" == "-d" ]]; then
|
if [[ "$1" == "-d" ]]; then
|
||||||
shift
|
shift
|
||||||
|
@ -187,6 +193,79 @@ run_modules() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_squashfs() {
|
||||||
|
truncate -s0 "${systemrescue_data_dir}/sysrescue/build_into_srm/.squashfs-pseudo"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_to_squashfs() {
|
||||||
|
local input="$1"
|
||||||
|
|
||||||
|
if $debug; then
|
||||||
|
echo "Adding to SquashFS: $1"
|
||||||
|
fi
|
||||||
|
echo "$1" >> "${systemrescue_data_dir}/sysrescue/build_into_srm/.squashfs-pseudo"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_path_to_squashfs() {
|
||||||
|
local path="$1"
|
||||||
|
local dir_perm="$2"
|
||||||
|
local file_perm="$3"
|
||||||
|
local file_owner="$4"
|
||||||
|
local file_group="$5"
|
||||||
|
local perm
|
||||||
|
|
||||||
|
[[ -z "$dir_perm" ]] && dir_perm="755"
|
||||||
|
[[ -z "$file_perm" ]] && file_perm="644"
|
||||||
|
[[ -z "$file_owner" ]] && file_owner="root"
|
||||||
|
[[ -z "$file_group" ]] && file_group="root"
|
||||||
|
|
||||||
|
while read -r file; do
|
||||||
|
if [[ -d "$file" ]]; then
|
||||||
|
[[ "$dir_perm" == "match" ]] && perm="$(stat -c "%a" "$file")" || perm="$dir_perm"
|
||||||
|
#add_to_squashfs "${file/${systemrescue_data_dir}\/sysrescue\/build_into_srm\///} m $dir_perm root root"
|
||||||
|
elif [[ -f "$file" ]]; then
|
||||||
|
[[ "$file_perm" == "match" ]] && perm="$(stat -c "%a" "$file")" || perm="$file_perm"
|
||||||
|
#add_to_squashfs "${file/${systemrescue_data_dir}\/sysrescue\/build_into_srm\///} m $file_perm root root"
|
||||||
|
fi
|
||||||
|
add_to_squashfs "${file/${systemrescue_data_dir}\/sysrescue\/build_into_srm\///} m $perm root root"
|
||||||
|
done < <(find "$path")
|
||||||
|
}
|
||||||
|
|
||||||
|
trap_add() {
|
||||||
|
local handler="${1:?Handler required}"
|
||||||
|
#local signal="${2:?Signal required}"
|
||||||
|
local signals=("${@:2}")
|
||||||
|
local hdls
|
||||||
|
local signal
|
||||||
|
|
||||||
|
if [[ "${#signals[@]}" -lt 1 ]]; then
|
||||||
|
echo_fail 1 "Signal required"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $debug; then
|
||||||
|
echo "====================================================="
|
||||||
|
fi
|
||||||
|
|
||||||
|
for signal in "${signals[@]}"; do
|
||||||
|
hdls="$( trap -p "${signal}" | cut -f2 -d \' )"
|
||||||
|
trap "${hdls}${hdls:+;}${handler}" "${signal}"
|
||||||
|
if $debug; then
|
||||||
|
echo "Adding Trap: $handler (${signal})"
|
||||||
|
echo "Old Traps: $hdls"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if $debug; then
|
||||||
|
echo "Current Traps:"
|
||||||
|
trap -p "${signals[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $debug; then
|
||||||
|
echo "====================================================="
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
### BACKUP and RESTORE FUNCTIONS
|
### BACKUP and RESTORE FUNCTIONS
|
||||||
###########################################################
|
###########################################################
|
||||||
|
@ -243,7 +322,7 @@ restore_btrfs_subvolumes() {
|
||||||
done < "${restoreDir}/btrfs.dump"
|
done < "${restoreDir}/btrfs.dump"
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_btfs_mounts() {
|
restore_btrfs_mounts() {
|
||||||
local rootBase mountSource mountDest
|
local rootBase mountSource mountDest
|
||||||
|
|
||||||
rootBase="$1"
|
rootBase="$1"
|
||||||
|
@ -257,3 +336,19 @@ restore_btfs_mounts() {
|
||||||
mount "$mountSource" "${rootBase}/${mountDest}"
|
mount "$mountSource" "${rootBase}/${mountDest}"
|
||||||
done < "$restoreDir/mounts.dump"
|
done < "$restoreDir/mounts.dump"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
### Initialization
|
||||||
|
###########################################################
|
||||||
|
|
||||||
|
if [[ ! -r "${configPath}/srb.cfg" ]]; then
|
||||||
|
# Start searching for common configuration paths
|
||||||
|
if [[ -r "$HOME/.config/systemrescue-backup/srb.cfg" ]]; then
|
||||||
|
configPath="$HOME/.config/systemrescue-backup"
|
||||||
|
elif [[ -r "/etc/systemrescue-backup/srb.cfg" ]]; then
|
||||||
|
configPath="/etc/systemrescue-backup"
|
||||||
|
else
|
||||||
|
echoerr "Warning: No configuration file path found. Defaults will be used."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
7
src/recovery/execute/100_build
Normal file
7
src/recovery/execute/100_build
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
"${systemrescue_data_dir}/systemrescue-customize" --auto --overwrite \
|
||||||
|
--source="${systemrescue_cache_dir}/systemrescue-${systemrescue_cd_version}-amd64.iso" \
|
||||||
|
--dest="${systemrescue_data_dir}/systemrescue-backup-${systemrescue_cd_version}-amd64.iso" \
|
||||||
|
--recipe-dir="${systemrescue_data_dir}/sysrescue" \
|
||||||
|
--work-dir="${systemrescue_temp_dir}/customize"
|
|
@ -1,8 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
umount "${systemrescue_data_dir}/build/build_into_srm/var/backups/systemrescue-backup/backupdb" &>/dev/null
|
umount "${systemrescue_data_dir}/sysrescue/build_into_srm/var/backups/systemrescue-backup/backupdb" &>/dev/null
|
||||||
umount "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile" &>/dev/null
|
umount "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/resticprofile" &>/dev/null
|
||||||
|
|
||||||
if [[ -d "${systemrescue_data_dir}/build/build_into_srm" ]]; then
|
if [[ -d "${systemrescue_data_dir}/sysrescue/build_into_srm" ]]; then
|
||||||
rm -rf "${systemrescue_data_dir}/build/build_into_srm" || exit 1
|
rm -rf "${systemrescue_data_dir}/sysrescue/build_into_srm" || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "${systemrescue_temp_dir}/customize" ]]; then
|
||||||
|
rm -rf "${systemrescue_temp_dir}/customize" || exit_fail 100 "Failed to clean up directory: ${systemrescue_temp_dir}/customize"
|
||||||
fi
|
fi
|
||||||
|
|
5
src/recovery/prepare/050_preprocess
Normal file
5
src/recovery/prepare/050_preprocess
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -n "$systemrescue_cd_iso_url" ]]; then
|
||||||
|
systemrescue_cd_iso_url="${systemrescue_cd_iso_url//\{SYSRESCUECD_VERSION\}/$systemrescue_cd_version}"
|
||||||
|
fi
|
|
@ -1,21 +1,64 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
mkdir -p "$systemrescue_data_dir" || return 1
|
# Ensure initial required directories exist
|
||||||
mkdir -p "$systemrescue_temp_dir" || return 1
|
mkdir -p "$systemrescue_data_dir" || exit_fail 10 "FATAL: Failed to create systemrescue_data_dir"
|
||||||
mkdir -p "$systemrescue_cache_dir" || return 1
|
mkdir -p "$systemrescue_cache_dir" || exit_fail 10 "FATAL: Failed to create systemrescue_cache_dir"
|
||||||
|
if [[ -d "$systemrescue_temp_dir" ]]; then
|
||||||
|
# Clean out Temporary Directory
|
||||||
|
rm -rf "$systemrescue_temp_dir" || exit_fail 10 "FATAL: Failed to clean systemrescue_temp_dir"
|
||||||
|
fi
|
||||||
|
mkdir -p "$systemrescue_temp_dir" || exit_fail 10 "FATAL: Failed to create systemrescue_temp_dir"
|
||||||
|
trap_add "rm -rf \"$systemrescue_temp_dir\"" EXIT
|
||||||
|
|
||||||
mkdir -p "${systemrescue_data_dir}/build/build_into_srm/var/backups/systemrescue-backup/backupdb" || return 1
|
# Download SystemRescueCD ISO and Customize script
|
||||||
#mount --bind "${systemrescue_data_dir}/backupdb" "${systemrescue_data_dir}/build/build_into_srm/var/backups/systemrescue-backup/backupdb" || exit 1
|
curl -C - -Lso \
|
||||||
if ! mount --bind "${systemrescue_data_dir}/backupdb" "${systemrescue_data_dir}/build/build_into_srm/var/backups/systemrescue-backup/backupdb"; then
|
"${systemrescue_cache_dir}/systemrescue-${systemrescue_cd_version}-amd64.iso" \
|
||||||
if ! cp -a "${systemrescue_data_dir}/backupdb/" "${systemrescue_data_dir}/build/build_into_srm/var/backups/systemrescue-backup/backupdb/"; then
|
"$systemrescue_cd_iso_url"
|
||||||
exit_fail 205 "FATAL: Failed to copy backupdb files over to recovery image build"
|
curl -C - -Lso \
|
||||||
fi
|
"${systemrescue_data_dir}/systemrescue-customize" \
|
||||||
|
"$systemrescue_cd_customize_url"
|
||||||
|
chmod 755 "${systemrescue_data_dir}/systemrescue-customize"
|
||||||
|
mkdir "${systemrescue_temp_dir}/customize" || exit_fail 10 "FATAL: Failed to create customize directory in systemrescue_temp_dir"
|
||||||
|
|
||||||
|
# Copy SysRescue Skeleton configuration over to Disc staging directory
|
||||||
|
mkdir -p "${systemrescue_data_dir}/sysrescue" || exit_fail 10 "FATAL: Could not create sysrescue directory in systemrescue_data_dir"
|
||||||
|
if ! cp -a "${configPath}/sysrescue/." "${systemrescue_data_dir}/sysrecue/"; then
|
||||||
|
exit_fail 205 "FATAL: Failed to copy sysrescue config files over to recovery image build"
|
||||||
|
fi
|
||||||
|
trap_add "rm -rf \"${systemrescue_data_dir}/sysrescue\"" EXIT
|
||||||
|
|
||||||
|
# Copy SystemRescue-Backup Configuration to Disc staging directory
|
||||||
|
mkdir -p "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/systemrescue-backup" || exit_fail 10 "FATAL: Could not create sysrescue config directory in systemrescue_data_dir"
|
||||||
|
if ! cp -a "${configPath}/." "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/systemrescue-backup/"; then
|
||||||
|
exit_fail 205 "FATAL: Failed to copy SRB config files over to recovery image build"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# mkdir -p "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile"
|
# Copy backupdb to Disc staging directory
|
||||||
# if ! mount --bind "${resticprofile_config_dir}" "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile"; then
|
mkdir -p "${systemrescue_data_dir}/sysrescue/build_into_srm/var/backups/systemrescue-backup/backupdb" || exit_fail 10 "FATAL: Could not create backupdb directory in systemrescue_data_dir"
|
||||||
# if ! cp -a "${resticprofile_config_dir}" "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile"; then
|
if ! cp -a "${systemrescue_data_dir}/backupdb/." "${systemrescue_data_dir}/sysrescue/build_into_srm/var/backups/systemrescue-backup/backupdb/"; then
|
||||||
# exit_fail 205 "FATAL: Failed to copy resticprofile config files over to recovery image build"
|
exit_fail 205 "FATAL: Failed to copy backupdb files over to recovery image build"
|
||||||
# fi
|
fi
|
||||||
# fi
|
|
||||||
#mount --bind "/etc/resticprofile" "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile" || return 1
|
# Copy SystemRescue-Backup to Disc staging directory
|
||||||
|
mkdir -p "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/lib/systemrescue-backup" || exit_fail 10 "FATAL: Could not create SystemRescueBackup Script directory in systemrescue_data_dir"
|
||||||
|
if ! cp -a "${scriptPath}/." "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/lib/systemrescue-backup/"; then
|
||||||
|
exit_fail 205 "FATAL: Failed to copy SystemRescue-Backup Scripts over to recovery image build"
|
||||||
|
fi
|
||||||
|
mkdir -p "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin" || exit_fail 10 "FATAL: Could not create usr/local/bin directory in systemrescue_data_dir"
|
||||||
|
if ! ln -srf "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/lib/systemrescue-backup/srb" "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin/srb"; then
|
||||||
|
exit_fail 205 "FATAL: Failed to create srb symlink in usr/local/bin in recovery image build directory"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup SquashFS-Pseudo Permissions on files & directories.
|
||||||
|
init_squashfs
|
||||||
|
add_to_squashfs "/etc m 755 root root"
|
||||||
|
add_to_squashfs "/var m 755 root root"
|
||||||
|
add_to_squashfs "/usr m 755 root root"
|
||||||
|
add_to_squashfs "/usr/lib m 755 root root"
|
||||||
|
add_to_squashfs "/usr/local m 755 root root"
|
||||||
|
add_to_squashfs "/usr/local/bin m 755 root root"
|
||||||
|
|
||||||
|
add_path_to_squashfs "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/systemrescue-backup" 700 600
|
||||||
|
add_path_to_squashfs "${systemrescue_data_dir}/sysrescue/build_into_srm/var/backups" 700 600
|
||||||
|
add_path_to_squashfs "${systemrescue_data_dir}/sysrescue/build_into_srm/root" 700 600
|
||||||
|
add_path_to_squashfs "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/lib/systemrescue-backup" match match
|
||||||
|
|
3
src/resticprofile/execute/100_null
Normal file
3
src/resticprofile/execute/100_null
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Placemat for doing nothing.
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ -d "${systemrescue_data_dir}/build/build_into_srm/usr/local/bin" ]]; then
|
if [[ -d "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin" ]]; then
|
||||||
rm -rf "${systemrescue_data_dir}/build/build_into_srm/usr/local/bin" || return 1
|
rm -rf "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -5,6 +5,8 @@ echoreg -d "Loaded resticprofile Recovery Module Initialization"
|
||||||
# Setup Defaults according to what's been develeoped and tested
|
# Setup Defaults according to what's been develeoped and tested
|
||||||
restic_version="0.17.0"
|
restic_version="0.17.0"
|
||||||
resticprofile_version="0.28.0"
|
resticprofile_version="0.28.0"
|
||||||
|
restic_url="https://github.com/restic/restic/releases/download/v{RESTIC_VERSION}/restic_{RESTIC_VERSION}_linux_amd64.bz2"
|
||||||
|
resticprofile_url="https://github.com/creativeprojects/resticprofile/releases/download/v{RESTICPROFILE_VERSION}/resticprofile_{RESTICPROFILE_VERSION}_linux_amd64.tar.gz"
|
||||||
resticprofile_config_dir="/etc/resticprofile"
|
resticprofile_config_dir="/etc/resticprofile"
|
||||||
|
|
||||||
resticprofile_init_find_config() {
|
resticprofile_init_find_config() {
|
||||||
|
|
9
src/resticprofile/prepare/050_preprocess
Normal file
9
src/resticprofile/prepare/050_preprocess
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -n "$restic_url" ]]; then
|
||||||
|
restic_url="${restic_url//\{RESTIC_VERSION\}/$restic_version}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$resticprofile_url" ]]; then
|
||||||
|
resticprofile_url="${resticprofile_url//\{RESTICPROFILE_VERSION\}/$resticprofile_version}"
|
||||||
|
fi
|
|
@ -4,47 +4,63 @@ echoreg "Using SystemRescueCD Version: $systemrescue_cd_version"
|
||||||
echoreg "Using Restic Version: $restic_version"
|
echoreg "Using Restic Version: $restic_version"
|
||||||
echoreg "Using ResticProfile Version: $resticprofile_version"
|
echoreg "Using ResticProfile Version: $resticprofile_version"
|
||||||
|
|
||||||
mkdir -p "${systemrescue_cache_dir}" || return 1
|
# Create iniital required staging directories
|
||||||
mkdir -p "${systemrescue_data_dir}/build/build_into_srm/usr/local/bin" || return 1
|
mkdir -p "${systemrescue_cache_dir}" || exit_fail 100 "FATAL: Could not create systemrescue_cache_dir"
|
||||||
mkdir -p "${systemrescue_temp_dir}/restic-install" || return 1
|
mkdir -p "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin" || exit_fail 100 "FATAL: Could not create directory: ${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin"
|
||||||
|
mkdir -p "${systemrescue_temp_dir}/restic-install" || exit_fail 100 "FATAL: Could not create directory: ${systemrescue_temp_dir}/restic-install"
|
||||||
|
|
||||||
|
# Download, Extract, and Install if it's not cached already: restic
|
||||||
if [[ ! -f "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64.bz2" ]]; then
|
if [[ ! -f "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64.bz2" ]]; then
|
||||||
curl -C - -Lso "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64.bz2" "https://github.com/restic/restic/releases/download/v${restic_version}/restic_${restic_version}_linux_amd64.bz2" || return 1
|
curl -C - -Lso \
|
||||||
|
"${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64.bz2" \
|
||||||
|
"$restic_url"
|
||||||
fi
|
fi
|
||||||
bunzip2 -k "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64.bz2" || return 1
|
bunzip2 -kf "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64.bz2" || exit_fail 101 "FATAL: Failed to extract restic binary"
|
||||||
chmod 755 "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64"
|
chmod 755 "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64"
|
||||||
chown root:root "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64"
|
chown root:root "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64"
|
||||||
mv "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64" "${systemrescue_data_dir}/build/build_into_srm/usr/local/bin/restic" || return 1
|
mv "${systemrescue_cache_dir}/restic_${restic_version}_linux_amd64" "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin/restic" || exit_fail 102 "FATAL: Failed to move restic binary to sysrescue build directory"
|
||||||
|
|
||||||
|
# Download, Extract, and Install if it's not cached already: resticprofile
|
||||||
if [[ ! -f "${systemrescue_cache_dir}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" ]]; then
|
if [[ ! -f "${systemrescue_cache_dir}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" ]]; then
|
||||||
curl -C - -Lso "${systemrescue_cache_dir}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" "https://github.com/creativeprojects/resticprofile/releases/download/v${resticprofile_version}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" || return 1
|
curl -C - -Lso \
|
||||||
|
"${systemrescue_cache_dir}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" \
|
||||||
|
"$resticprofile_url"
|
||||||
|
#"https://github.com/creativeprojects/resticprofile/releases/download/v${resticprofile_version}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" || return 1
|
||||||
fi
|
fi
|
||||||
tar -xzf "${systemrescue_cache_dir}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" -C "${systemrescue_temp_dir}/restic-install" || return 1
|
tar -xzf "${systemrescue_cache_dir}/resticprofile_${resticprofile_version}_linux_amd64.tar.gz" -C "${systemrescue_temp_dir}/restic-install" || exit_fail 101 "FATAL: Failed to extract resticprofile archive"
|
||||||
chmod 755 "${systemrescue_temp_dir}/restic-install/resticprofile"
|
chmod 755 "${systemrescue_temp_dir}/restic-install/resticprofile"
|
||||||
chown root:root "${systemrescue_temp_dir}/restic-install/resticprofile"
|
chown root:root "${systemrescue_temp_dir}/restic-install/resticprofile"
|
||||||
mv "${systemrescue_temp_dir}/restic-install/resticprofile" "${systemrescue_data_dir}/build/build_into_srm/usr/local/bin/resticprofile" || return 1
|
mv "${systemrescue_temp_dir}/restic-install/resticprofile" "${systemrescue_data_dir}/sysrescue/build_into_srm/usr/local/bin/resticprofile" || exit_fail 102 "FATAL: Failed to move resticprofile binary to sysrescue build directory"
|
||||||
rm -rf "${systemrescue_temp_dir}/restic-install" || return 1
|
rm -rf "${systemrescue_temp_dir}/restic-install" || exit_fail 100 "FATAL: Failed to remove temporary restic-install directory"
|
||||||
|
|
||||||
mkdir -p "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile"
|
# Copy resticprofile configuration to Disc staging directory
|
||||||
if ! mount --bind "${resticprofile_config_dir}" "${systemrescue_data_dir}/build/build_into_srm/etc/resticprofile"; then
|
mkdir -p "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/resticprofile"
|
||||||
if ! cp -a "${resticprofile_config_dir}" "${systemrescue_data_dir}/build/build_into_srm/etc/"; then
|
if ! cp -a "${resticprofile_config_dir}/." "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/resticprofile/"; then
|
||||||
exit_fail 205 "FATAL: Failed to copy resticprofile config files over to recovery image build"
|
exit_fail 205 "FATAL: Failed to copy resticprofile config files over to recovery image build"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $debug; then
|
add_to_squashfs "/usr/local/bin/restic m 755 root root"
|
||||||
echo "==========================================================================="
|
add_to_squashfs "/usr/local/bin/resticprofile m 755 root root"
|
||||||
echo "Cache Dir: $systemrescue_cache_dir"
|
add_path_to_squashfs "${systemrescue_data_dir}/sysrescue/build_into_srm/etc/resticprofile" 700 600
|
||||||
ls -lR "$systemrescue_cache_dir"
|
|
||||||
echo "====="
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Data Dir: $systemrescue_data_dir"
|
# if $debug; then
|
||||||
ls -lR "$systemrescue_data_dir"
|
# echo "==========================================================================="
|
||||||
echo "====="
|
# echo "Cache Dir: $systemrescue_cache_dir"
|
||||||
echo
|
# ls -lR "$systemrescue_cache_dir"
|
||||||
|
# echo "====="
|
||||||
|
# echo
|
||||||
|
|
||||||
echo "Temp Dir: $systemrescue_temp_dir"
|
# echo "Data Dir: $systemrescue_data_dir"
|
||||||
ls -lR "$systemrescue_temp_dir"
|
# ls -lR "$systemrescue_data_dir"
|
||||||
echo "==========================================================================="
|
# echo "====="
|
||||||
fi
|
# echo
|
||||||
|
|
||||||
|
# echo "Temp Dir: $systemrescue_temp_dir"
|
||||||
|
# ls -lR "$systemrescue_temp_dir"
|
||||||
|
# echo "==========================================================================="
|
||||||
|
|
||||||
|
# echo "SquashFS Definitions:"
|
||||||
|
# echo
|
||||||
|
# cat "${systemrescue_data_dir}/sysrescue/build_into_srm/.squashfs-pseudo"
|
||||||
|
# echo "==========================================================================="
|
||||||
|
# fi
|
||||||
|
|
Loading…
Reference in a new issue