From 74d5b16c06e0b305ee1616fc71c8bf3e454f68f1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 26 Nov 2021 00:32:48 +0000 Subject: [PATCH] run.sh: add utility functions & initial setup step --- src/run.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/run.sh b/src/run.sh index 318bdf0..f60471d 100644 --- a/src/run.sh +++ b/src/run.sh @@ -42,6 +42,48 @@ ask_yesno() { return "$?"; # Not actually needed, but best to be explicit } +queue_postinstall_step() { + local stepname="$1"; + + echo "${stepname}" >>"${temp_dir}/steps.txt"; +} + +queue_apt_install() { + for package_name in "$@"; do + subtask_begin "[apt] Queueing install of ${package_name}"; + echo "${package_name}" >>"${temp_dir}/apt-packages.txt"; + subtask_end "$?"; + done +} + +############################################################################### + + +# ███████ ████████ ███████ ██████ ██████ +# ██ ██ ██ ██ ██ ██ ████ +# ███████ ██ █████ ██████ ██ ██ ██ +# ██ ██ ██ ██ ████ ██ +# ███████ ██ ███████ ██ ██████ + +stage_begin "Preparing to provision host"; + +task_begin "Creating temporary directory"; +temp_dir="$(mktemp --tmpdir -d "sbrl-provisioning-XXXXXXX")"; +on_exit() { + task_begin "Cleaning up"; + rm -rf "${temp_dir}"; +} +trap on_exit EXIT; +task_end "$?"; + + +task_begin "Setting initial state"; +cat apt-packages.txt >"${temp_dir}/apt-packages.txt"; +queue_postinstall_step "base"; +task_end "$?"; + +stage_end "$?"; + ############################################################################### # ███████ ████████ ███████ ██████ ██ @@ -52,5 +94,9 @@ ask_yesno() { step_current="1"; if ask_yesno "Use apt cache?"; then - source ./steps/10-apt-cache.sh; + source ./steps-config/10-apt-cache.sh; +fi + +if ask_yesno "Install Docker?"; then + source ./steps-config/10-docker.sh; fi