separate logic for user creation and folder preparation

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2024-10-28 14:00:22 +03:00
parent e182e86590
commit 18c6094e3f
Signed by: st1nky
GPG Key ID: 016064BD97603B40

View File

@ -289,13 +289,17 @@ if [ $UNIT_FILE = true ]; then
echo "[!] user ghost not found" echo "[!] user ghost not found"
if prompt "[?] do you want to create ghost user? (NOT RECOMMENDED: current $(whoami))"; then if prompt "[?] do you want to create ghost user? (NOT RECOMMENDED: current $(whoami))"; then
sudo useradd --system --create-home $user_name sudo useradd --system --create-home $user_name
else
user_name=$(whoami)
fi
fi
if [ ! -d $BASE_PATH ]; then if [ ! -d $BASE_PATH ]; then
echo "[+] create folder for the node at '$BASE_PATH'" echo "[+] create folder for the node at '$BASE_PATH'"
sudo mkdir $BASE_PATH sudo mkdir $BASE_PATH
fi fi
else
user_name=$(whoami) if [ -z "$(stat -c "%U %G" $BASE_PATH | grep $user_name)" ]; then
fi
echo "[+] make $user_name owner of $BASE_PATH" echo "[+] make $user_name owner of $BASE_PATH"
sudo chown -R "$user_name:" $BASE_PATH sudo chown -R "$user_name:" $BASE_PATH
fi fi