diff options
author | Roger Leigh <rleigh@debian.org> | 2012-04-03 23:29:40 +0100 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2012-04-03 23:35:23 +0100 |
commit | d04e32dd3cc39ea641fc2848957292fe94751925 (patch) | |
tree | 1dcad119f35da94f9d4d66f508f19dc3fd13c90f /etc | |
parent | b8e564087278600fe72e2bf1ca334524945082d6 (diff) | |
download | schroot-d04e32dd3cc39ea641fc2848957292fe94751925.tar.gz |
etc/setup.d: Update scripts to use profile and user data
Split out sourcing of SCHROOT_SCRIPT_CONFIG/SETUP_CONFIG
into common-config script, which all setup scripts source.
Use SETUP_CONFIG, SETUP_FSTAB, SETUP_COPYFILES and
SETUP_NSSDATABASES, but permit old names to be used for
backward compatibility.
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/setup.d/00check | 7 | ||||
-rwxr-xr-x | etc/setup.d/05btrfs | 7 | ||||
-rwxr-xr-x | etc/setup.d/05file | 7 | ||||
-rwxr-xr-x | etc/setup.d/05lvm | 7 | ||||
-rwxr-xr-x | etc/setup.d/05union | 7 | ||||
-rwxr-xr-x | etc/setup.d/10mount | 22 | ||||
-rwxr-xr-x | etc/setup.d/15killprocs | 7 | ||||
-rwxr-xr-x | etc/setup.d/20copyfiles | 22 | ||||
-rwxr-xr-x | etc/setup.d/20nssdatabases | 22 | ||||
-rwxr-xr-x | etc/setup.d/50chrootname | 1 | ||||
-rw-r--r-- | etc/setup.d/Makefile.am | 1 | ||||
-rw-r--r-- | etc/setup.d/common-config | 34 |
12 files changed, 78 insertions, 66 deletions
diff --git a/etc/setup.d/00check b/etc/setup.d/00check index 5680ef1d..f7594b93 100755 --- a/etc/setup.d/00check +++ b/etc/setup.d/00check @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" # Plain chroots should not be able to use scripts, but check anyway to # be safe. diff --git a/etc/setup.d/05btrfs b/etc/setup.d/05btrfs index ccf8f3b9..bfc62f45 100755 --- a/etc/setup.d/05btrfs +++ b/etc/setup.d/05btrfs @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" if [ "$CHROOT_TYPE" = "btrfs-snapshot" ]; then diff --git a/etc/setup.d/05file b/etc/setup.d/05file index 7fa7e4bf..13cca7c2 100755 --- a/etc/setup.d/05file +++ b/etc/setup.d/05file @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" # Check file type check_filetype() diff --git a/etc/setup.d/05lvm b/etc/setup.d/05lvm index b1f04a64..2ae7bd14 100755 --- a/etc/setup.d/05lvm +++ b/etc/setup.d/05lvm @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" if [ "$VERBOSE" = "verbose" ]; then LVM_VERBOSE="-v" diff --git a/etc/setup.d/05union b/etc/setup.d/05union index 30b7cb03..89199afb 100755 --- a/etc/setup.d/05union +++ b/etc/setup.d/05union @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" if [ -n "${CHROOT_UNION_TYPE}" ] && [ "${CHROOT_UNION_TYPE}" != 'none' ]; then diff --git a/etc/setup.d/10mount b/etc/setup.d/10mount index cfd7f6c3..4c529379 100755 --- a/etc/setup.d/10mount +++ b/etc/setup.d/10mount @@ -22,12 +22,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" # Mount a filesystem # $1: mount options @@ -194,12 +189,19 @@ if [ "$CHROOT_TYPE" = "directory" ] \ do_mount "$CHROOT_MOUNT_OPTIONS" "$CHROOT_MOUNT_DEVICE" "$CHROOT_MOUNT_LOCATION" fi - if [ -n "$FSTAB" ]; then - if [ -f "$FSTAB" ]; then + # For backward compatibility + if [ -z "$SETUP_FSTAB" ]; then + SETUP_FSTAB="$FSTAB" + else + SETUP_FSTAB="${SCHROOT_SYSCONF_DIR}/${SETUP_FSTAB}" + fi + + if [ -n "$SETUP_FSTAB" ]; then + if [ -f "$SETUP_FSTAB" ]; then "$LIBEXEC_DIR/schroot-mount" $MOUNT_VERBOSE \ - -f "$FSTAB" -m "$CHROOT_PATH" + -f "$SETUP_FSTAB" -m "$CHROOT_PATH" else - fatal "fstab file '$FSTAB' does not exist" + fatal "setup_fstab file '$SETUP_FSTAB' does not exist" fi fi diff --git a/etc/setup.d/15killprocs b/etc/setup.d/15killprocs index 3b679f51..5216fc60 100755 --- a/etc/setup.d/15killprocs +++ b/etc/setup.d/15killprocs @@ -22,12 +22,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" # Wrapper around kill command. Turns errors into # warnings when running in verbose mode, otherwise diff --git a/etc/setup.d/20copyfiles b/etc/setup.d/20copyfiles index 56331197..7d8f3cbb 100755 --- a/etc/setup.d/20copyfiles +++ b/etc/setup.d/20copyfiles @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" if [ "$VERBOSE" = "verbose" ]; then CP_VERBOSE="--verbose" @@ -82,8 +77,15 @@ copy_file() if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then - if [ -n "$COPYFILES" ]; then - if [ -f "$COPYFILES" ]; then + # For backward compatibility + if [ -z "$SETUP_COPYFILES" ]; then + SETUP_COPYFILES="$COPYFILES" + else + SETUP_COPYFILES="${SCHROOT_SYSCONF_DIR}/${SETUP_COPYFILES}" + fi + + if [ -n "$SETUP_COPYFILES" ]; then + if [ -f "$SETUP_COPYFILES" ]; then while read file; do if echo "$file" | egrep -q '^(#|$)' ; then continue @@ -93,9 +95,9 @@ if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then else warn "Not copying file with relative path: $file" fi - done < "$COPYFILES" + done < "$SETUP_COPYFILES" else - fatal "copyfiles file '$COPYFILES' does not exist" + fatal "copyfiles file '$SETUP_COPYFILES' does not exist" fi fi diff --git a/etc/setup.d/20nssdatabases b/etc/setup.d/20nssdatabases index adf74257..23fe2e28 100755 --- a/etc/setup.d/20nssdatabases +++ b/etc/setup.d/20nssdatabases @@ -21,12 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" - -if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" -elif [ "$STATUS" = "ok" ]; then - fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" -fi +. "$SETUP_DATA_DIR/common-config" # Copy NSS database from host to chroot # $1: database name @@ -39,8 +34,15 @@ dup_nss() if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then - if [ -n "$NSSDATABASES" ]; then - if [ -f "$NSSDATABASES" ]; then + # For backward compatibility + if [ -z "$SETUP_NSSDATABASES" ]; then + SETUP_NSSDATABASES="$NSSDATABASES" + else + SETUP_NSSDATABASES="${SCHROOT_SYSCONF_DIR}/${SETUP_NSSDATABASES}" + fi + + if [ -n "$SETUP_NSSDATABASES" ]; then + if [ -f "$SETUP_NSSDATABASES" ]; then while read db; do if echo "$db" | egrep -q '^(#|$)' ; then continue @@ -60,9 +62,9 @@ if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then fi dup_nss "$db" "${CHROOT_PATH}/etc/$db" - done < "$NSSDATABASES" + done < "$SETUP_NSSDATABASES" else - fatal "nssdatabases file '$NSSDATABASES' does not exist" + fatal "nssdatabases file '$SETUP_NSSDATABASES' does not exist" fi fi diff --git a/etc/setup.d/50chrootname b/etc/setup.d/50chrootname index 062a0f90..9c0b53e5 100755 --- a/etc/setup.d/50chrootname +++ b/etc/setup.d/50chrootname @@ -21,6 +21,7 @@ set -e . "$SETUP_DATA_DIR/common-data" . "$SETUP_DATA_DIR/common-functions" +. "$SETUP_DATA_DIR/common-config" if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then . "$CHROOT_SCRIPT_CONFIG" diff --git a/etc/setup.d/Makefile.am b/etc/setup.d/Makefile.am index fb027e94..8087e3c6 100644 --- a/etc/setup.d/Makefile.am +++ b/etc/setup.d/Makefile.am @@ -22,6 +22,7 @@ include $(top_srcdir)/scripts/global.mk schroot_setupdata_DATA = \ + common-config \ common-data \ common-functions diff --git a/etc/setup.d/common-config b/etc/setup.d/common-config new file mode 100644 index 00000000..93a87993 --- /dev/null +++ b/etc/setup.d/common-config @@ -0,0 +1,34 @@ +# Copyright © 2012 Roger Leigh <rleigh@debian.org> +# +# schroot is free software: you can redistribute 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. +# +# schroot 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 this program. If not, see +# <http://www.gnu.org/licenses/>. +# +##################################################################### + +# Common configuration for use in schroot setup scripts + +if [ -n "${SETUP_CONFIG}" ]; then + SETUP_CONFIG="${SCHROOT_SYSCONF_DIR}/${SETUP_CONFIG}" + if [ -f "$SETUP_CONFIG" ]; then + . "$SETUP_CONFIG" + elif [ "$STATUS" = "ok" ]; then + fatal "setup script config file '$SETUP_CONFIG' does not exist" + fi +else + if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then + . "$CHROOT_SCRIPT_CONFIG" + elif [ "$STATUS" = "ok" ]; then + fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + fi +fi |