Skip to content

Commit

Permalink
Convert YUM files which were symlinks to other, non-YUM files to copi…
Browse files Browse the repository at this point in the history
…es of those files
  • Loading branch information
N3WWN committed Sep 8, 2017
1 parent 6ca926b commit 3d9cc24
Show file tree
Hide file tree
Showing 9 changed files with 824 additions and 9 deletions.

This file was deleted.

14 changes: 14 additions & 0 deletions usr/share/rear/build/YUM/default/600_create_python_symlink.sh
@@ -0,0 +1,14 @@
# Copied from ../../DUPLICITY/default/600_create_python_symlink.sh for YUM
# make sure we have a symbolic link to the python binary
(
cd $ROOTFS_DIR/bin
for py in $(find . -name "python*" )
do
this_py=${py#./*} # should be without ./
case $this_py in
python) break ;;
python2*|python3*) ln -sf $v $this_py python >&2 ;;
esac
done
)

1 change: 0 additions & 1 deletion usr/share/rear/prep/YUM/default/070_set_backup_archive.sh

This file was deleted.

300 changes: 300 additions & 0 deletions usr/share/rear/prep/YUM/default/070_set_backup_archive.sh

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh

This file was deleted.

13 changes: 13 additions & 0 deletions usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh
@@ -0,0 +1,13 @@
# Copied from ../../NETFS/default/100_mount_NETFS_path.sh a.k.a. ../../../backup/NETFS/default/100_mount_NETFS_path.sh for YUM

# create mount point
mkdir -p $v "$BUILD_DIR/outputfs" >&2
StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"

AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"

if [[ "$BACKUP_MOUNTCMD" ]] ; then
BACKUP_URL="var://BACKUP_MOUNTCMD"
fi

mount_url $BACKUP_URL $BUILD_DIR/outputfs $BACKUP_OPTIONS

This file was deleted.

39 changes: 39 additions & 0 deletions usr/share/rear/restore/YUM/default/970_set_root_password.sh
@@ -0,0 +1,39 @@
# Copied from ../../ZYPPER/default/970_set_root_password.sh for YUM
#
# restore/ZYPPER/default/970_set_root_password.sh
# 970_set_root_password.sh is a finalisation script (see restore/readme)
# that sets the initial root password in the target system
# after the files have been restored into the target system
# so that the 'passwd' executable can be called inside the target system
# to avoid a 'passwd' executable is needed in the ReaR recovery system.
# This initial root password should not be the actually intended root password
# because its value is stored in usually insecure files (e.g. /etc/rear/local.conf)
# which are included in the ReaR recovery system that is stored
# in also usually insecure files (like ISO images e.g. rear-HOSTNAME.iso)
# so that the actually intended root password for the target system
# should be set manually by the admin after "rear recover".
#

# Try to care about possible errors
# see https://github.com/rear/rear/wiki/Coding-Style
set -e -u -o pipefail

# As fallback use 'root' as root password in the target system.
# A non-empty fallback is needed because 'passwd' does not accept empty input:
local root_password="root"
# If SSH_ROOT_PASSWORD is specified used that as root password in the target system:
test "$SSH_ROOT_PASSWORD" && root_password="$SSH_ROOT_PASSWORD"
# If ZYPPER_ROOT_PASSWORD is specified used that as root password in the target system:
test "$ZYPPER_ROOT_PASSWORD" && root_password="$ZYPPER_ROOT_PASSWORD"

# Set the root password in the target system.
# Use a login shell in between so that one has in the chrooted environment
# all the advantages of a "normal working shell" which means one can write
# the commands inside 'chroot' as one would type them in a normal working shell.
# In particular one can call programs (like 'passwd') by their basename without path
# cf. https://github.com/rear/rear/issues/862#issuecomment-274068914
chroot $TARGET_FS_ROOT /bin/bash --login -c "echo -e '$root_password\n$root_password' | passwd root"

# Restore the ReaR default bash flags and options (see usr/sbin/rear):
apply_bash_flags_and_options_commands "$DEFAULT_BASH_FLAGS_AND_OPTIONS_COMMANDS"

1 change: 0 additions & 1 deletion usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh

This file was deleted.

15 changes: 15 additions & 0 deletions usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh
@@ -0,0 +1,15 @@
# Copied from ../../../backup/NETFS/default/980_umount_NETFS_dir.sh for YUM

# umount NETFS mountpoint

if [[ "$BACKUP_UMOUNTCMD" ]] ; then
BACKUP_URL="var://BACKUP_UMOUNTCMD"
fi

umount_url $BACKUP_URL $BUILD_DIR/outputfs

rmdir $v $BUILD_DIR/outputfs >&2
if [[ $? -eq 0 ]] ; then
# the argument to RemoveExitTask has to be identical to the one given to AddExitTask
RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
fi

This file was deleted.

117 changes: 117 additions & 0 deletions usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh
@@ -0,0 +1,117 @@
# Copied from ../../../prep/NETFS/default/050_check_NETFS_requirements.sh for YUM
# BACKUP_URL=[proto]://[host]/[share]
# example: nfs://lucky/temp/backup
# example: cifs://lucky/temp
# example: usb:///dev/sdb1
# example: tape:///dev/nst0
# example: file:///path
# example: iso://backup/
# example: sshfs://user@host/G/rear/
# example: ftpfs://user:password@host/rear/ (the password part is optional)

