summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-03-10 21:31:45 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2009-03-10 21:31:45 +0100
commitd455713e8a993e7dba9922893fc6e6785c037745 (patch)
treed05b07f353367870a95aef9282469be6bcef2a9f
parent61bd867bb9fffc93a9feaffd00d7992d3bcc89c1 (diff)
improved version of automatic procedures. better separation between my needs and those of the average user. also a sample config for generic install
-rw-r--r--examples/deployconfig-dieter53
-rw-r--r--examples/generic-install-on-sda17
-rw-r--r--src/core/procedures/automatic75
3 files changed, 107 insertions, 38 deletions
diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter
index 75a197c..a866d54 100644
--- a/examples/deployconfig-dieter
+++ b/examples/deployconfig-dieter
@@ -1,6 +1,9 @@
#!/bin/bash
# An example config for the deployment procedure
+# Use var_* for "standard" variables recognized by the automatic procedure. these should work for everyone.
+# use all other variable names for your own stuff. (eg i use them to define some things needed to pull my stuff from svn.)
+
# TODO: install ruby-gems too
# TODO * dieter/automatic: wait for yaourt --config fix ( http://forums.archlinux.fr/post23171.html#23171 )
# TODO:* dieter/automatic: put config files from svn in place first, so that if a package has an update, it can do it's thing.
@@ -15,16 +18,29 @@ SVN_USERNAME=dieter
SVN_PASSWORD=
SVN_BASE=https://192.168.1.2/svn/repos
+var_PARTITIONS='/dev/sda 100:ext2:+ 2048:swap *:xfs'
+var_BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params
+/dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params
+/dev/sda3 raw no_label dm_crypt;yes;no_mountpoint;target;no_opts;sda3crypt;-c_aes-xts-plain_-y_-s_512
+/dev/mapper/sda3crypt dm_crypt no_label lvm-pv;yes;no_mountpoint;target;no_opts;no_label;no_params
+/dev/mapper/sda3crypt+ lvm-pv no_label lvm-vg;yes;no_mountpoint;target;no_opts;cryptpool;/dev/mapper/sda3crypt
+/dev/mapper/cryptpool lvm-vg cryptpool lvm-lv;yes;no_mountpoint;target;no_opts;cryptroot;5G|lvm-lv;yes;no_mountpoint;target;no_opts;crypthome;5G
+/dev/mapper/cryptpool-cryptroot lvm-lv no_label xfs;yes;/;target;no_opts;no_label;no_params
+/dev/mapper/cryptpool-crypthome lvm-lv no_label xfs;yes;/home;target;no_opts;no_label;no_params'
+
+
+
phase_preparation=(accept_ssl_cert "${phase_preparation[@]}") # make accept_ssl_cert the very first thing. it needs to go before fetch_configs and it's not easy to put it somewhere in the middle, so...
phase_system+=(configure_home)
+# Deprecated. I try to keep everything in 1 config file now. that's cooler.
+#worker_fetch_configs ()
+#{
+# $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata $RUNTIME_DIR/aif-blockdata || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata to $RUNTIME_DIR/aif-blockdata"
+# $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions $RUNTIME_DIR/aif-partitions || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions to $RUNTIME_DIR/aif-partitions"
+#}
-worker_fetch_configs ()
-{
- $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata $RUNTIME_DIR/aif-blockdata || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata to $RUNTIME_DIR/aif-blockdata"
- $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions $RUNTIME_DIR/aif-partitions || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions to $RUNTIME_DIR/aif-partitions"
-}
worker_package_list ()
@@ -85,3 +101,30 @@ worker_configure_home ()
# PACMAN=$PACMAN_BACKUP
# PACMAN_TARGET=$PACMAN_TARGET_BACKUP
#}
+
+
+# Check if we have all needed settings loaded from the profile
+post_worker_configure ()
+{
+ if check_is_in svn $var_RUNTIME_PACKAGES
+ then
+ [ -z "$SVN_USERNAME" ] && ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING
+ [ -z "$SVN_PASSWORD" ] && ask_password svn #TODO: if user entered incorrect password, the install process will just fail..
+ [ -z "$SVN_BASE" ] && ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING
+ [ -z "$DEPLOY_CLASS" ] && ask_string "Which hostclass are you installing? (optional)" '' 0 && DEPLOY_CLASS=$ANSWER_STRING
+ SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD"
+ elif check_is_in moo $var_RUNTIME_PACKAGES
+ then
+ # Maybe more stuff later
+ true
+ fi
+ [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING
+
+ return 0
+}
+
+worker_set_clock ()
+{
+ #Not doing anything. hwclock is set already, configs are coming from svn anyway and we'll use ntp.
+ true
+}
diff --git a/examples/generic-install-on-sda b/examples/generic-install-on-sda
new file mode 100644
index 0000000..5e05b34
--- /dev/null
+++ b/examples/generic-install-on-sda
@@ -0,0 +1,17 @@
+# these variables are defaults, but it doesn't hurt to define them.
+# TODO: put something here (preferably the group) to say which packages we want)
+AUTOMATIC_SOURCE=cd
+AUTOMATIC_FILE_URL=file:///src/core/pkg
+AUTOMATIC_SYNC_URL=
+
+AUTOMATIC_RUNTIME_REPOSITORIES=
+AUTOMATIC_RUNTIME_PACKAGES=
+worker_intro () {
+ infofy "Automatic procedure running the generic-install-on-sda example config. THIS WILL ERASE AND OVERWRITE YOUR /DEV/SDA. IF YOU DO NOT WANT THIS PRESS CTRL+C WITHIN 10 SECONDS"
+ sleep 10
+}
+
+var_PARTITIONS='/dev/sda 100:ext2:+ 512:swap *:ext4'
+var_BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params
+/dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params
+/dev/sda3 raw no_label ext4;yes;/;target;no_opts;no_label;no_params' \ No newline at end of file
diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic
index cde7f6a..d0f8249 100644
--- a/src/core/procedures/automatic
+++ b/src/core/procedures/automatic
@@ -1,24 +1,32 @@
#!/bin/bash
-# This procedure is EARLY in development!!
+# This procedure is in development!!
# This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...)
+# check /usr/share/aif/examples for some example config files.
+# This procedure can easily replace the old quickinst script if you look at the "generic install" config file
+# Look at the base procedure to see the phases and which workers they'll execute.
+# It should be:
+# phase_preparation=(configure intro sysprep select_source runtime_network runtime_repositories runtime_packages)
+# phase_basics=(set_clock prepare_disks)
+# phase_system=(package_listTODO install_packages auto_fstab auto_networkTODO auto_locale configure_system mkinitcpio locales install_bootloader)
+# phase_finish=(msg_report)
# In theory, the only manual thing should maybe be configuring the runtime network and putting the configfile in place
# TODO: I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..?
+# TODO: for worker_configure_system, we probably want the user to specify hostname, root pass etc.
+
+# for a list of recognized variables, see examples/generic-install-on-sda
depend_procedure core base
var_OPTS_STRING="c:"
-var_ARGS_USAGE="-c <config>: Specify a configfile (profile) to be used (optional)" #if we need some settings that we're missing, we'll ask for them
-
-phase_preparation+=(runtime_settings)
-phase_preparation+=(msg_automatic) # this can happen probably a bit earlier..
-phase_preparation+=(fetch_configs)
+var_ARGS_USAGE="-c <config>: Specify a configfile (profile) to be used"
+var_AUTOMATIC_PROFILE=""
process_args ()
{
if [ "$1" = '-c' ]
then
[ -z "$2" ] && die_error "You must specify a config"
- source $2 || die_error "Could not source config $2"
+ var_AUTOMATIC_PROFILE=$2
else
usage
exit 5
@@ -35,36 +43,31 @@ worker_intro ()
worker_configure ()
{
var_UI_TYPE=${arg_ui_type:-cli}
+ [ -z "$var_AUTOMATIC_PROFILE" ] && die_error "You must specify a config file to use this procedure"
+ source $var_AUTOMATIC_PROFILE || die_error "Could not source config $var_AUTOMATIC_PROFILE"
+ var_RUNTIME_REPOSITORIES=$AUTOMATIC_RUNTIME_REPOSITORIES
+ var_RUNTIME_PACKAGES=$AUTOMATIC_RUNTIME_PACKAGES
+ [ - z "$var_PARTITIONS" ] && die_error "You did not specify a partition scheme"
+ [ - z "$var_BLOCKDATA" ] && die_error "You did not specify a partition scheme"
}
-
-# not used
-worker_msg_manual ()
-{
- notify "A few manual things need to happen first..."
-}
-
-
-worker_msg_automatic ()
+worker_select_source ()
{
- notify "**** From now on. everything will be automatic. Enjoy the show!" # not true: you need pass for dm_crypt
+ var_PKG_SOURCE_TYPE=${AUTOMATIC_SOURCE:-cd}
+ var_FILE_URL=${AUTOMATIC_FILE_URL:-file:///src/core/pkg}
+ var_SYNC_URL=${AUTOMATIC_SYNC_URL:-}
}
-
-worker_fetch_configs ()
-{
- true
-}
-
-
worker_runtime_network ()
{
- if ask_yesno "Do you want to (re)-configure your networking?"
- then
- interactive_runtime_network
- else
- infofy "Ok. skipping network config"
- fi
+ true # for now. we assume the user has taken care of this himself already. doing this interactively wouldn't be a good default anyway.
+ # maybe check if network works, if not, try dhcp. let user override by using a static config in his config file
+ #if ask_yesno "Do you want to (re)-configure your networking?"
+ #then
+ # interactive_runtime_network
+ #else
+ # infofy "Ok. skipping network config"
+ #fi
}
@@ -91,6 +94,8 @@ worker_runtime_settings ()
worker_prepare_disks ()
{
+ echo "$var_PARTITIONS" > $TMP_PARTITIONS
+ echo "$var_BLOCKDATA" > $TMP_BLOCKDEVICES
process_disks || die_error "Could not process_disks"
if ! process_filesystems
then
@@ -116,15 +121,19 @@ worker_install_packages ()
worker_set_clock ()
{
- #timezone="Europe/Brussels"
- #Not doing anything. hwclock is set already and configs are coming from svn anyway..
+ #TODO implement this
true
}
+worker_auto_network () {
+ # temporary override because i need to implement this
+}
+
+
worker_install_bootloader ()
{
- install-grub /dev/sda
+ install-grub /dev/sda #TODO: this can be more flexible..
}