summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/hydra/misc15
-rwxr-xr-xshare/hydractl/provision61
2 files changed, 46 insertions, 30 deletions
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 7c3c955..5318ba8 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -15,8 +15,8 @@ function hydra_set_env {
# Read a parameter from user
function hydra_user_input {
local input
- param="$1"
- default="$2"
+ local param="$1"
+ local default="$2"
shift 2
if echo $param | grep -q 'passwd'; then
@@ -32,6 +32,17 @@ function hydra_user_input {
fi
}
+# Get a configuration parameter if not previously defined by a sourced file
+function hydra_user_config {
+ local param="$1"
+ local default="$2"
+ shift 2
+
+ if [ -z "`eval echo '$'$param`" ]; then
+ hydra_user_input $param $default $*
+ fi
+}
+
# Install a package
function hydra_install_package {
if [ -z "$1" ]; then
diff --git a/share/hydractl/provision b/share/hydractl/provision
index b781178..2477fa3 100755
--- a/share/hydractl/provision
+++ b/share/hydractl/provision
@@ -21,7 +21,7 @@ source $APP_BASE/lib/hydra/functions || exit 1
hydra_config_load
# Create a logical volume.
-function hydra_lvcreate {
+function hydra_provision_lvcreate {
local volume="$1"
local size="$2"
local space
@@ -40,13 +40,16 @@ function hydra_lvcreate {
# See http://forums.funtoo.org/viewtopic.php?id=1206
# https://bbs.archlinux.org/viewtopic.php?id=124615
- #hydra_safe_run lvcreate -Z n $space -n $volume $vg
- hydra_safe_run lvcreate $space -n $volume $vg
+ if [ "$disable_zeroing" == "y" ]; then
+ hydra_safe_run lvcreate -Z n $space -n $volume $vg
+ else
+ hydra_safe_run lvcreate $space -n $volume $vg
+ fi
fi
}
# Create a physical volume.
-function hydra_create_volume {
+function hydra_provision_create_volume {
local volume="$1"
if [ -z "$volume" ] || [ ! -b "/dev/mapper/$vg-$volume" ]; then
@@ -72,22 +75,23 @@ function hydra_create_volume {
fi
}
-# Ask user for install configuration.
-function hydra_provision_askuser {
- hydra_user_input device /dev/sdb "Destination device"
- hydra_user_input root_size 20G "Size of root partition"
- hydra_user_input swap_size 2000 "Swap size (in MB, 0 to not create it)"
- hydra_user_input home_size 20G "Size of home partition (0 to not create it, -1 for all free space)"
- hydra_user_input var_size 20G "Size of var partition (0 to not create it, -1 for all free space)"
- hydra_user_input encrypt y "Encrypt volumes? (y/n)"
- hydra_user_input garbage y "Pre-fill volumes with garbage? (y/n)"
- hydra_user_input hostname $HOSTNAME "Hostname"
- hydra_user_input domain example.com "Domain"
- hydra_user_input arch amd64 "System arch"
- hydra_user_input version wheezy "Distro version"
- hydra_user_input vg vg "Temporary install vg"
- hydra_user_input grub y "Setup GRUB? (y/n)"
- hydra_user_input mirror http://http.debian.net/debian/ "Debian mirror"
+# Make sure there is provision config.
+function hydra_provision_config {
+ hydra_user_config device /dev/sdb "Destination device"
+ hydra_user_config root_size 20G "Size of root partition"
+ hydra_user_config swap_size 2000 "Swap size (in MB, 0 to not create it)"
+ hydra_user_config home_size 20G "Size of home partition (0 to not create it, -1 for all free space)"
+ hydra_user_config var_size 20G "Size of var partition (0 to not create it, -1 for all free space)"
+ hydra_user_config encrypt y "Encrypt volumes? (y/n)"
+ hydra_user_config garbage y "Pre-fill volumes with garbage? (y/n)"
+ hydra_user_config disable_zeroing n "Disable zeroing of lvm volumes? (y/n)"
+ hydra_user_config hostname $HOSTNAME "Hostname"
+ hydra_user_config domain example.com "Domain"
+ hydra_user_config arch amd64 "System arch"
+ hydra_user_config version wheezy "Distro version"
+ hydra_user_config vg vg "Temporary install vg"
+ hydra_user_config grub y "Setup GRUB? (y/n)"
+ hydra_user_config mirror http://http.debian.net/debian/ "Debian mirror"
}
# Setup.
@@ -99,10 +103,11 @@ if [ ! -z "$1" ]; then
echo "File not found: $1"
exit 1
fi
-else
- hydra_provision_askuser
fi
+# Get parameters
+hydra_provision_config
+
# Check for requirements.
for req in debootstrap cryptsetup grub-pc lvm2 parted; do
hydra_install_package $req
@@ -156,16 +161,16 @@ fi
# Create root partition
hydra_safe_run vgchange -a y $vg
-hydra_lvcreate root $root_size
+hydra_provision_lvcreate root $root_size
# Create home partition
if [ "$home_size" != "0" ]; then
- hydra_lvcreate home $home_size
+ hydra_provision_lvcreate home $home_size
fi
# Create var partition
if [ "$var_size" != "0" ]; then
- hydra_lvcreate var $var_size
+ hydra_provision_lvcreate var $var_size
fi
# Garbage.
@@ -195,16 +200,16 @@ for folder in proc dev home var boot sys; do
done
# Create root fs
-hydra_create_volume root
+hydra_provision_create_volume root
# Create home fs
if [ "$home_size" != "0" ]; then
- hydra_create_volume home
+ hydra_provision_create_volume home
fi
# Create var fs
if [ "$var_size" != "0" ]; then
- hydra_create_volume var
+ hydra_provision_create_volume var
fi
# Mount root volume