run.sh: add utility functions & initial setup step

This commit is contained in:
Starbeamrainbowlabs 2021-11-26 00:32:48 +00:00
parent 8c394192b5
commit 74d5b16c06
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -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