From 65fe20c41a3ec0cbd73b458006347ecedf1ec3c1 Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 22 Jun 2019 02:48:04 -0500 Subject: [PATCH] Perform checks when generating configs --- firestarter | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/firestarter b/firestarter index 0eb20d3..0bd3cb6 100755 --- a/firestarter +++ b/firestarter @@ -342,6 +342,11 @@ step_check() { if ! [ -d "$HOME" ] || ! [ -r "$HOME" ]; then err "Inaccessible home directory: \"$HOME\"" 54 fi + if ! [ -d "$_configdir" ]; then + if ! mkdir -p "$_configdir" > /dev/null 2>&1; then + err "Failed to create configuration directory: \"$_configdir\"" 52 + fi + fi return 0 } step_preexecute() { @@ -422,12 +427,6 @@ step_preexecute() { fi } step_execute() { - # Ensure we have a config directory - if ! [ -d "$_configdir" ]; then - if ! mkdir -p "$_configdir" > /dev/null 2>&1; then - err "Failed to create configuration directory: \"$_configdir\"" 52 - fi - fi # Ensure we can log if we have to if [ -n "$FS_NOLOG" ]; then log "No logs will be created per FS_NOLOG" @@ -540,8 +539,7 @@ main() { _dryrun=1 ;; g) - step_generate - exit $? + _generate=1 ;; h) step_printhelp @@ -557,10 +555,14 @@ main() { done [ -n "$_dryrun" ] && log "Performing a dry run" step_check - step_preexecute - step_execute - step_postexecute - step_wait + if [ -n "$_generate" ]; then + step_generate + else + step_preexecute + step_execute + step_postexecute + step_wait + fi return 0 }