From 6c2db072c4cf1e6fb86d9f97d52e2468194a9702 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Tue, 26 Dec 2023 13:51:33 -0800 Subject: [PATCH] linux: warn root install --- .../install-scrypted-dependencies-linux.sh | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/install/local/install-scrypted-dependencies-linux.sh b/install/local/install-scrypted-dependencies-linux.sh index 6f1a4d530e..89601876dc 100755 --- a/install/local/install-scrypted-dependencies-linux.sh +++ b/install/local/install-scrypted-dependencies-linux.sh @@ -12,6 +12,26 @@ then exit 1 fi +function readyn() { + while true; do + read -p "$1 (y/n) " yn + case $yn in + [Yy]* ) break;; + [Nn]* ) break;; + * ) echo "Please answer yes or no. (y/n)";; + esac + done +} + +if [ "$SERVICE_USER" == "root" ] +then + readyn "Scrypted will store its files in the root user home directory. Running as a non-root user is recommended. Are you sure?" + if [ "$yn" == "n" ] + then + exit 1 + fi +fi + echo "Stopping existing service if it is running..." systemctl stop scrypted.service @@ -56,12 +76,6 @@ then exit 0 fi -if [ "$SERVICE_USER" == "root" ] -then - echo "Scrypted SERVICE_USER root is not allowed." - exit 1 -fi - # this is not RUN as we do not care about the result USER_HOME=$(eval echo ~$SERVICE_USER) echo "Setting permissions on $USER_HOME/.scrypted"