From 8ecffabb0ae3ac2a74c09b0ea00138f96bf6b3a9 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 2 Nov 2016 09:51:42 +0000 Subject: [PATCH] integrate-distro.sh: Add support for --config-file and --non-interactive Signed-off-by: Jan Lindemann --- scripts/integrate-distro.sh | 62 +++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/scripts/integrate-distro.sh b/scripts/integrate-distro.sh index c2530f1d..2d7f7dc6 100644 --- a/scripts/integrate-distro.sh +++ b/scripts/integrate-distro.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ini-tools.sh + # -- defaults # install_dev=/dev/sdb arch=`uname -m` @@ -440,12 +442,19 @@ usage() get_opts() { - eval set -- `getopt -o 'hd:n:a:p:k:u:w:s:r:f' -l parted-script: -- "$@"` + eval set -- `getopt -o 'hd:n:a:p:k:u:w:s:r:fc:' -l parted-script:,config-file:,non-interactive -- "$@"` while [ "$1" != -- ] ; do case "$1" in -h) usage 0 ;; + -c|--config-file) + config_file="$2" + shift + ;; + --non-interactive) + non_interactive=1 + ;; -d) install_dev=$2 shift @@ -557,6 +566,38 @@ check_var_set() return $r } +have_cfg_file() +{ + [ "$config_file" ] || return 1 + [ -r "$config_file" ] || { + fatal "failed to read config file \"$config_file\"" + } +} + +have_cfg_section() +{ + have_cfg_file || return 1 + ini_has_section "$config_file" "$@" || return 1 +} + +have_cfg_value() +{ + have_cfg_file || return 1 + ini_has_value "$config_file" "$@" || return 1 +} + +cfg_section() +{ + have_cfg_file || return 1 + ini_section "$config_file" "$@" +} + +cfg_value() +{ + have_cfg_file || return 1 + ini_value "$config_file" "$@" +} + _run_chroot() { local cmd @@ -624,6 +665,10 @@ parted_script() cat $parted_script return fi + if have_cfg_section parted; then + ini_section "$config_file" parted + return + fi default_parted_script } @@ -811,7 +856,7 @@ make_etc_fstab_local_boot() _cat<