From 72e50b25f1eac15e5a9041c9cae0b7c57aca496e Mon Sep 17 00:00:00 2001 From: muggleChen Date: Wed, 9 Nov 2022 11:50:11 +0800 Subject: [PATCH] [Improvement][script] Add installPath verification for install.sh (#12523) --- script/install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/install.sh b/script/install.sh index dcde12ad88..d36f90a3f3 100755 --- a/script/install.sh +++ b/script/install.sh @@ -18,6 +18,7 @@ workDir=`dirname $0` workDir=`cd ${workDir};pwd` +baseDir=`cd ${workDir}/..;pwd` source ${workDir}/env/install_env.sh source ${workDir}/env/dolphinscheduler_env.sh @@ -27,7 +28,10 @@ echo "1.create directory" # If install Path equal to "/" or related path is "/" or is empty, will cause directory "/bin" be overwrite or file adding, # so we should check its value. Here use command `realpath` to get the related path, and it will skip if your shell env # without command `realpath`. -if [ ! -d $installPath ];then +if [ ${baseDir} = $installPath ]; then + echo "Fatal: The installPath can not be same as the current path: ${installPath}" + exit 1 +elif [ ! -d $installPath ];then sudo mkdir -p $installPath sudo chown -R $deployUser:$deployUser $installPath elif [[ -z "${installPath// }" || "${installPath// }" == "/" || ( $(command -v realpath) && $(realpath -s "${installPath}") == "/" ) ]]; then