#!/bin/bash # This is a procedure for automatic deployment/installation/configuration of systems. # 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_list install_packages configure_system 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 # I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..? # TODO: implement setting hostname, keymap, consolefont, network settings, root pass, etc # for a list of recognized variables, see examples/generic-install-on-sda depend_procedure core base # important, don't be confused when worker/variable definitions seem to be missing here. var_OPTS_STRING="c:" var_ARGS_USAGE="-c : Specify a configfile (profile) to be used" var_AUTOMATIC_PROFILE="" # TODO: if the user does aif -p automatic -c, then $1 is ":-" ??? if you do -c then it's ok. process_args () { if [ "$1" = '-c' ] then [ -z "$2" ] && die_error "You must specify a config" var_AUTOMATIC_PROFILE=$2 else usage exit 5 fi } worker_intro () { notify "Automatic procedure running profile $var_AUTOMATIC_PROFILE ...\n$DISCLAIMER" } worker_configure () { var_UI_TYPE=${arg_ui_type:-cli} ui_init [ -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" # Check mandatory options [ -z "$PARTITIONS" ] && die_error "You did not specify a partition scheme" [ -z "$BLOCKDATA" ] && die_error "You did not specify a partition scheme" [ -z "$GRUB_DEVICE" ] && die_error "You did not specify a grub device" # initialize internal variables based on variables set by the user (some of the vars are handled in other workers): var_RUNTIME_REPOSITORIES=$RUNTIME_REPOSITORIES var_RUNTIME_PACKAGES=$RUNTIME_PACKAGES var_GRUB_DEVICE=$GRUB_DEVICE var_PARTITIONS=$PARTITIONS var_BLOCKDATA=$BLOCKDATA HARDWARECLOCK=${HARDWARECLOCK:-localtime} TIMEZONE=${TIMEZONE:-Canada/Pacific} } worker_select_source () { var_PKG_SOURCE_TYPE=${SOURCE:-cd} var_FILE_URL=${FILE_URL:-file:///src/core/pkg} var_SYNC_URL=${SYNC_URL:-} } worker_prepare_disks () { get_possible_fs echo "$var_PARTITIONS" > $TMP_PARTITIONS echo "$var_BLOCKDATA" > $TMP_BLOCKDEVICES process_disks || die_error "Could not process_disks" if ! process_filesystems then show_warning 'Disk processing' "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 inform "Partitions and filesystems made successfully" # TODO: fstab? auto-add to fstab with libs? auto mkdir's on target_dir? } worker_package_list () { var_TARGET_PACKAGES=$TARGET_PACKAGES var_TARGET_GROUPS=$TARGET_GROUPS var_TARGET_PACKAGES_EXCLUDE=$TARGET_PACKAGES_EXCLUDE [ -z "$var_TARGET_PACKAGES" -a -z "$var_TARGET_GROUPS" ] && var_TARGET_GROUPS=base true } worker_install_packages () { target_prepare_pacman core extra community && installpkg } worker_set_clock () { # uses $TIMEZONE, clock itself remains untouched. copy_timezone_file } worker_install_bootloader () { get_grub_map || return 1 grub-install $var_GRUB_DEVICE --root-directory=/mnt || return 1 # check if we have a seperate bootdev (/boot) # ToDo: This is double-work, find a better place! # See comment in generate_grub_menulst and interactive_grub bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1) generate_grub_menulst || return 1 }