# This bash script is sourced by the various tools to set the
# adt_... variables and some other useful ones.
+set -e${ADT_SHELLX}
+
#---------- useful general functions ----------
fail () {
exit 16
}
+x () { echo "x $*"; "$@"; }
+
+case "$BASH_VERSION" in
+'') fail 'scripts using adtxenlvm readconfig must be bash scripts' ;;
+*) ;;
+esac
+
#---------- default values for simple settings ----------
adt_nominum=adt
adt_vm_reduce_retries=10
adt_ssh_keytype=dsa
+adt_debootstrap_components='*'
+adt_debootstrap_include=libc6-xen,openssh-server,ed
+adt_debootstrap_includemore=
+adt_debootstrap_mirrors=''
+adt_debootstrap_script=''
+
adt_fw_localmirrors=''
adt_fw_prohibnets='192.168.0.0/24 172.16.0.0/12 10.0.0.0/8'
adt_fw_allowglobalports='80'
eval "$var=\"\$value\""
shift ;;
- --) break ;;
+ --) shift; break ;;
-*) fail "unknown option \`$arg'" ;;
- *) shift; break ;;
+ *) break ;;
esac
done
- test $# = 0 || fail "non-option arguments not allowed"
+ nonoptargs=$#
}
-cmdline_args
-. ${adt_config}
-cmdline_args
+cmdline_args "$@"
+: "${adt_config:=/etc/autopkgtest/xenlvm_${adt_nominum}_config}"
+test ! -e "${adt_config}" || . "${adt_config}"
+cmdline_args "$@"
#---------- calculated defaults for complex settings ----------
case "$adt_lvm_vg" in
'')
- echo "searching for default volume group ..."
- vgdisplay_out=`vgdisplay -c`
+ printf "searching for default volume group ... "
+ vgdisplay_out=`vgdisplay -c 10>&-`
case "$vgdisplay_out" in
"") fail 'no volume groups found';;
*"
"*) fail 'several volume groups, config must specify which';;
esac
- $adt_lvm_vg=${vgdisplay_out%%:*}
- echo "system has one volume group, $adt_vg, using that."
+ adt_lvm_vg=${vgdisplay_out%%:*}
+ case "$adt_lvm_vg" in
+ *[^\ ]\ *) fail "volume group name \`$adt_lvm_vg' has spaces!";;
+ esac
+ adt_lvm_vg=${adt_lvm_vg##* }
+ echo "using system's only volume group: $adt_lvm_vg"
;;
esac
case "$adt_kernel" in
'')
- echo "searching for kernel ..."
+ printf "searching for kernel ... "
for f in /boot/xen*"`uname -r`"; do
- test -f "$f" || continue
+ test -e "$f" || continue
test "x$adt_kernel" = x || \
fail 'several kernels, config must specify which'
adt_kernel="$f"
done
- echo "... using currently booted kernel $adt_kernel"
+ echo "using currently booted kernel: $adt_kernel"
;;
esac
none) echo "ramdisk \`none' specified, using static kernel"
adt_ramdisk='' ;;
'') adt_ramdisk="$adt_kernel.initrd.img"
- echo "using default ramdisk <kernel>.initrd.img, $adt_ramdisk" ;;
+ echo "using default ramdisk <kernel>.initrd.img: $adt_ramdisk" ;;
*) ;;
esac
case "$adt_modules" in
-'') /lib/modules/`uname -r` ;;
+'') adt_modules="/lib/modules/`uname -r`" ;;
*) ;;
esac
case "$adt_distro" in
'')
- echo "considering which distro to use ..."
- test -f /etc/lsb-release || \
+ printf "considering which distro to use ... "
+ test -e /etc/lsb-release || \
fail 'no /etc/lsb-version, config must specify adt_distro'
. /etc/lsb-release
- $adt_distro=$DISTRIB_CODENAME
+ adt_distro=$DISTRIB_CODENAME
+ echo "using same distro as host: $adt_distro"
;;
esac
eval '
if [ x"$adt_'$1'_hostname" = x ] && \
[ x"$adt_'$1'_ipaddr" != x ]; then
- echo "finding '$1' hostname from IP address $adt_'$1'_ipaddr"
+ printf "%s" "finding '$1' hostname from IP address $adt_'$1'_ipaddr: "
adt_'$1'_hostname=`adnshost -t ptr +Do +Dt +Dc -i $adt_'$1'_ipaddr`
+ printf "%s\n" "${adt_'$1'_hostname}"
fi
'
}
hostname_from_ipaddr host
if [ x"$adt_host_hostname" = x ]; then
- echo "finding host hostname, supposely our own FQDN ..."
+ printf "finding host hostname, supposely our own FQDN: "
adt_host_hostname=`hostname -f`
+ printf "%s\n" "$adt_host_hostname"
fi
if [ x"$adt_guest_hostname" = x ]; then
case "$adt_guests_domain" in
- '') echo "guessing guest hostname from host hostname ..."
+ '') printf "guessing guest hostname from host hostname: "
adt_guest_hostname=$adt_distro.$adt_nominum.${adt_host_hostname#*.} ;;
- .*) echo "setting guest hostname using distro and nominum ..."
+ .*) printf "setting guest hostname using distro and nominum: "
adt_guest_hostname=$adt_distro.$adt_nominum$adt_guests_domain ;;
- *) echo "setting guest hostname using distro and domain ..."
+ *) printf "setting guest hostname using distro and domain: "
adt_guest_hostname=$adt_distro.$adt_guests_domain ;;
esac
+ printf "%s\n" "$adt_guest_hostname"
fi
ipaddr_from_hostname () {
eval '
if [ x"$adt_'$1'_ipaddr" = x ] && \
[ x"$adt_'$1'_hostname" != x ]; then
- echo "finding '$1' IP address from hostname $adt_'$1'_hostname"
- adt_'$1'_ipaddr=`adnshost -t a +Do +Dt +Dc -i - "$adt_'$1'_hostname"`
+ printf "%s" "finding '$1' IP address from hostname $adt_'$1'_hostname: "
+ adt_'$1'_ipaddr=`adnshost -t a +Do +Dt +Dc - "$adt_'$1'_hostname"`
+ echo "${adt_'$1'_ipaddr}"
fi
'
}
ipaddr_from_hostname guest
ipaddr_from_hostname host
-: ${adt_config:=/etc/autopkgtest/xenlvm_${adt_nominum}_config}
+printf "looking for firewall hook ... "
+case "$adt_fw_hook" in
+'')
+ case "$adt_config" in
+ *_config)
+ adt_fw_hook=${adt_config%_config}_fwhook
+ if test -e "$adt_fw_hook"; then
+ echo "default exists: $adt_fw_hook"
+ else
+ echo "default $adt_fw_hook is not a file, so: none"
+ adt_fw_hook=''
+ fi
+ ;;
+ *)
+ echo "not specified, not computable from config, so: none"
+ adt_fw_hook=''
+ ;;
+ esac
+ ;;
+*)
+ if test -e "$adt_fw_hook"; then
+ echo "exists: $adt_fw_hook"
+ else
+ echo "specified as $adt_fw_hook, but not a file, so: none"
+ adt_fw_hook=''
+ fi
+ ;;
+esac
+
+boolean_config () {
+ eval '
+ case "${adt_'$1'}" in
+ y*|Y*|1*|t*) adt_'$1'=true ;;
+ n*|N*|0*|f*) adt_'$1'=false ;;
+ "") adt_'$1'=$2 ;;
+ *) fail "unknown boolean value \`$1'\'' for adt_'$1'" ;;
+ esac
+ '
+}
# SSH
: ${adt_ssh_privkey:=/root/.ssh/id_${adt_ssh_keytype}_${adt_nominum}}
# In-host-file-system playground
: ${adt_play:=${adt_playbase}/${adt_nominum}_${adt_distro}}
: ${adt_xmconfig:=${adt_play}/xmconfig}
+: ${adt_lock:=${adt_play}/lock}
# LVM
+boolean_config lvm_erasebase true
: ${adt_lvm_baselv:=${adt_nominum}_${adt_distro}_base}
: ${adt_lvm_cowdatalv:=${adt_nominum}_${adt_distro}_cowdata}
: ${adt_devmapper_cowdev:=${adt_nominum}_${adt_distro}_snap}
# Firewall
: ${adt_fw_testbedclients:=${adt_host_ipaddr}}
-lvm_baselv_namerhs=${adt_vg}/${adt_lvm_baselv}
-lvm_baselv_namepath=/dev/${adt_lvbaserhs}
+lvm_baselv_namerhs=${adt_lvm_vg}/${adt_lvm_baselv}
+lvm_baselv_namepath=/dev/${lvm_baselv_namerhs}
-lvm_cowdata_namerhs:=${adt_vg}/${adt_lvm_cowdatalv}
-lvm_cowdata_namepath:=/dev/${lvm_cowdata_namerhs}
+lvm_cowdata_namerhs=${adt_lvm_vg}/${adt_lvm_cowdatalv}
+lvm_cowdata_namepath=/dev/${lvm_cowdata_namerhs}
lvm_snapdev=/dev/mapper/${adt_devmapper_cowdev}
lvm_fslink_ptrrhs=${adt_fslink_dir}/${adt_fslink_name}
lvm_fslink_dirpath=/dev/${adt_fslink_dir}
-lvm_fslink_ptr=/dev/${lvm_fslink_dir}/${adt_fslink_name}
+lvm_fslink_ptr=/dev/${adt_fslink_dir}/${adt_fslink_name}
+
+echo "adtxenlvm: configuration for read for nominum=${adt_nominum}"