From 2f839ffec30eea2025cced9fb690ab612795c6ac Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 11:38:03 +0100 Subject: first move towards making my deployment procedure usable for other people too --- src/core/procedures/automatic | 131 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 src/core/procedures/automatic (limited to 'src/core/procedures/automatic') diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic new file mode 100644 index 0000000..0e47f7b --- /dev/null +++ b/src/core/procedures/automatic @@ -0,0 +1,131 @@ +#!/bin/bash +# This procedure is EARLY in development!! +# This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...) + +# In theory, the only manual thing should maybe be configuring the runtime network +# TODO: implement profile reading +# TODO: I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..? + +depend_module yaourt +depend_procedure core base + +phase_preparation=(\ + configure \ + intro \ + sysprep \ + runtime_network \ + runtime_svn \ + msg_automatic \ + select_source \ + runtime_packages \ + runtime_yaourt) + +phase_finish=(configure_home msg_report) + + +worker_intro () +{ + notify "Automatic procedure running..." +} + + +worker_configure () +{ + var_UI_TYPE=${arg_ui_type:-cli} +} + + +worker_msg_manual () +{ + # All things that need to be done manually first + notify "A few manual things need to happen first..." +} + + +worker_msg_automatic () +{ + notify "**** From now on. everything will be automatic. Enjoy the show!" # not true: you need pass for dm_crypt +} + + +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 +} + + +worker_runtime_svn () +{ + SVN_USERNAME=dieter #TODO: softcode this + ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. + SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD" + SVN_BASE=https://192.168.1.2/svn/repos + ask_string "Which host are you installing?" desktop-a7nx8 + TARGET_HOST=$ANSWER_STRING #TODO: allow passing as cmdline argument (and check with svn info). handle -z $ANSWER_STRING + _accept_ssl_cert +} + + +worker_prepare_disks () +{ + svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata into $RUNTIME_DIR" + svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions into $RUNTIME_DIR" + + process_disks || die_error "Could not process_disks" + process_filesystems || die_error "Could not process_filesystems" + + #TODO: support rollback + + + # TODO: fstab? auto-add to fstab with libs? auto mkdir's on target_dir? + true +} + +worker_package_list () +{ + $SVN export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/package-list $var_PKG_FILE || die_error "Could not export package list!" + # cat -> there are newlines in it -> var=`echo $var` -> not anymore :) + TARGET_PACKAGES=`cat $var_PKG_FILE` && TARGET_PACKAGES=`echo $TARGET_PACKAGES` || die_error "Could not cat package list. THIS SHOULD NEVER HAPPEN." + true +} + + +worker_install_packages () +{ + target_prepare_pacman core extra community #TODO: it would be better if this was a separate worker, i think + [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!" + installpkg +} + + +worker_configure_home () +{ + #checkout from svn + true +} + + +worker_set_clock () +{ + #timezone="Europe/Brussels" + #Not doing anything. hwclock is set already and configs are coming from svn anyway.. + true +} + + +worker_install_bootloader () +{ + install-grub /dev/sda +} + + +worker_runtime_yaourt () +{ + _yaourt_replace_pacman +} + -- cgit v1.2.3-54-g00ecf From 440e64fc28c4bb22782bc9eb2842c773707ab49a Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 12:45:15 +0100 Subject: enhanced arg parsing + automatic procedure can read configs now --- src/aif.sh | 4 ++-- src/core/procedures/automatic | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/src/aif.sh b/src/aif.sh index 4ef130e..2386992 100755 --- a/src/aif.sh +++ b/src/aif.sh @@ -275,7 +275,7 @@ procedure= # in that case -p needs to be the first option, but that's doable imho # an alternative would be to provide an argumentstring for the profile. eg aif -p profile -a "-a a -b b -c c" -var_OPTS_STRING=":i:dlp:" # you can override this variable in your procedure. +var_OPTS_STRING="" # you can override this variable in your procedure. # Processes args that were not already matched by the basic rules. @@ -320,7 +320,7 @@ load_module core load_procedure "$module" "$procedure" -while getopts $var_OPTS_STRING OPTION +while getopts ":i:dlp:$var_OPTS_STRING" OPTION do case $OPTION in i) diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 0e47f7b..cdda847 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -3,12 +3,24 @@ # This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...) # In theory, the only manual thing should maybe be configuring the runtime network -# TODO: implement profile reading # TODO: I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..? depend_module yaourt depend_procedure core base +var_OPTS_STRING="c:" +process_args () +{ + [ "$1" = '-c' ] + then + [ -z "$2" ] && die_error "You must specify a config" + source $2 || die_error "Could not source config $2" + else + usage + exit 5 + fi +} + phase_preparation=(\ configure \ intro \ -- cgit v1.2.3-54-g00ecf From 12cdf2d55775ee671968977d890f9a4d7ba95f1f Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 13:45:47 +0100 Subject: allow procedures to add stuff to usage output --- src/aif.sh | 7 +++++-- src/core/procedures/automatic | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/src/aif.sh b/src/aif.sh index 2386992..3a20e2e 100755 --- a/src/aif.sh +++ b/src/aif.sh @@ -22,6 +22,8 @@ If the procedurename is prefixed with '/' it will be loaded from use Available procedures on the filesystem: `find /home/arch/aif/core/procedures -type f`\n `find /home/arch/aif/user/*/procedures -type f 2>/dev/null`" + [ -z "$procedure" ] && msg="$msg\nProcedure ($procedure) specific options:\n$var_ARGS_USAGE" + echo -e "$msg" } @@ -275,8 +277,9 @@ procedure= # in that case -p needs to be the first option, but that's doable imho # an alternative would be to provide an argumentstring for the profile. eg aif -p profile -a "-a a -b b -c c" -var_OPTS_STRING="" # you can override this variable in your procedure. - +# you can override these variables in your procedures +var_OPTS_STRING="" +var_ARGS_USAGE="" # Processes args that were not already matched by the basic rules. process_args () diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index cdda847..ad279ce 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -4,11 +4,14 @@ # In theory, the only manual thing should maybe be configuring the runtime network # TODO: I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..? +# TODO: check_is_in runtime packages and check needed args, if not known ask (eg svn password) depend_module yaourt depend_procedure core base var_OPTS_STRING="c:" +var_ARGS_USAGE="-c : Specify a configfile (profile) to be used (Mandatory)" # TODO: don't check if the option is specified, but do checking on all variables that we need + process_args () { [ "$1" = '-c' ] -- cgit v1.2.3-54-g00ecf From d3907f6e1ce359d83d72b8b45d735c7ee134c2b0 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 14:38:08 +0100 Subject: cleanup automatic deployment stuff --- examples/deployconfig-dieter | 16 +++++++++++- src/core/procedures/automatic | 60 ++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 33 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter index c59bcc2..b7af73a 100644 --- a/examples/deployconfig-dieter +++ b/examples/deployconfig-dieter @@ -4,11 +4,25 @@ var_RUNTIME_PACKAGES="svn" DEPLOY_CLASS=desktop-a7n8x +HOSTNAME=dieter-ws SVN_USER=dieter SVN_PASSWORD= +SVN_BASE=https://192.168.1.2/svn/repos +phase_preparation+=(accept_ssl_cert) +phase_system+=(configure_home) -_accept_ssl_cert () + + +worker_configure () +{ + var_UI_TYPE=${arg_ui_type:-cli} + svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata into $RUNTIME_DIR" + svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions into $RUNTIME_DIR" +} + + +worker_accept_ssl_cert () { mkdir -p /root/.subversion/auth/svn.ssl.server cat > /root/.subversion/auth/svn.ssl.server/1123d3c8b27895efee3848cc779e526a << EOF diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index ad279ce..7e852b9 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -2,15 +2,17 @@ # This procedure is EARLY in development!! # This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...) -# In theory, the only manual thing should maybe be configuring the runtime network +# 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: check_is_in runtime packages and check needed args, if not known ask (eg svn password) depend_module yaourt depend_procedure core base var_OPTS_STRING="c:" -var_ARGS_USAGE="-c : Specify a configfile (profile) to be used (Mandatory)" # TODO: don't check if the option is specified, but do checking on all variables that we need +var_ARGS_USAGE="-c : 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.. process_args () { @@ -24,19 +26,6 @@ process_args () fi } -phase_preparation=(\ - configure \ - intro \ - sysprep \ - runtime_network \ - runtime_svn \ - msg_automatic \ - select_source \ - runtime_packages \ - runtime_yaourt) - -phase_finish=(configure_home msg_report) - worker_intro () { @@ -50,9 +39,9 @@ worker_configure () } +# not used worker_msg_manual () { - # All things that need to be done manually first notify "A few manual things need to happen first..." } @@ -74,28 +63,35 @@ worker_runtime_network () } -worker_runtime_svn () +# Check if we have all needed settings loaded from the profile +worker_runtime_settings () { - SVN_USERNAME=dieter #TODO: softcode this - ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. - SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD" - SVN_BASE=https://192.168.1.2/svn/repos - ask_string "Which host are you installing?" desktop-a7nx8 - TARGET_HOST=$ANSWER_STRING #TODO: allow passing as cmdline argument (and check with svn info). handle -z $ANSWER_STRING - _accept_ssl_cert + if check_is_in svn "$var_RUNTIME_PACKAGES" + then + [ -n "$SVN_USERNAME" ] || ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING + [ -n "$SVN_PASSWORD" ] || ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. + [ -n "$SVN_BASE" ] || ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING + [ -n "$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" + # Maybe more stuff later + true + fi + [ -n "$HOSTNAME" ] || ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING } worker_prepare_disks () { - svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata into $RUNTIME_DIR" - svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions into $RUNTIME_DIR" - process_disks || die_error "Could not process_disks" - process_filesystems || die_error "Could not process_filesystems" - - #TODO: support rollback - + if ! process_filesystems + then + show_warning "Could not process_filesystems" + txt='also failed to execute properly' + rollback_filesystems && txt='ended successfully' + die_error "Something failed while processing the filesystem. A rollback was executed, which $txt" + fi + infofy "Partitions and filesystems made successfully" # TODO: fstab? auto-add to fstab with libs? auto mkdir's on target_dir? true -- cgit v1.2.3-54-g00ecf From 2fae9af8e549dbe9269ae4bde1b2269c99c17a35 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 14:41:23 +0100 Subject: syntax fix --- src/core/procedures/automatic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/procedures/automatic') diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 7e852b9..a776004 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -16,7 +16,7 @@ phase_preparation+=(msg_automatic) # this can happen probably a bit earlier.. process_args () { - [ "$1" = '-c' ] + if [ "$1" = '-c' ] then [ -z "$2" ] && die_error "You must specify a config" source $2 || die_error "Could not source config $2" -- cgit v1.2.3-54-g00ecf From 37103ea8afa907966062b94fc1708ca1bf5d8351 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 14:43:12 +0100 Subject: syntax fix --- src/core/procedures/automatic | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/procedures/automatic') diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index a776004..e2e4b00 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -74,6 +74,7 @@ worker_runtime_settings () [ -n "$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 -- cgit v1.2.3-54-g00ecf From 0111fdd1d6dbf6c988eb9a742f4934ead887d2d6 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 15:27:25 +0100 Subject: probably its better to only use svn after we installed it --- examples/deployconfig-dieter | 3 +-- src/core/procedures/automatic | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter index b7af73a..1c334a2 100644 --- a/examples/deployconfig-dieter +++ b/examples/deployconfig-dieter @@ -14,9 +14,8 @@ phase_system+=(configure_home) -worker_configure () +worker_fetch_configs () { - var_UI_TYPE=${arg_ui_type:-cli} svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata into $RUNTIME_DIR" svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions into $RUNTIME_DIR" } diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index e2e4b00..3f02832 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -13,7 +13,7 @@ var_ARGS_USAGE="-c : Specify a configfile (profile) to be used (optional phase_preparation+=(runtime_settings) phase_preparation+=(msg_automatic) # this can happen probably a bit earlier.. - +phase_preparation+=(fetch_configs) process_args () { if [ "$1" = '-c' ] @@ -52,6 +52,12 @@ worker_msg_automatic () } +worker_fetch_configs () +{ + true +} + + worker_runtime_network () { if ask_yesno "Do you want to (re)-configure your networking?" -- cgit v1.2.3-54-g00ecf From e8291396bf3879140fd7032414a5d417975152c9 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 15:34:47 +0100 Subject: variable name & logic fixes --- examples/deployconfig-dieter | 6 +++--- src/core/procedures/automatic | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter index 1c334a2..6c9a909 100644 --- a/examples/deployconfig-dieter +++ b/examples/deployconfig-dieter @@ -5,7 +5,7 @@ var_RUNTIME_PACKAGES="svn" DEPLOY_CLASS=desktop-a7n8x HOSTNAME=dieter-ws -SVN_USER=dieter +SVN_USERNAME=dieter SVN_PASSWORD= SVN_BASE=https://192.168.1.2/svn/repos @@ -16,8 +16,8 @@ phase_system+=(configure_home) worker_fetch_configs () { - svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.blockdata into $RUNTIME_DIR" - svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/disks/.partitions into $RUNTIME_DIR" + svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata into $RUNTIME_DIR" + svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions $RUNTIME_DIR || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions into $RUNTIME_DIR" } diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 3f02832..f41d5a9 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -74,17 +74,17 @@ worker_runtime_settings () { if check_is_in svn "$var_RUNTIME_PACKAGES" then - [ -n "$SVN_USERNAME" ] || ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING - [ -n "$SVN_PASSWORD" ] || ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. - [ -n "$SVN_BASE" ] || ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING - [ -n "$DEPLOY_CLASS" ] || ask_string "Which hostclass are you installing? (optional)" '' 0 && DEPLOY_CLASS=$ANSWER_STRING + [ -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 - [ -n "$HOSTNAME" ] || ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING + [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING } -- cgit v1.2.3-54-g00ecf From 7f9c5b317eb33ffc4be183b50dd636de15f01ae2 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 16:03:38 +0100 Subject: cleanup automatic deployment stuff --- examples/deployconfig-dieter | 16 ++++++++++++++++ src/core/procedures/automatic | 15 --------------- src/core/procedures/base | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter index 00a3396..c626a64 100644 --- a/examples/deployconfig-dieter +++ b/examples/deployconfig-dieter @@ -1,6 +1,8 @@ #!/bin/bash # An example config for the deployment procedure +#TODO: install ruby-gems too + var_RUNTIME_PACKAGES="svn" DEPLOY_CLASS=desktop-a7n8x @@ -21,6 +23,13 @@ worker_fetch_configs () } +worker_package_list () +{ + $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/package-list $var_PKG_FILE || die_error "Could not export package list!" + # cat -> there are newlines in it -> var=`echo $var` -> not anymore :) + TARGET_PACKAGES=`cat $var_PKG_FILE` && TARGET_PACKAGES=`echo $TARGET_PACKAGES` || die_error "Could not cat package list. THIS SHOULD NEVER HAPPEN." +} + worker_accept_ssl_cert () { mkdir -p /root/.subversion/auth/svn.ssl.server @@ -40,3 +49,10 @@ https://192.168.1.2:443 END EOF } + + +worker_configure_home () +{ + #TODO checkout from svn + true +} \ No newline at end of file diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index f41d5a9..dc879ee 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -104,14 +104,6 @@ worker_prepare_disks () true } -worker_package_list () -{ - $SVN export $SVN_BASE/ddm-configs/$TARGET_HOST/trunk/package-list $var_PKG_FILE || die_error "Could not export package list!" - # cat -> there are newlines in it -> var=`echo $var` -> not anymore :) - TARGET_PACKAGES=`cat $var_PKG_FILE` && TARGET_PACKAGES=`echo $TARGET_PACKAGES` || die_error "Could not cat package list. THIS SHOULD NEVER HAPPEN." - true -} - worker_install_packages () { @@ -121,13 +113,6 @@ worker_install_packages () } -worker_configure_home () -{ - #checkout from svn - true -} - - worker_set_clock () { #timezone="Europe/Brussels" diff --git a/src/core/procedures/base b/src/core/procedures/base index 632dda7..1c1d640 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -4,7 +4,7 @@ var_DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3" var_TARGET_DIR="/mnt" # When overriding this, do _not_ add a trailing /. It's not needed and maybe you could even break something var_RUNTIME_PACKAGES= -var_PKG_FILE=$RUNTIME_DIR/package-list +var_PKG_FILE=$RUNTIME_DIR/package-list # not used by default in base/interactive. can be used by custom procedures or profiles for the automatic procedure var_MIRRORLIST="/etc/pacman.d/mirrorlist" var_UI_TYPE="cli" # set to cli or dia for dialog var_ARCH=`uname -m` #works for i686 TODO: check if it works for x86_64 -- cgit v1.2.3-54-g00ecf From cd6c7c01579bc37c458eac1a649ef74f17def3cb Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 20 Dec 2008 17:31:25 +0100 Subject: fixes/cleanups for runtime packages and repositories. Not much use in making yauort a module, its integrated now --- examples/deployconfig-dieter | 42 ++++++++++++++++++++++++++++++++++++++++-- src/core/procedures/automatic | 1 - src/core/procedures/base | 13 +++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter index c626a64..9e80dc4 100644 --- a/examples/deployconfig-dieter +++ b/examples/deployconfig-dieter @@ -1,8 +1,13 @@ #!/bin/bash # An example config for the deployment procedure -#TODO: install ruby-gems too +# 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. +depend_module yaourt + +var_RUNTIME_REPOSITORIES=(archlinuxfr "Server = http://repo.archlinux.fr/$var_ARCH") var_RUNTIME_PACKAGES="svn" DEPLOY_CLASS=desktop-a7n8x @@ -23,6 +28,19 @@ worker_fetch_configs () } +worker_runtime_packages () +{ + for pkg in $var_RUNTIME_PACKAGES + do + $PACMAN -Sy --noconfirm --needed $pkg + done + + # We'll install packages on the target system, for that we need yaourt + _runtime_yaourt + _yaourt_replace_pacman +} + + worker_package_list () { $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/package-list $var_PKG_FILE || die_error "Could not export package list!" @@ -55,4 +73,24 @@ worker_configure_home () { #TODO checkout from svn true -} \ No newline at end of file +} + + + +# See http://wiki.archlinux.org/index.php/Yaourt + +worker_install_packages () #pre_ / post_ callbacks would be useful here +{ + PACMAN_BACKUP=$PACMAN + PACMAN_TARGET_BACKUP=$PACMAN_TARGET + PACMAN=${PACMAN//pacman/yaourt} + PACMAN_TARGET=${PACMAN_TARGET//pacman/yaourt} + + target_prepare_pacman core + [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!" + installpkg + + PACMAN=$PACMAN_BACKUP + PACMAN_TARGET=$PACMAN_TARGET_BACKUP + +} diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index dc879ee..bb78437 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -5,7 +5,6 @@ # 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/..? -depend_module yaourt depend_procedure core base var_OPTS_STRING="c:" diff --git a/src/core/procedures/base b/src/core/procedures/base index 1c1d640..4fd32c8 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -3,6 +3,7 @@ #TODO: make this profile work on itself, eg some stuff from inheriting profiles should be moved in, stuff implemented etc var_DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3" var_TARGET_DIR="/mnt" # When overriding this, do _not_ add a trailing /. It's not needed and maybe you could even break something +var_RUNTIME_REPOSITORIES= # array like this ('name1' 'location of repo 1' ['name2' 'location of repo2',..]) var_RUNTIME_PACKAGES= var_PKG_FILE=$RUNTIME_DIR/package-list # not used by default in base/interactive. can be used by custom procedures or profiles for the automatic procedure var_MIRRORLIST="/etc/pacman.d/mirrorlist" @@ -17,6 +18,7 @@ phase_preparation=(\ sysprep \ select_source \ runtime_network \ + runtime_repositories \ runtime_packages) phase_basics=(\ @@ -77,6 +79,17 @@ worker_runtime_network () } +worker_runtime_repositories () +{ + for i in `seq 0 $((${#var_RUNTIME_REPOSITORIES[@]}/2-1))` + do + repo=${var_RUNTIME_REPOSITORIES[$(($i*2))]} + location=${var_RUNTIME_REPOSITORIES[$(($i*2+1))]} + list_pacman_repos runtime | grep -q $repo || add_pacman_repo runtime $repo $location + done +} + + worker_runtime_packages () { for pkg in $var_RUNTIME_PACKAGES -- cgit v1.2.3-54-g00ecf From a0be4eb42a1d0fc93e592bff9c27cc3e74968bec Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 21 Dec 2008 16:40:22 +0100 Subject: needle/haystack order + return code fixes --- src/core/procedures/automatic | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index bb78437..4369a5a 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -71,19 +71,21 @@ worker_runtime_network () # Check if we have all needed settings loaded from the profile worker_runtime_settings () { - if check_is_in svn "$var_RUNTIME_PACKAGES" + if check_is_in "$var_RUNTIME_PACKAGES" svn 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" + elif check_is_in "$var_RUNTIME_PACKAGES" moo then # Maybe more stuff later true fi [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING + + return 0 } -- cgit v1.2.3-54-g00ecf From a2d15c5e2b8afda0da44959f52937a6a0c48e933 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 21 Dec 2008 17:02:42 +0100 Subject: bugfix mkay --- src/core/procedures/automatic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/procedures/automatic') diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 4369a5a..3c93167 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -71,14 +71,14 @@ worker_runtime_network () # Check if we have all needed settings loaded from the profile worker_runtime_settings () { - if check_is_in "$var_RUNTIME_PACKAGES" svn + if check_is_in $var_RUNTIME_PACKAGES svn 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 "$var_RUNTIME_PACKAGES" moo + elif check_is_in $var_RUNTIME_PACKAGES moo then # Maybe more stuff later true -- cgit v1.2.3-54-g00ecf