run.sh: add utility functions & initial setup step
This commit is contained in:
parent
8c394192b5
commit
74d5b16c06
1 changed files with 47 additions and 1 deletions
48
src/run.sh
48
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
|
||||
|
|
Loading…
Reference in a new issue