Skip to content

Commit

Permalink
Moved the source of CONFIG_APPEND_FILES to 'init' stage (see: issue r…
Browse files Browse the repository at this point in the history
  • Loading branch information
didacog committed Mar 15, 2017
1 parent 5bd1a18 commit 95b1fa7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
44 changes: 0 additions & 44 deletions usr/sbin/rear
Expand Up @@ -414,50 +414,6 @@ done
for config in site local rescue ; do
test -r "$CONFIG_DIR/$config.conf" && Source "$CONFIG_DIR/$config.conf" || true
done
# Finally source additional configuration files if specified on the command line:
if test "$CONFIG_APPEND_FILES" ; then
# If DRLM_MANAGED=y additional configuration files will be loaded by DRLM:
if drlm_is_managed ; then
LogPrint "DRLM_MANAGED: DRLM will load additional configuration files: $CONFIG_APPEND_FILES"
else
for config_append_file in $CONFIG_APPEND_FILES ; do
# If what is specified on the command line starts with '/' an absolute path is meant
# otherwise what is specified on the command line means a file in CONFIG_DIR.
# Files in CONFIG_DIR get automatically copied into the recovery system but
# other files are added to COPY_AS_IS to get them copied into the recovery system:
case "$config_append_file" in
(/*)
config_append_file_path="$config_append_file"
# If "-C foo" was specified on the command line but 'foo' does not exist
# try if 'foo.conf' exists and if yes, use that:
if test -r "$config_append_file_path" ; then
COPY_AS_IS=( "${COPY_AS_IS[@]}" "$config_append_file_path" )
else if test -r "$config_append_file_path.conf" ; then
COPY_AS_IS=( "${COPY_AS_IS[@]}" "$config_append_file_path.conf" )
else
Error "There is '-C $config_append_file' but neither '$config_append_file_path' nor '$config_append_file_path.conf' can be read."
fi
fi
;;
(*)
config_append_file_path="$CONFIG_DIR/$config_append_file"
;;
esac
# If "-C foo" was specified on the command line but 'foo' does not exist
# try if 'foo.conf' exists and if yes, use that:
if test -r "$config_append_file_path" ; then
LogPrint "Sourcing additional configuration file '$config_append_file_path'"
Source "$config_append_file_path"
else if test -r "$config_append_file_path.conf" ; then
LogPrint "Sourcing additional configuration file '$config_append_file_path.conf'"
Source "$config_append_file_path.conf"
else
Error "There is '-C $config_append_file' but neither '$config_append_file_path' nor '$config_append_file_path.conf' can be read."
fi
fi
done
fi
fi

# Now SHARE_DIR CONFIG_DIR VAR_DIR LOG_DIR and KERNEL_VERSION should be set to a fixed value:
readonly SHARE_DIR CONFIG_DIR VAR_DIR LOG_DIR KERNEL_VERSION
Expand Down
44 changes: 44 additions & 0 deletions usr/share/rear/init/default/005_set_config_append_files.sh
@@ -0,0 +1,44 @@

if drlm_is_managed ; then
return 0
fi

# source additional configuration files if specified on the command line:
if test "$CONFIG_APPEND_FILES" ; then
for config_append_file in $CONFIG_APPEND_FILES ; do
# If what is specified on the command line starts with '/' an absolute path is meant
# otherwise what is specified on the command line means a file in CONFIG_DIR.
# Files in CONFIG_DIR get automatically copied into the recovery system but
# other files are added to COPY_AS_IS to get them copied into the recovery system:
case "$config_append_file" in
(/*)
config_append_file_path="$config_append_file"
# If "-C foo" was specified on the command line but 'foo' does not exist
# try if 'foo.conf' exists and if yes, use that:
if test -r "$config_append_file_path" ; then
COPY_AS_IS=( "${COPY_AS_IS[@]}" "$config_append_file_path" )
else if test -r "$config_append_file_path.conf" ; then
COPY_AS_IS=( "${COPY_AS_IS[@]}" "$config_append_file_path.conf" )
else
Error "There is '-C $config_append_file' but neither '$config_append_file_path' nor '$config_append_file_path.conf' can be read."
fi
fi
;;
(*)
config_append_file_path="$CONFIG_DIR/$config_append_file"
;;
esac
# If "-C foo" was specified on the command line but 'foo' does not exist
# try if 'foo.conf' exists and if yes, use that:
if test -r "$config_append_file_path" ; then
LogPrint "Sourcing additional configuration file '$config_append_file_path'"
Source "$config_append_file_path"
else if test -r "$config_append_file_path.conf" ; then
LogPrint "Sourcing additional configuration file '$config_append_file_path.conf'"
Source "$config_append_file_path.conf"
else
Error "There is '-C $config_append_file' but neither '$config_append_file_path' nor '$config_append_file_path.conf' can be read."
fi
fi
done
fi

0 comments on commit 95b1fa7

Please sign in to comment.