Skip to content

Commit

Permalink
Add install script to simplify the deployment of SSM (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohuan771634 authored and PHILO-HE committed Aug 1, 2018
1 parent d98afaa commit 4b848d5
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 1 deletion.
127 changes: 127 additions & 0 deletions bin/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

BIN_HOME=$(cd `dirname $0`;pwd)
SSM_HOME=${BIN_HOME%/*}
SSM_NAME=${SSM_HOME##*/}
CONF_DIR=$SSM_HOME/conf
INSTALL_PATH=''

cd $SSM_HOME/../;

#config option is used to specify SSM's conf directory, e.g. "./install.sh --config ". If not given, the default conf is $SSM_HOME/config.
while [ $# != 0 ]; do
case "$1" in
"--config")
shift
CONF_DIR="$1"
if [[ ! -d "${CONF_DIR}" ]]; then
echo "ERROR : ${CONF_DIR} is not a directory"
exit 1
else
if [[ $CONF_DIR != */ ]];then
CONF_DIR=${CONF_DIR}/
fi
break
fi
;;
*)
echo no command \"./install.sh $1\"
exit 1
;;
esac
done

cat $CONF_DIR/servers $CONF_DIR/agents >>/dev/null 2>/dev/null
if [ $? = 1 ];then
echo -e "there is no file named 'agents' or 'servers' under $CONF_DIR"
exit 1
fi

echo -e "SSM will be installed on the below hosts \033[33m(empty means there is no host configured)\033[0m"

IFS=$'\n'
for host in `cat $CONF_DIR/servers;echo '';cat $CONF_DIR/agents`
do
host=$(echo $host | tr -d " ")
if [[ "$host" =~ ^#.* ]];then
continue
else
echo -n -e "\033[33m$host \033[0m "
fi
done

echo ""

user=`whoami`
if [[ "$user" = "root" ]];then
DEFAULT_PATH=/root/
else DEFAULT_PATH=/home/$user/
fi

while true;do
read -p "Do you want to continue installing? Please type [Y|y] or [N|n]:
" yn
case $yn in
[Yy]* )
read -p "$(echo -e "Please type in the path where you want to install SSM \033[33m(empty means using default path '$DEFAULT_PATH')\033[0m":)
" INSTALL_PATH
break;;
[Nn]* ) exit 1;;
* ) continue;;
esac
done

if [ -z "$INSTALL_PATH" ];then
INSTALL_PATH=$DEFAULT_PATH
fi

echo installing...

if [[ $INSTALL_PATH != */ ]];then
INSTALL_PATH=${INSTALL_PATH}/
fi

tar cf "${SSM_NAME}.tar" ${SSM_NAME}

for host in `cat $CONF_DIR/servers;echo '';cat $CONF_DIR/agents`
do
host=$(echo $host | tr -d " ")
if [[ "$host" =~ ^#.* ]];then
continue
else
#Before install on a host, delete ssm home directory if there exists
ssh $host "if [ -d ${INSTALL_PATH}${SSM_NAME} ];then rm -rf ${INSTALL_PATH}${SSM_NAME};fi"
flag=`ssh $host "if [ -d $INSTALL_PATH ];then echo 1; else echo 0; fi"`
if [ $flag = 1 ];then
echo installing SSM to $host...
scp ${SSM_NAME}.tar $host:$INSTALL_PATH >> /dev/null
ssh $host "cd ${INSTALL_PATH};tar xf ${SSM_NAME}.tar;rm -f ${SSM_NAME}.tar"
elif [ $flag = 0 ];then
ssh $host "mkdir $INSTALL_PATH"
echo installing SSM to $host...
scp ${SSM_NAME}.tar $host:$INSTALL_PATH >> /dev/null
ssh $host "cd ${INSTALL_PATH};tar xf ${SSM_NAME}.tar;rm -f ${SSM_NAME}.tar"
else
rm -f ${SSM_NAME}.tar
exit 1
fi
fi
done

rm -f ${SSM_NAME}.tar
2 changes: 1 addition & 1 deletion docs/ssm-deployment-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ After finishing the SSM configuration, we can start to deploy the SSM package wi
# Deploy SSM
---------------------------------------------------------------------------------

SSM supports two running modes, standalone service and SSM service with multiple Smart Agents. If file move performance is not the concern, then standalone service mode is enough. If better performance is desired, we recommend to deploy one agent on each Datanode.
SSM supports two running modes, standalone service and SSM service with multiple Smart Agents. If file move performance is not the concern, then standalone service mode is enough. If better performance is desired, we recommend to deploy one agent on each Datanode. To deploy SSM to Smart Server nodes and Smart Agent nodes (if configured), you can enter into ${SMART_HOME} directory and type "./bin/install.sh". You can use --config <config-dir> to specify where SSM's config directory is. ${SMART_HOME}/conf is the default config directory if the config option is not used.

## Standalone SSM Service

Expand Down

0 comments on commit 4b848d5

Please sign in to comment.