From 18c6094e3f471de04dce52db9e8a323ce553d7c4 Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Mon, 28 Oct 2024 14:00:22 +0300 Subject: [PATCH] separate logic for user creation and folder preparation Signed-off-by: Uncle Stinky --- scripts/starter.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/starter.sh b/scripts/starter.sh index 040b9ab..ee0fdb4 100755 --- a/scripts/starter.sh +++ b/scripts/starter.sh @@ -289,13 +289,17 @@ if [ $UNIT_FILE = true ]; then echo "[!] user ghost not found" if prompt "[?] do you want to create ghost user? (NOT RECOMMENDED: current $(whoami))"; then sudo useradd --system --create-home $user_name - if [ ! -d $BASE_PATH ]; then - echo "[+] create folder for the node at '$BASE_PATH'" - sudo mkdir $BASE_PATH - fi else user_name=$(whoami) fi + fi + + if [ ! -d $BASE_PATH ]; then + echo "[+] create folder for the node at '$BASE_PATH'" + sudo mkdir $BASE_PATH + fi + + if [ -z "$(stat -c "%U %G" $BASE_PATH | grep $user_name)" ]; then echo "[+] make $user_name owner of $BASE_PATH" sudo chown -R "$user_name:" $BASE_PATH fi