]> gitweb.fluxo.info Git - hydra.git/commitdiff
Provision improvements and fixes
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 3 Jul 2018 13:16:31 +0000 (10:16 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 3 Jul 2018 13:16:31 +0000 (10:16 -0300)
lib/hydra/config
lib/hydra/misc
share/config/provision/nas.conf
share/config/provision/router.conf
share/config/provision/stick.conf [new file with mode: 0644]
share/config/provision/tpc.conf
share/hydra/provision
share/hydractl/provision

index 5390159545dd67d194ef6ff9b318525da94d87f2..da49ec785774a0c225784b0dfb1cb0a73ac4963e 100644 (file)
@@ -83,3 +83,14 @@ function hydra_bootstrap_config {
     make config
   )
 }
+
+# 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
+}
index 2c5789bf613a750cb35b2f012501f4ab48f96e40..6081107af575e86fe9504d1f11d872ed31858104 100644 (file)
@@ -49,17 +49,6 @@ 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
index 591638361ca0698e12d6488168c271eeac631445..a48e3d6d73e9cb906053f9bc9120b5695620cf74 100644 (file)
@@ -9,6 +9,6 @@ garbage="y"                             # Pre-fill volumes with garbage?
 disable_zeroing="n"                     # Disable zeroing of lvm volumes?
 random_swap="y"                         # Random swap?
 arch="amd64"                            # System arch
-version="wheezy"                        # Distro version
+version="stretch"                       # Distro version
 grub="n"                                # Setup GRUB?
 mirror="http://http.debian.net/debian/" # Debian mirror
index f3b763ab615b8a824089e37b5a891392f89f8533..14d2597a6f8c80c16c7d4a6de27681d70a33de0d 100644 (file)
@@ -9,6 +9,6 @@ garbage="n"                             # Pre-fill volumes with garbage?
 disable_zeroing="n"                     # Disable zeroing of lvm volumes?
 random_swap="n"                         # Random swap?
 arch="amd64"                            # System arch
-version="wheezy"                        # Distro version
+version="stretch"                       # Distro version
 grub="y"                                # Setup GRUB?
 mirror="http://http.debian.net/debian/" # Debian mirror
diff --git a/share/config/provision/stick.conf b/share/config/provision/stick.conf
new file mode 100644 (file)
index 0000000..b47f38b
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Sample configuration for provisioning a machine in a USB stick.
+# The machine's disk is unencrypted.
+#
+
+interactive="n"                         # Interactive mode?
+swap_size="0"                           # Swap size
+root_size="-1"                          # Root size
+encrypt="n"                             # Encrypt volumes?
+disable_zeroing="n"                     # Disable zeroing of lvm volumes?
+domain="example.org"                    # Domain
+hostname="debian"                       # Hostname
+arch="amd64"                            # System arch
+version="stretch"                       # Distro version
+grub="y"                                # Setup GRUB?
+mirror="http://http.debian.net/debian/" # Debian mirror
+vg="debian"                             # Install vg
+ssh="n"                                 # Install openssh-server?
index 5c209a0f45ff1e7eb8cf6857c13f34b8c997d465..89faa5e9b2d87137d8ed2ba211fdd277e95f8204 100644 (file)
@@ -13,7 +13,7 @@ garbage="n"                             # Pre-fill volumes with garbage?
 disable_zeroing="n"                     # Disable zeroing of lvm volumes?
 random_swap="n"                         # Random swap?
 arch="amd64"                            # System arch
-version="jessie"                        # Distro version
+version="stretch"                       # Distro version
 grub="y"                                # Setup GRUB?
 mirror="http://http.debian.net/debian/" # Debian mirror
 ssh="n"                                 # Install openssh-server?
index 4c59b3d135fb1cf1737ef11db6c4957fe9b8f7e2..a025a8e1844c5b2e51f4784770c842f719398195 100755 (executable)
@@ -34,5 +34,9 @@ if [ -z "$NODE" ]; then
   ( cd $CONFIG && tree )
   exit 1
 else
