From eb2b4e9ae90a43112b31c5d1bd9e8fca89434e34 Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Wed, 8 Aug 2018 19:09:05 +0100 Subject: [PATCH] Set install state if install is finished --- src/freedombone-installer | 13 +++++++++++++ src/freedombone-utils-final | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/freedombone-installer b/src/freedombone-installer index f8b6551f8..bc4e47185 100755 --- a/src/freedombone-installer +++ b/src/freedombone-installer @@ -521,6 +521,19 @@ fi # get the current install state if [ -f "$install_state_file" ]; then install_state=$(cat "$install_state_file") + # shellcheck disable=SC2086 + if [ $install_state -ne $INSTALL_STATE_COMMAND_SUCCESS ]; then + chown www-data:www-data "$webadmin_install_dir/log.txt" + # remove the setup file containing login details + if [ -f "$setup_file" ]; then + rm "$setup_file" + fi + if [ -f /etc/nginx/.webadminpasswd ]; then + rm /etc/nginx/.webadminpasswd + fi + echo -n "$INSTALL_STATE_FIRST_BOOT" > "$install_state_file" + install_state=$INSTALL_STATE_FIRST_BOOT + fi else echo -n "$INSTALL_STATE_FIRST_BOOT" > "$install_state_file" install_state=$INSTALL_STATE_FIRST_BOOT diff --git a/src/freedombone-utils-final b/src/freedombone-utils-final index be60bc100..4fdb0d5c1 100755 --- a/src/freedombone-utils-final +++ b/src/freedombone-utils-final @@ -27,7 +27,13 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. function install_final { + INSTALL_STATE_RUNNING_COMMAND=2 + INSTALL_STATE_COMMAND_SUCCESS=4 + install_state_file=/root/.install_state.txt + if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then + install_state=$INSTALL_STATE_COMMAND_SUCCESS + echo -n "$INSTALL_STATE_COMMAND_SUCCESS" > "$install_state_file" return fi # unmount any attached usb drive @@ -78,9 +84,6 @@ $(get_ssh_server_key) echo $'Turning off logging' "${PROJECT_NAME}-logging" off --restart - INSTALL_STATE_RUNNING_COMMAND=2 - INSTALL_STATE_COMMAND_SUCCESS=4 - install_state_file=/root/.install_state.txt install_state=$INSTALL_STATE_RUNNING_COMMAND if [ -f "$install_state_file" ]; then install_state=$(cat "$install_state_file") -- GitLab