Merge "labs: remove old script queuing mechanism"

This commit is contained in:
Jenkins
2014-10-08 06:52:12 +00:00
committed by Gerrit Code Review
3 changed files with 9 additions and 48 deletions

View File

@@ -88,30 +88,4 @@ function get_next_prefix {
printf "%0${digits}d" "$cnt" printf "%0${digits}d" "$cnt"
} }
#-------------------------------------------------------------------------------
# Helpers for scripts configuration files (config/scripts.*)
#-------------------------------------------------------------------------------
# Configuration files use codes for directories rather than full paths (to make
# them easier to read and write)
function src_dir_code_to_dir {
local src_dir_code=$1
case "$src_dir_code" in
osbash)
echo "$OSBASH_SCRIPTS_DIR"
;;
scripts)
echo "$SCRIPTS_DIR"
;;
config)
echo "$CONFIG_DIR"
;;
*)
# No code, it must be a path already
echo "$src_dir_code"
;;
esac
}
# vim: set ai ts=4 sw=4 et ft=sh: # vim: set ai ts=4 sw=4 et ft=sh:

View File

@@ -214,10 +214,7 @@ function wait_for_autofiles {
# were added to the queue. # were added to the queue.
function _autostart_queue { function _autostart_queue {
local src_dir=${1%/*} local src_path=$SCRIPTS_DIR/$1
# if src_dir is a code, turn it into a real path
src_dir="$(src_dir_code_to_dir "$src_dir")"
local src_name=${1##*/} local src_name=${1##*/}
# If we get a target name, file will be renamed # If we get a target name, file will be renamed
@@ -235,7 +232,6 @@ function _autostart_queue {
echo >&2 -e "\t$src_name -> $target_name" echo >&2 -e "\t$src_name -> $target_name"
fi fi
local src_path=$src_dir/$src_name
cp -- "$src_path" "$AUTOSTART_DIR/$target_name" cp -- "$src_path" "$AUTOSTART_DIR/$target_name"
${WBATCH:-:} wbatch_cp_auto "$src_path" "$AUTOSTART_DIR/$target_name" ${WBATCH:-:} wbatch_cp_auto "$src_path" "$AUTOSTART_DIR/$target_name"
} }
@@ -249,7 +245,7 @@ function log_autostart_source {
echo >&2 "Copying autostart files set in $src_file" echo >&2 "Copying autostart files set in $src_file"
} }
# autostart <src_dir|src_dir_code> <file> <new_name> # autostart <src_dir> <file> <new_name>
# e.g. autostart osbash init_xxx_node.sh init_controller_node.sh # e.g. autostart osbash init_xxx_node.sh init_controller_node.sh
function autostart_and_rename { function autostart_and_rename {
local src_dir=$1 local src_dir=$1
@@ -262,19 +258,16 @@ function autostart_and_rename {
_autostart_queue "$src_dir/$src_file" "$target_file" _autostart_queue "$src_dir/$src_file" "$target_file"
} }
# autostart <src_dir|src_dir_code> <file> [<file> ...] # autostart <file> [<file> ...]
# e.g. autostart scripts prepare_home.sh apt_init.sh # e.g. autostart zero_empty.sh osbash/base_fixups.sh
function autostart { function autostart {
local src_dir=$1
shift
# Don't log this file -- log our caller's source file # Don't log this file -- log our caller's source file
log_autostart_source "${BASH_SOURCE[1]##*/}" log_autostart_source "${BASH_SOURCE[1]##*/}"
while (($#)); do while (($#)); do
local src_file=$1 local src_file=$1
shift shift
_autostart_queue "$src_dir/$src_file" _autostart_queue "$src_file"
done done
} }
@@ -318,7 +311,7 @@ function command_from_config {
# Note: _autostart_queue takes care of dircode # Note: _autostart_queue takes care of dircode
local script_rel_path=${cmd_string[1]} local script_rel_path=${cmd_string[1]}
echo >&2 _autostart_queue "$script_rel_path" echo >&2 _autostart_queue "$script_rel_path"
_autostart_queue "$SCRIPTS_DIR/$script_rel_path" _autostart_queue "$script_rel_path"
;; ;;
*) *)
echo >&2 "Error: invalid cmd: $cmd" echo >&2 "Error: invalid cmd: $cmd"
@@ -348,12 +341,6 @@ function autostart_from_config {
continue continue
elif [ "$field_1" == "cmd" ]; then elif [ "$field_1" == "cmd" ]; then
command_from_config "$field_2" command_from_config "$field_2"
else
# Queue a script for autostart
# Format: <dircode> <script_name>
# Note: _autostart_queue takes care of dircode
echo >&2 _autostart_queue "$field_1/$field_2"
_autostart_queue "$field_1/$field_2"
fi fi
done done
} }

View File

@@ -64,14 +64,14 @@ function vm_install_base {
autostart_reset autostart_reset
# For wbatch, install osbashauto as a boot service # For wbatch, install osbashauto as a boot service
${WBATCH:-:} autostart osbash activate_autostart.sh ${WBATCH:-:} autostart osbash/activate_autostart.sh
autostart osbash base_fixups.sh autostart osbash/base_fixups.sh
# By default, set by lib/osbash/lib.* to something like scripts.ubuntu # By default, set by lib/osbash/lib.* to something like scripts.ubuntu
autostart_from_config "$BASE_INSTALL_SCRIPTS" autostart_from_config "$BASE_INSTALL_SCRIPTS"
autostart scripts zero_empty.sh shutdown.sh autostart zero_empty.sh shutdown.sh
# Boot VM into distribution installer # Boot VM into distribution installer
vbox_boot "$vm_name" vbox_boot "$vm_name"