-  hydractl $BASENAME $NODE
+  if [ -e "$CONFIG/$NODE.conf" ]; then
+    hydractl $BASENAME $CONFIG/$NODE.conf
+  elif [ -e "$APP_BASE/share/config/provision/$NODE.conf" ]; then
+    hydractl $BASENAME $APP_BASE/share/config/provision/$NODE.conf
+  fi
 fi
index e7877c3caef8634fa8ec658dfb2f57af77675432..96784c5edb95a1c9653fd68c18779dfd111b93ca 100755 (executable)
@@ -98,13 +98,13 @@ function hydra_provision_config {
   hydra_user_config   root_size         20G                              "Size of root partition (-1 for all free space)"
 
   if [ "$root_size" != "-1" ]; then
-    hydra_user_config   home_size       20G                              "Size of home partition (0 to not create it, -1 for all free space)"
+    hydra_user_config home_size         20G                              "Size of home partition (0 to not create it, -1 for all free space)"
   else
     home_size="0"
   fi
 
   if [ "$root_size" != "-1" ] && [ "$home_size" != "-1" ]; then
-    hydra_user_config   var_size        20G                              "Size of var 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)"
   else
     var_size="0"
   fi
@@ -112,11 +112,11 @@ function hydra_provision_config {
   hydra_user_config   encrypt           y                                "Encrypt volumes? (if RAID, then encryption is default) (y/n)"
 
   if [ "$encrypt" == "y" ]; then
-    hydra_user_config   garbage         y                                "Pre-fill volumes with garbage? (y/n)"
+    hydra_user_config garbage           y                                "Pre-fill volumes with garbage? (y/n)"
   fi
 
   if [ "$swap_size" != "0" ]; then
-    hydra_user_config   random_swap     y                                "Random swap? (y/n)"
+    hydra_user_config random_swap       y                                "Random swap? (y/n)"
   fi
 
   hydra_user_config   disable_zeroing   n                                "Disable zeroing of LVM volumes? (y/n)"
@@ -484,7 +484,7 @@ if [ "$grub" == "y" ]; then
   echo "Setting up GRUB..."
   $APT_INSTALL grub-pc -y
 
-  sed -i -e 's/^GRUB_CMDLINE_LINUX_DEFAULT="quiet"$/GRUB_CMDLINE_LINUX_DEFAULT="quiet apparmor=1 security=apparmor/"' \
+  hydra_sudo_run sed -i -e 's/^GRUB_CMDLINE_LINUX_DEFAULT="quiet"$/GRUB_CMDLINE_LINUX_DEFAULT="quiet apparmor=1 security=apparmor"/' \
     $WORK/etc/default/grub
   hydra_sudo_run chroot $WORK/ update-grub
 
@@ -499,6 +499,8 @@ if [ "$grub" == "y" ]; then
     # Fix menu entry
     hydra_sudo_run sed -i -e "s|root=/dev/mapper/provision-root|root=/dev/mapper/root|g"     $WORK/boot/grub/grub.cfg
     hydra_sudo_run sed -i -e "s|root=/dev/mapper/$hostname-unlocked|root=/dev/mapper/root|g" $WORK/boot/grub/grub.cfg
+  else
+    hydra_sudo_run chroot $WORK/ grub-install --recheck --force $device
   fi
 fi
 
@@ -531,6 +533,11 @@ if [ "$ssh" == "y" ]; then
 fi
 
 echo "Umounting installation device..."
+
+if [ "$grub" == "y" ] && [ "$encrypt" != "y" ]; then
+  hydra_sudo_run umount $WORK/boot
+fi
+
 hydra_sudo_run umount $WORK/sys $WORK/proc $WORK/dev $WORK
 
 if [ "$swap_size" != "0" ]; then