Add system to tell if we've provisioned before or not

In theory, we can do a one-click "update" with all the same settings as 
we used previously
This commit is contained in:
Starbeamrainbowlabs 2022-04-10 18:06:06 +01:00
parent 0ef990bff9
commit 6cf5496c69
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 11 additions and 1 deletions

View file

@ -37,6 +37,12 @@ if command_exists lolcat; then
rainbow="lolcat"; rainbow="lolcat";
fi fi
version="$(git rev-parse HEAD)";
last_version="";
if [[ -r "/etc/sbrl-provisioning-commitid.txt" ]]; then
last_version="$(cat "/etc/sbrl-provisioning-commitid.txt")";
fi
############################################################################### ###############################################################################
ask_yesno() { ask_yesno() {
@ -239,6 +245,8 @@ source "steps-last/15-ufw.sh";
step_current="done"; step_current="done";
echo "${version}" >>/etc/sbrl-provisioning-commitid.txt
echo " echo "
██████ ██████ ██████ ██ ██ ██ ███████ ██ ██████ ███ ██ ██ ███ ██ ██████ ██████ ██████ ██████ ██ ██ ██ ███████ ██ ██████ ███ ██ ██ ███ ██ ██████

View file

@ -8,7 +8,9 @@ subtask_begin "Stopping collectd";
systemctl stop collectd; systemctl stop collectd;
subtask_end "$?"; subtask_end "$?";
if [[ -r "/etc/collectd/collectd.conf" ]]; then # If there's an existing config file and we haven't completed provisioning at
# least once yet, move it aside as a backup
if [[ -r "/etc/collectd/collectd.conf" ]] && [[ -z "${last_version}" ]]; then
subtask_begin "Moving existing config file aside"; subtask_begin "Moving existing config file aside";
mv "${collectd_conf_target}" "${collectd_conf_target}.bak-$(date +%Y-%m-%d)"; mv "${collectd_conf_target}" "${collectd_conf_target}.bak-$(date +%Y-%m-%d)";
subtask_end "$?"; subtask_end "$?";