Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | ### Env vars used by this script. (default value) ### |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 6 | # $ONOS_HOME : path of root directory of ONOS repository (~/ONOS) |
| 7 | # $ONOS_CLUSTER_HOME : path of ONOS cluster tools directory (this script's dir) |
| 8 | # $REMOTE_ONOS_HOME : path of root directory of ONOS repository in remote hosts (ONOS) |
| 9 | # $ONOS_CLUSTER_LOGDIR : path of log output directory (~/ONOS/cluster-mgmt/logs) |
| 10 | # $SSH : command name to access host |
| 11 | # $PSSH : command name to access hosts in parallel |
| 12 | # $SCP : command name to copy config file to each host |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 13 | ##################################################### |
| 14 | |
| 15 | |
| 16 | ### Variables read from ONOS config file ### |
| 17 | ONOS_HOME=${ONOS_HOME:-${HOME}/ONOS} |
| 18 | |
| 19 | source ${ONOS_HOME}/scripts/common/utils.sh |
| 20 | |
| 21 | CLUSTER_HOME=${ONOS_CLUSTER_HOME:-$(cd `dirname $0`; pwd)} |
| 22 | CLUSTER_CONF_DIR=${CLUSTER_HOME}/conf |
| 23 | CLUSTER_CONF=${ONOS_CLUSTER_CONF:-${CLUSTER_CONF_DIR}/onos-cluster.conf} |
| 24 | CLUSTER_TEMPLATE_DIR=${CLUSTER_CONF_DIR}/template |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 25 | CLUSTER_LOGDIR=${ONOS_CLUSTER_LOGDIR:-${CLUSTER_HOME}/logs} |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 26 | |
| 27 | REMOTE_ONOS_HOME=${REMOTE_ONOS_HOME:-ONOS} |
| 28 | REMOTE_ONOS_CONF_DIR=${REMOTE_ONOS_HOME}/conf |
| 29 | |
| 30 | if [ ! -f ${CLUSTER_CONF} ]; then |
| 31 | echo "${CLUSTER_CONF} not found." |
| 32 | exit 1 |
| 33 | fi |
Naoki Shiota | 9109a1e | 2014-05-13 11:11:01 -0700 | [diff] [blame] | 34 | CLUSTER_HOSTS=$(read-conf ${CLUSTER_CONF} cluster.hosts.names `hostname` | tr ',' ' ') |
| 35 | CLUSTER_BACKEND=$(read-conf ${CLUSTER_CONF} cluster.hosts.backend) |
| 36 | CLUSTER_RC_PROTOCOL=$(read-conf ${CLUSTER_CONF} cluster.hosts.ramcloud.protocol "fast+udp") |
| 37 | CLUSTER_RC_SERVER_REPLICAS=$(read-conf ${CLUSTER_CONF} cluster.hosts.ramcloud.server.replicas "0") |
| 38 | CLUSTER_HC_NETWORK=$(read-conf ${CLUSTER_CONF} cluster.hosts.hazelcast.network) |
| 39 | CLUSTER_HC_ADDR=$(read-conf ${CLUSTER_CONF} cluster.hosts.hazelcast.multicast.address "224.2.2.3") |
| 40 | CLUSTER_HC_PORT=$(read-conf ${CLUSTER_CONF} cluster.hosts.hazelcast.multicast.port "54327") |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 41 | ############################################ |
| 42 | |
| 43 | |
| 44 | ONOS_CONF_TEMPLATE=${CLUSTER_TEMPLATE_DIR}/onos_node.conf.template |
| 45 | |
| 46 | |
| 47 | ### Parallel SSH settings ### |
| 48 | SSH=${SSH:-ssh} |
| 49 | PSSH=${PSSH:-parallel-ssh} |
| 50 | PSSH_CONF=${CLUSTER_CONF_DIR}/pssh.hosts |
| 51 | SCP=${SCP:-scp} |
| 52 | ############################# |
| 53 | |
| 54 | |
| 55 | ############# Common functions ############# |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 56 | function print-usage { |
| 57 | local scriptname=`basename $0` |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 58 | local usage="Usage: setup/deploy/start/stop/status ONOS cluster. |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 59 | \$ ${scriptname} setup [-f] |
| 60 | Set up ONOS cluster using ${CLUSTER_CONF}. |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 61 | If -f option is used, all existing files will be overwritten without confirmation. |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 62 | \$ ${scriptname} deploy [-f] |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 63 | Deliver node config files to cluster nodes. |
| 64 | If -f option is used, all existing files will be overwritten without confirmation. |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 65 | \$ ${scriptname} start |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 66 | Start ONOS cluster |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 67 | \$ ${scriptname} stop |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 68 | Stop ONOS cluster |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 69 | \$ ${scriptname} status |
| 70 | Show status of ONOS-cluster |
| 71 | \$ ${scriptname} cmd {command to execute} |
| 72 | Execute command on all hosts in parallel" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 73 | |
| 74 | echo "${usage}" |
| 75 | } |
| 76 | |
| 77 | ############################################ |
| 78 | |
| 79 | |
| 80 | ############# Setup functions ############## |
| 81 | |
| 82 | function list-zk-hosts { |
| 83 | local list=() |
| 84 | for host in ${CLUSTER_HOSTS}; do |
| 85 | local zk_host_string=$(read-conf ${CLUSTER_CONF} "cluster.${host}.zk.host") |
| 86 | |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 87 | if [ -z "${zk_host_string}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 88 | # falling back to ip |
| 89 | zk_host_string=$(read-conf ${CLUSTER_CONF} "cluster.${host}.ip") |
| 90 | fi |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 91 | if [ -z "${zk_host_string}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 92 | # falling back to hostname |
| 93 | zk_host_string=${host} |
| 94 | fi |
| 95 | |
| 96 | list=("${list[@]}" ${zk_host_string}) |
| 97 | done |
| 98 | |
| 99 | # join with comma |
| 100 | local IFS=, |
| 101 | echo "${list[*]}" |
| 102 | } |
| 103 | |
| 104 | function list-hc-hosts { |
| 105 | local list=() |
| 106 | for host in ${CLUSTER_HOSTS}; do |
| 107 | local hc_host_string=$(read-conf ${CLUSTER_CONF} "cluster.${host}.hazelcast.ip") |
| 108 | |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 109 | if [ -z "${hc_host_string}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 110 | # falling back to ip |
| 111 | hc_host_string=$(read-conf ${CLUSTER_CONF} "cluster.${host}.ip") |
| 112 | fi |
| 113 | |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 114 | if [ -z "${hc_host_string}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 115 | # falling back to hostname |
| 116 | hc_host_string=${host} |
| 117 | fi |
| 118 | |
| 119 | list=("${list[@]}" ${hc_host_string}) |
| 120 | done |
| 121 | |
| 122 | local IFS=, |
| 123 | echo "${list[*]}" |
| 124 | } |
| 125 | |
| 126 | function create-pssh-conf { |
| 127 | local tempfile=`begin-conf-creation ${PSSH_CONF}` |
| 128 | |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 129 | local filename=`basename ${PSSH_CONF}` |
| 130 | echo -n "Creating ${filename} ... " |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 131 | # creation of pssh config file |
| 132 | for host in ${CLUSTER_HOSTS}; do |
| 133 | local user=$(read-conf ${CLUSTER_CONF} remote.${host}.ssh.user) |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 134 | if [ -z "${user}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 135 | # falling back to common setting |
| 136 | user=$(read-conf ${CLUSTER_CONF} remote.common.ssh.user) |
| 137 | fi |
| 138 | |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 139 | if [ -z "${user}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 140 | echo ${host} >> ${tempfile} |
| 141 | else |
| 142 | echo ${user}@${host} >> ${tempfile} |
| 143 | fi |
| 144 | done |
| 145 | |
| 146 | end-conf-creation ${PSSH_CONF} |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 147 | echo "DONE" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | # create-onos-conf {hostname} |
| 151 | function create-onos-conf { |
| 152 | local host_name=${1} |
| 153 | |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 154 | if [ -z "${host_name}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 155 | echo "FAILED" |
| 156 | echo "[ERROR] invalid hostname ${host_name}" |
| 157 | exit 1 |
| 158 | fi |
| 159 | |
| 160 | local onos_conf="${CLUSTER_CONF_DIR}/onos_node.${host_name}.conf" |
| 161 | local tempfile=`begin-conf-creation ${onos_conf}` |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 162 | local filename=`basename ${onos_conf}` |
| 163 | echo -n "Creating ${filename} ... " |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 164 | |
| 165 | cp ${ONOS_CONF_TEMPLATE} ${tempfile} |
| 166 | |
| 167 | local prefix="cluster.${host}" |
| 168 | |
| 169 | local host_ip=$(read-conf ${CLUSTER_CONF} "${prefix}.ip") |
| 170 | local host_string=${host_ip} |
| 171 | if [ -z "${host_string}" ]; then |
| 172 | host_string=${host_name} |
| 173 | fi |
| 174 | local host_role=$(read-conf ${CLUSTER_CONF} "${prefix}.role") |
| 175 | local zk_hosts=`list-zk-hosts` |
| 176 | local rc_ip=$(read-conf ${CLUSTER_CONF} "${prefix}.ramcloud.ip" ${host_string}) |
| 177 | local rc_coord_port=$(read-conf ${CLUSTER_CONF} "${prefix}.ramcloud.coordinator.port" 12246) |
| 178 | local rc_server_port=$(read-conf ${CLUSTER_CONF} "${prefix}.ramcloud.server.port" 12242) |
| 179 | local hc_hosts=`list-hc-hosts` |
| 180 | |
| 181 | # creation of ONOS node config file |
| 182 | sed -i -e "s|__HOST_NAME__|${host_name}|" ${tempfile} |
| 183 | if [ -z "${host_ip}" ]; then |
| 184 | # comment out |
| 185 | sed -i -e "s|^\(.*__HOST_IP__.*\)$|#\1|" ${tempfile} |
| 186 | else |
| 187 | sed -i -e "s|__HOST_IP__|${host_ip}|" ${tempfile} |
| 188 | fi |
| 189 | sed -i -e "s|__ONOS_ROLE__|${host_role}|" ${tempfile} |
| 190 | sed -i -e "s|__BACKEND__|${CLUSTER_BACKEND}|" ${tempfile} |
| 191 | sed -i -e "s|__ZK_HOSTS__|${zk_hosts}|" ${tempfile} |
| 192 | sed -i -e "s|__RAMCLOUD_PROTOCOL__|${CLUSTER_RC_PROTOCOL}|" ${tempfile} |
| 193 | sed -i -e "s|__RAMCLOUD_IP__|${rc_ip}|" ${tempfile} |
| 194 | sed -i -e "s|__RAMCLOUD_COORD_PORT__|${rc_coord_port}|" ${tempfile} |
| 195 | sed -i -e "s|__RAMCLOUD_SERVER_PORT__|${rc_server_port}|" ${tempfile} |
Naoki Shiota | 9109a1e | 2014-05-13 11:11:01 -0700 | [diff] [blame] | 196 | sed -i -e "s|__RAMCLOUD_SERVER_REPLICAS__|${CLUSTER_RC_SV_REPLICAS}|" ${tempfile} |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 197 | |
| 198 | if [ ${CLUSTER_HC_NETWORK} = "tcp-ip" ]; then |
| 199 | sed -i -e "s|__HAZELCAST_MEMBERS__|${hc_hosts}|" ${tempfile} |
| 200 | |
| 201 | # Comment out unused parameters |
| 202 | sed -i -e "s|^\(.*__HAZELCAST_MULTICAST_GROUP__.*\)$|#\1|" ${tempfile} |
| 203 | sed -i -e "s|^\(.*__HAZELCAST_MULTICAST_PORT__.*\)$|#\1|" ${tempfile} |
| 204 | elif [ ${CLUSTER_HC_NETWORK} = "multicast" ]; then |
| 205 | sed -i -e "s|__HAZELCAST_MULTICAST_GROUP__|${CLUSTER_HC_ADDR}|" ${tempfile} |
| 206 | sed -i -e "s|__HAZELCAST_MULTICAST_PORT__|${CLUSTER_HC_PORT}|" ${tempfile} |
| 207 | |
| 208 | sed -i -e "s|^\(.*__HAZELCAST_MEMBERS__.*\)$|#\1|" ${tempfile} |
| 209 | fi |
| 210 | |
| 211 | end-conf-creation ${onos_conf} |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 212 | |
| 213 | echo "DONE" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | # setup -f : force overwrite existing files |
| 217 | function setup { |
| 218 | if [ "${1}" = "-f" ]; then |
| 219 | create-pssh-conf |
| 220 | |
| 221 | for host in ${CLUSTER_HOSTS}; do |
| 222 | create-onos-conf ${host} |
| 223 | done |
| 224 | else |
| 225 | create-conf-interactive ${PSSH_CONF} create-pssh-conf |
| 226 | |
| 227 | for host in ${CLUSTER_HOSTS}; do |
| 228 | local filename="${CLUSTER_CONF_DIR}/onos_node.${host}.conf" |
| 229 | create-conf-interactive ${filename} create-onos-conf ${host} |
| 230 | done |
| 231 | fi |
| 232 | } |
| 233 | |
| 234 | ############################################ |
| 235 | |
| 236 | |
| 237 | ############ Deploy functions ############## |
| 238 | |
| 239 | function deploy { |
| 240 | if [ ! -f ${PSSH_CONF} ]; then |
| 241 | echo "[ERROR] ${PSSH_CONF} not found" |
| 242 | local command=`basename ${0}` |
| 243 | echo "[ERROR] Try \"${command} setup\" to create files." |
| 244 | exit 1 |
| 245 | fi |
| 246 | |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 247 | mkdir -p ${CLUSTER_LOGDIR} |
| 248 | |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 249 | for host in ${CLUSTER_HOSTS}; do |
| 250 | local conf=${CLUSTER_CONF_DIR}/onos_node.${host}.conf |
| 251 | if [ ! -f ${conf} ]; then |
| 252 | echo "[ERROR] ${conf} not found" |
| 253 | local command=`basename ${0}` |
| 254 | echo "[ERROR] Try \"${command} setup\" to create files." |
| 255 | exit 1 |
| 256 | fi |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 257 | |
| 258 | local filename=`basename ${conf}` |
| 259 | echo -n "Copying ${filename} to ${host} ... " |
| 260 | |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 261 | local user=$(read-conf ${CLUSTER_CONF} "remote.${host}.ssh.user") |
Naoki Shiota | b7eb55d | 2014-04-21 18:21:36 -0700 | [diff] [blame] | 262 | if [ -z "${user}" ]; then |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 263 | # falling back to common setting |
| 264 | user=$(read-conf ${CLUSTER_CONF} "remote.common.ssh.user") |
| 265 | fi |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 266 | |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 267 | local login= |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 268 | if [ -z "${user}" ]; then |
| 269 | user=`whoami` |
| 270 | fi |
| 271 | |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 272 | ${SCP} ${conf} ${user}@${host}:${REMOTE_ONOS_CONF_DIR} &> ${CLUSTER_LOGDIR}/deploy.${host}.log |
| 273 | echo "DONE" |
| 274 | |
| 275 | echo -n "Configuring ${host} ... " |
| 276 | ${SSH} ${user}@${host} "cd ${REMOTE_ONOS_HOME}; ./onos.sh setup -f; ./build-ramcloud-java-bindings.sh" &>> ${CLUSTER_LOGDIR}/deploy.${host}.log |
| 277 | echo "DONE" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 278 | done |
| 279 | |
| 280 | # TODO: Replacing per-host ssh command with pssh command below. |
| 281 | # Need to solve concurrency problem when ONOS directory is shared among hosts. |
| 282 | # ${PSSH} -i -h ${PSSH_CONF} "cd ${REMOTE_ONOS_HOME}; ./onos.sh setup -f" |
| 283 | } |
| 284 | ############################################ |
| 285 | |
| 286 | |
| 287 | ############# Start functions ############## |
| 288 | |
| 289 | function start { |
| 290 | if [ ! -f ${PSSH_CONF} ]; then |
| 291 | echo "[ERROR] ${PSSH_CONF} not found" |
| 292 | local command=`basename ${0}` |
| 293 | echo "[ERROR] Try \"${command} setup\" to create files." |
| 294 | exit 1 |
| 295 | fi |
| 296 | |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 297 | echo "Starting ONOS cluster" |
| 298 | ${PSSH} -i -h ${PSSH_CONF} "cd ${REMOTE_ONOS_HOME}; ./onos.sh start 2>&1" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | ############################################ |
| 302 | |
| 303 | |
| 304 | ############# Stop functions $############## |
| 305 | |
| 306 | function stop { |
| 307 | if [ ! -f ${PSSH_CONF} ]; then |
| 308 | echo "[ERROR] ${PSSH_CONF} not found" |
| 309 | local command=`basename ${0}` |
| 310 | echo "[ERROR] Try \"${command} setup\" to create files." |
| 311 | exit 1 |
| 312 | fi |
| 313 | |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 314 | echo "Stopping ONOS cluster" |
| 315 | ${PSSH} -i -h ${PSSH_CONF} "cd ${REMOTE_ONOS_HOME}; ./onos.sh stop 2>&1" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | ############################################ |
| 319 | |
| 320 | |
| 321 | ############ Status functions ############## |
| 322 | |
| 323 | function status { |
| 324 | if [ ! -f ${PSSH_CONF} ]; then |
| 325 | echo "[ERROR] ${PSSH_CONF} not found" |
| 326 | local command=`basename ${0}` |
| 327 | echo "[ERROR] Try \"${command} setup\" to create files." |
| 328 | exit 1 |
| 329 | fi |
| 330 | |
Naoki Shiota | b76bc65 | 2014-04-28 19:26:13 -0700 | [diff] [blame] | 331 | ${PSSH} -i -h ${PSSH_CONF} "cd ${REMOTE_ONOS_HOME}; ./onos.sh status 2>&1" |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | ############################################ |
| 335 | |
| 336 | |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 337 | ############## Cmd functions ############### |
| 338 | |
| 339 | function do-cmd { |
| 340 | local cmd=$* |
| 341 | |
| 342 | if [ -z "${cmd}" ]; then |
| 343 | print-usage |
| 344 | else |
| 345 | ${PSSH} -i -h ${PSSH_CONF} "${cmd}" |
| 346 | fi |
| 347 | } |
| 348 | |
| 349 | ############################################ |
| 350 | |
| 351 | |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 352 | ################## Main #################### |
| 353 | case "$1" in |
| 354 | setup) |
| 355 | setup $2 |
| 356 | ;; |
| 357 | deploy) |
| 358 | deploy |
| 359 | ;; |
| 360 | start) |
| 361 | start |
| 362 | ;; |
| 363 | stop) |
| 364 | stop |
| 365 | ;; |
| 366 | stat*) # <- status |
| 367 | status |
| 368 | ;; |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 369 | cmd) |
| 370 | array=("$@") |
| 371 | unset array[0] |
| 372 | do-cmd ${array[@]} |
| 373 | ;; |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 374 | *) |
Naoki Shiota | 05721b3 | 2014-04-29 14:41:12 -0700 | [diff] [blame] | 375 | print-usage |
Naoki Shiota | 9a1e6d1 | 2014-04-03 14:47:12 -0700 | [diff] [blame] | 376 | exit 1 |
| 377 | esac |