integrate-distro.sh: Add support for --config-file and --non-interactive

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2016-11-02 09:51:42 +00:00
commit 8ecffabb0a

View file

@ -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<<EOT
|$run_dev_swap swap swap defaults 0 0
|$run_dev_root / ext4 acl,user_xattr 1 1
|$run_dev_boot /boot ext4 acl,user_xattr 1 2
|$run_dev_boot /boot ext3 acl,user_xattr 1 2
EOT
}
@ -1340,6 +1385,15 @@ fi
[ ! "$scm_user" ] && scm_user=`whoami`
case $cmd in
unmount)
unmount_devices
exit $?
;;
*)
;;
esac
# -- set up variables denoting devices
if [ "$install_dev" ]; then
@ -1400,10 +1454,6 @@ mount)
setup_bind_mounts
exit $?
;;
unmount)
unmount_devices
exit $?
;;
mkinitrd)
grub_boot_partition_num=0
grub_slash_boot_partition_num=1