From 04f7df8e693cf5b79e6f3dfaeb16c7742027c82c Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Sat, 11 Aug 2018 09:41:56 +0100 Subject: [PATCH] Tidying --- src/freedombone-installer | 42 ++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/src/freedombone-installer b/src/freedombone-installer index 138229af1..aceb5bc61 100755 --- a/src/freedombone-installer +++ b/src/freedombone-installer @@ -895,38 +895,22 @@ function check_for_existing_processes { { echo '#!/bin/bash'; echo ''; - echo '# ensure that there is no format in progress'; - echo "format_process=\$(ps a | grep 'webadmin_format.sh' | grep -v 'grep')"; - echo "if [ \"\$format_process\" ]; then"; - echo " if [[ \"\$format_process\" != *'grep'* ]]; then"; - echo " format_pid=\$(echo \"\$format_process\" | awk -F ' ' '{print \$1}')"; - echo " if [ \"\$format_pid\" ]; then"; - echo " exit 0"; + echo 'function exit_if_process_is_running {'; + echo " process_name=\"\$1\""; + echo " format_process=\$(ps a | grep \"\$process_name\" | grep -v 'grep')"; + echo " if [ \"\$format_process\" ]; then"; + echo " if [[ \"\$format_process\" != *'grep'* ]]; then"; + echo " format_pid=\$(echo \"\$format_process\" | awk -F ' ' '{print \$1}')"; + echo " if [ \"\$format_pid\" ]; then"; + echo " exit 0"; + echo ' fi'; echo ' fi'; echo ' fi'; - echo 'fi'; - echo ''; - echo '# ensure that there are no other running backups'; - echo "backup_process=\$(ps a | grep 'webadmin_backup.sh' | grep -v 'grep')"; - echo "if [ \"\$backup_process\" ]; then"; - echo " if [[ \"\$backup_process\" != *'grep'* ]]; then"; - echo " backup_pid=\$(echo \"\$backup_process\" | awk -F ' ' '{print \$1}')"; - echo " if [ \"\$backup_pid\" ]; then"; - echo " exit 0"; - echo ' fi'; - echo ' fi'; - echo 'fi'; + echo '}'; echo ''; - echo '# ensure that there are no other running restores'; - echo "restore_process=\$(ps a | grep 'webadmin_restore.sh' | grep -v 'grep')"; - echo "if [ \"\$restore_process\" ]; then"; - echo " if [[ \"\$restore_process\" != *'grep'* ]]; then"; - echo " restore_pid=\$(echo \"\$restore_process\" | awk -F ' ' '{print \$1}')"; - echo " if [ \"\$restore_pid\" ]; then"; - echo " exit 0"; - echo ' fi'; - echo ' fi'; - echo 'fi'; + echo 'exit_if_process_is_running webadmin_format.sh'; + echo 'exit_if_process_is_running webadmin_backup.sh'; + echo 'exit_if_process_is_running webadmin_restore.sh'; echo ''; } > "$script_name" } -- GitLab