blob: 1b4e5790abdec13bcc36ca0c00e03c30fc7d3701 [file] [log] [blame]
tom5c255702014-09-18 06:57:39 -07001#!/bin/bash
2#-------------------------------------------------------------------------------
tom3014aef2014-09-18 08:44:39 -07003# Remotely pushes bits to a remote machine and install & starts ONOS.
tom5c255702014-09-18 06:57:39 -07004#-------------------------------------------------------------------------------
5
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
tom3014aef2014-09-18 08:44:39 -07009# If the first option is -f attempt uninstall first.
tomecd0fbd2014-09-19 08:47:05 -070010[ "$1" = "-f" ] && shift && echo 'Uninstalling...' && onos-uninstall ${1:-$OCI}
tom3014aef2014-09-18 08:44:39 -070011
tom5c255702014-09-18 06:57:39 -070012remote=$ONOS_USER@${1:-$OCI}
13
tom3014aef2014-09-18 08:44:39 -070014scp -q $ONOS_TAR $remote:/tmp
tom5c255702014-09-18 06:57:39 -070015
tomecd0fbd2014-09-19 08:47:05 -070016LOG=$ONOS_INSTALL_DIR/install.log
17onos=$ONOS_INSTALL_DIR/bin/onos
18
tom3014aef2014-09-18 08:44:39 -070019ssh $remote "
20 [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
21
tom1f3805d2014-09-18 19:58:47 -070022 # Prepare a landing zone and unroll the bits
tomecd0fbd2014-09-19 08:47:05 -070023 echo 'Unpacking...'
tom3014aef2014-09-18 08:44:39 -070024 sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown sdn:sdn $ONOS_INSTALL_DIR
tom5c255702014-09-18 06:57:39 -070025 tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1
26
tom1f3805d2014-09-18 19:58:47 -070027 # Make a link to the log file directory.
tomecd0fbd2014-09-19 08:47:05 -070028 ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
tom1f3805d2014-09-18 19:58:47 -070029
30 # TODO: Setup ONOS to run as a daemon; for now we at least startup
tomecd0fbd2014-09-19 08:47:05 -070031 echo 'Starting...'
32 nohup $ONOS_INSTALL_DIR/bin/onos-ctl server </dev/null | 1>/opt/onos/svc.log 2>&1 &
33
34 # Wait until we reach the run-level 100
35 echo 'Waiting for cluster bootstrap...'
36 running=""
37 while [ -z \$running ]; do
38 $onos bundle:list 2>>$LOG | grep -q 'START LEVEL 100' && running=1 || sleep 2
39 done
40
41 # Now create group onos and join it, while quitting the default one
42 if ! $onos cluster:group-list 2>>$LOG | cut -d \\ -f3 | grep -q onos; then
43 echo 'Creating ONOS group...'
44 installRole=primary
45 $onos cluster:group-create onos 1>>$LOG 2>&1
46 fi
47
48 echo 'Configuring group membership...'
49 node=\$($onos cluster:node-list 2>>$LOG | grep '^x' | cut -d \\ -f3)
50 $onos cluster:group-join onos \$node 1>>$LOG 2>&1
51 $onos cluster:group-quit default \$node 1>>$LOG 2>&1
52
53 if [ X\$installRole = Xprimary ]; then
54 echo 'Installing ONOS bundles...'
55 $onos cluster:feature-install onos onos-api 1>>$LOG 2>&1
56 $onos cluster:feature-install onos onos-core 1>>$LOG 2>&1
57 $onos cluster:feature-install onos onos-openflow 1>>$LOG 2>&1
tomab0af292014-09-19 13:04:54 -070058 $onos cluster:feature-install onos onos-cli 1>>$LOG 2>&1
tomecd0fbd2014-09-19 08:47:05 -070059 # $onos cluster:feature-install onos onos-gui 1>>$LOG 2>&1
60 # $onos cluster:feature-install onos onos-rest 1>>$LOG 2>&1
61 $onos cluster:feature-install onos onos-app-tvue 1>>$LOG 2>&1
62 $onos cluster:feature-install onos onos-app-fwd 1>>$LOG 2>&1
63 fi
64
65 echo 'Started...'
tom5c255702014-09-18 06:57:39 -070066"