[[ "$BACKUP_URL" || "$BACKUP_MOUNTCMD" ]]
# FIXME: The above test does not match the error message below.
# To match the the error message the test should be
# [[ "$BACKUP_URL" || ( "$BACKUP_MOUNTCMD" && "$BACKUP_UMOUNTCMD" ) ]]
# but I <jsmeix@suse.de> cannot decide if there is a subtle reason for the omission.
StopIfError "You must specify either BACKUP_URL or BACKUP_MOUNTCMD and BACKUP_UMOUNTCMD !"

if [[ "$BACKUP_URL" ]] ; then
local scheme=$( url_scheme $BACKUP_URL )
local hostname=$( url_hostname $BACKUP_URL )
local path=$( url_path $BACKUP_URL )

### check for vaild BACKUP_URL schemes
### see https://github.com/rear/rear/issues/842
case $scheme in
(nfs|cifs|usb|tape|file|iso|sshfs|ftpfs)
# do nothing for vaild BACKUP_URL schemes
:
;;
(*)
Error "Invalid scheme '$scheme' in BACKUP_URL '$BACKUP_URL' valid schemes: nfs cifs usb tape file iso sshfs ftpfs"
;;
esac

### set other variables from BACKUP_URL
if [[ "usb" = "$scheme" ]] ; then
# if USB_DEVICE is not explicitly specified it is the path from BACKUP_URL
[[ -z "$USB_DEVICE" ]] && USB_DEVICE="$path"
fi

### check if host is reachable
if [[ "$PING" && "$hostname" ]] ; then
# Only LogPrintIfError but no StopIfError because it is not a fatal error
# (i.e. not a reason to abort) when a host does not respond to a 'ping'
# because hosts can be accessible via certain ports but do not respond to a 'ping'
# cf. https://bugzilla.opensuse.org/show_bug.cgi?id=616706
# TODO: it would be better to test if it is accessible via the actually needed port(s)
ping -c 2 "$hostname" >/dev/null
LogPrintIfError "Host '$hostname' in BACKUP_URL '$BACKUP_URL' does not respond to a 'ping'."
else
Log "Skipping 'ping' test for host '$hostname' in BACKUP_URL '$BACKUP_URL'"
fi

fi

# some backup progs require a different backuparchive name
case "$(basename $BACKUP_PROG)" in
(rsync)
# rsync creates a target directory instead of a file
BACKUP_PROG_SUFFIX=
BACKUP_PROG_COMPRESS_SUFFIX=
;;
(*)
:
;;
esac

# include required programs
# the code below includes mount.* and umount.* programs for all non-empty schemes
# (i.e. for any non-empty BACKUP_URL like usb tape file sshfs ftpfs)
# and it includes 'mount.' for empty schemes (e.g. if BACKUP_URL is not set)
# which is o.k. because it is a catch all rule so we do not miss any
# important executable needed a certain scheme and it does not hurt
# see https://github.com/rear/rear/pull/859
PROGS=( "${PROGS[@]}"
showmount
mount.$(url_scheme $BACKUP_URL)
umount.$(url_scheme $BACKUP_URL)
$( test "$BACKUP_MOUNTCMD" && echo "${BACKUP_MOUNTCMD%% *}" )
$( test "$BACKUP_UMOUNTCMD" && echo "${BACKUP_UMOUNTCMD%% *}" )
$BACKUP_PROG
gzip
bzip2
xz
)

# include required stuff for sshfs or ftpfs (via CurlFtpFS)
if [[ "sshfs" = "$scheme" || "ftpfs" = "$scheme" ]] ; then
# both sshfs and ftpfs (via CurlFtpFS) are based on FUSE
PROGS=( "${PROGS[@]}" fusermount mount.fuse )
MODULES=( "${MODULES[@]}" fuse )
MODULES_LOAD=( "${MODULES_LOAD[@]}" fuse )
COPY_AS_IS=( "${COPY_AS_IS[@]}" /etc/fuse.conf )
# include what is specific for sshfs
if [[ "sshfs" = "$scheme" ]] ; then
# see http://sourceforge.net/apps/mediawiki/fuse/index.php?title=SshfsFaq
REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" sshfs )
# as we're using SSH behind the scenes we need our keys/config file saved
COPY_AS_IS=( "${COPY_AS_IS[@]}" $HOME/.ssh )
fi
# include what is specific for ftpfs
if [[ "ftpfs" = "$scheme" ]] ; then
# see http://curlftpfs.sourceforge.net/
# and https://github.com/rear/rear/issues/845
REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" curlftpfs )
fi
fi

# include required modules, like nfs cifs ...
# the code below includes modules for all non-empty schemes
# (i.e. for any non-empty BACKUP_URL like usb tape file sshfs ftpfs)
# which is o.k. because this must been seen as a catch all rule
# (one never knows what one could miss)
# see https://github.com/rear/rear/pull/859
MODULES=( "${MODULES[@]}" $(url_scheme $BACKUP_URL) )

1 change: 0 additions & 1 deletion usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh

This file was deleted.

12 changes: 12 additions & 0 deletions usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh
@@ -0,0 +1,12 @@
# Copied from ../../../backup/NETFS/default/100_mount_NETFS_path.sh for YUM
# create mount point
mkdir -p $v "$BUILD_DIR/outputfs" >&2
StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"

AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"

if [[ "$BACKUP_MOUNTCMD" ]] ; then
BACKUP_URL="var://BACKUP_MOUNTCMD"
fi

mount_url $BACKUP_URL $BUILD_DIR/outputfs $BACKUP_OPTIONS

This file was deleted.

0 comments on commit 3d9cc24

Please sign in to comment.