From f4064806dd614ce204b37d35af9b0d6dd20769e8 Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Wed, 8 Aug 2018 15:14:54 +0100 Subject: [PATCH] Make sure that any pre-existing webadmin installs are killed before starting a new one --- src/freedombone-installer | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/freedombone-installer b/src/freedombone-installer index 45a2586ff..4d7058d15 100755 --- a/src/freedombone-installer +++ b/src/freedombone-installer @@ -207,6 +207,17 @@ function set_webadmin_permissions { function run_setup_command { installer_script=/root/.installer.sh { echo '#!/bin/bash'; + echo ''; + echo '# ensure that any other running installs are killed'; + echo "install_process=\$(ps a | grep '/usr/local/bin/freedombone -c' | grep -v 'grep')"; + echo "if [ \"\$install_process\" ]; then"; + echo " if [[ \"\$install_process\" != *'grep'* ]]; then"; + echo " install_pid=\$(echo \"\$install_process\" | awk -F ' ' '{print \$1}')"; + echo " if [ \"\$install_pid\" ]; then"; + echo " pkill -9 \"\$install_pid\""; + echo ' fi'; + echo ' fi'; + echo 'fi'; echo ''; echo 'if [ -f /root/.finished_install_command ]; then'; echo ' rm /root/.finished_install_command'; @@ -467,7 +478,7 @@ fi # If the freedombone command is already running then kill its process #shellcheck disable=SC2009 -install_process=$(ps a | grep '/usr/local/bin/freedombone -c' | head -n 1) +install_process=$(ps a | grep '/usr/local/bin/freedombone -c' | grep -v 'grep') if [ "$install_process" ]; then if [[ "$install_process" != *'grep'* ]]; then install_pid=$(echo "$install_process" | awk -F ' ' '{print $1}') -- GitLab