From 7935c05a21f03ff7f6511148fc6b4dfc407d615e Mon Sep 17 00:00:00 2001 From: alok Date: Mon, 13 Dec 2021 14:31:57 +0530 Subject: [PATCH] auto deploy support for non-root user --- install.sh | 41 +++++++++++++++--------- openlookeng/bin/auxiliary_tools/pathfile | 5 +-- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 2a113ad..9d2983b 100644 --- a/install.sh +++ b/install.sh @@ -13,11 +13,21 @@ # limitations under the License. ## #!/bin/bash + +userhome=`echo ~` +echo $userhome +mkdir -p $userhome/openlookeng +if [[ $? != 0 ]] +then + echo "home directory $userhome does not exist!" + exit 1 +fi + export wget_url=https://download.openlookeng.io declare openlk_version= declare version_arr= declare package_name=openlookeng.tar.gz -declare install_path=/opt/openlookeng +declare install_path=/$userhome/openlookeng declare DEFAULT_MAX_SPLITS_PER_NODE_VALUE=100 declare DEFAULT_MAX_PENDING_SPLITS_PER_TASK_VALUE=10 declare CLUSTER_PASS @@ -201,16 +211,16 @@ function download() URL="$wget_url/auto-install/$package_name" if type wget &>/dev/null then - echo "wget -O /opt/$package_name.sha256sum $URL.sha256sum" - wget -O /opt/$package_name.sha256sum $URL.sha256sum - echo "wget -O /opt/$package_name $URL" - wget -O /opt/$package_name $URL + echo "wget -O $userhome/$package_name.sha256sum $URL.sha256sum" + wget -O $userhome/$package_name.sha256sum $URL.sha256sum + echo "wget -O $userhome/$package_name $URL" + wget -O $userhome/$package_name $URL elif type curl &>/dev/null then #wget -P . "$URL" - curl -fsSL -o /opt/$package_name.sha256sum $URL.sha256sum - echo "curl -fsSL -o /opt/$package_name $URL" - curl -fsSL -o /opt/$package_name $URL + curl -fsSL -o $userhome/$package_name.sha256sum $URL.sha256sum + echo "curl -fsSL -o $userhome/$package_name $URL" + curl -fsSL -o $userhome/$package_name $URL fi # download failed if test $? -ne 0 @@ -223,7 +233,7 @@ function download() function verify_unpack() { #1.check package - cd /opt &> /dev/null + cd $userhome &> /dev/null echo "[INFO] Starting verification package..." res=$(sha256sum -c ${package_name}.sha256sum|grep OK|wc -l) if [[ $res > 0 ]] @@ -236,8 +246,8 @@ function verify_unpack() fi #cd - &> /dev/null #2.extracting package - echo "[INFO] Extracting package ${package_name} to /opt ..." - tar -zxvf $package_name -C /opt &> /dev/null + echo "[INFO] Extracting package ${package_name} to $userhome ..." + tar -zxvf $package_name -C $userhome &> /dev/null if [[ $? != 0 ]] then exit 1 @@ -246,9 +256,9 @@ function verify_unpack() rm -rf ${package_name} } function clear_local(){ - if [[ -d $install_path ]] + if [[ -d $userhome ]] then - rm -rf $install_path + rm -rf $userhome fi } function config_cluster() @@ -333,8 +343,8 @@ function create_user() #bash $OPENLOOKENG_BIN_THIRD_PATH/hetu_adduser.sh # will create user before continue else - . $OPENLOOKENG_BIN_THIRD_PATH/cpresource_remote.sh $ip $OPENLOOKENG_BIN_THIRD_PATH/hetu_adduser.sh /opt - . $OPENLOOKENG_BIN_THIRD_PATH/execute_remote.sh $ip "bash /opt/hetu_adduser.sh;rm -rf /opt/hetu_adduser.sh;exit" + . $OPENLOOKENG_BIN_THIRD_PATH/cpresource_remote.sh $ip $OPENLOOKENG_BIN_THIRD_PATH/hetu_adduser.sh $userhome + . $OPENLOOKENG_BIN_THIRD_PATH/execute_remote.sh $ip "bash $userhome/hetu_adduser.sh;rm -rf $userhome/hetu_adduser.sh;exit" fi done @@ -510,6 +520,7 @@ function main() echo "source $install_path/bin/auxiliary_tools/pathfile" #4.create user on local node + echo "$OPENLOOKENG_BIN_THIRD_PATH/hetu_adduser.sh" bash $OPENLOOKENG_BIN_THIRD_PATH/hetu_adduser.sh if [[ $? != 0 ]] then diff --git a/openlookeng/bin/auxiliary_tools/pathfile b/openlookeng/bin/auxiliary_tools/pathfile index ab1a4ee..066f987 100644 --- a/openlookeng/bin/auxiliary_tools/pathfile +++ b/openlookeng/bin/auxiliary_tools/pathfile @@ -13,7 +13,8 @@ # limitations under the License. ## #bin/pathfile -INSTALL_PATH=/opt/openlookeng +homeuser=`echo ~` +INSTALL_PATH=$homeuser/openlookeng OPENLOOKENG_DEPENDENCIES_PATH=$INSTALL_PATH/resource OEPNLKADMIN_PATH=/home/openlkadmin/.openlkadmin CLUSTER_CONFIG_INFO=$OEPNLKADMIN_PATH/cluster_config_info @@ -21,4 +22,4 @@ CLUSTER_NODE_INFO=$OEPNLKADMIN_PATH/cluster_node_info OPENLOOKENG_BIN_PATH=$INSTALL_PATH/bin OPENLOOKENG_BIN_THIRD_PATH=$OPENLOOKENG_BIN_PATH/auxiliary_tools -export INSTALL_PATH OPENLOOKENG_DEPENDENCIES_PATH OEPNLKADMIN_PATH OPENLOOKENG_BIN_PATH OPENLOOKENG_BIN_THIRD_PATH \ No newline at end of file +export INSTALL_PATH OPENLOOKENG_DEPENDENCIES_PATH OEPNLKADMIN_PATH OPENLOOKENG_BIN_PATH OPENLOOKENG_BIN_THIRD_PATH