blob: 1b4e5790abdec13bcc36ca0c00e03c30fc7d3701 [file] [log] [blame]
#!/bin/bash
#-------------------------------------------------------------------------------
# Remotely pushes bits to a remote machine and install & starts ONOS.
#-------------------------------------------------------------------------------
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults
# If the first option is -f attempt uninstall first.
[ "$1" = "-f" ] && shift && echo 'Uninstalling...' && onos-uninstall ${1:-$OCI}
remote=$ONOS_USER@${1:-$OCI}
scp -q $ONOS_TAR $remote:/tmp
LOG=$ONOS_INSTALL_DIR/install.log
onos=$ONOS_INSTALL_DIR/bin/onos
ssh $remote "
[ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
# Prepare a landing zone and unroll the bits
echo 'Unpacking...'
sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown sdn:sdn $ONOS_INSTALL_DIR
tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1
# Make a link to the log file directory.
ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
# TODO: Setup ONOS to run as a daemon; for now we at least startup
echo 'Starting...'
nohup $ONOS_INSTALL_DIR/bin/onos-ctl server </dev/null | 1>/opt/onos/svc.log 2>&1 &
# Wait until we reach the run-level 100
echo 'Waiting for cluster bootstrap...'
running=""
while [ -z \$running ]; do
$onos bundle:list 2>>$LOG | grep -q 'START LEVEL 100' && running=1 || sleep 2
done
# Now create group onos and join it, while quitting the default one
if ! $onos cluster:group-list 2>>$LOG | cut -d \\ -f3 | grep -q onos; then
echo 'Creating ONOS group...'
installRole=primary
$onos cluster:group-create onos 1>>$LOG 2>&1
fi
echo 'Configuring group membership...'
node=\$($onos cluster:node-list 2>>$LOG | grep '^x' | cut -d \\ -f3)
$onos cluster:group-join onos \$node 1>>$LOG 2>&1
$onos cluster:group-quit default \$node 1>>$LOG 2>&1
if [ X\$installRole = Xprimary ]; then
echo 'Installing ONOS bundles...'
$onos cluster:feature-install onos onos-api 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-core 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-openflow 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-cli 1>>$LOG 2>&1
# $onos cluster:feature-install onos onos-gui 1>>$LOG 2>&1
# $onos cluster:feature-install onos onos-rest 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-app-tvue 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-app-fwd 1>>$LOG 2>&1
fi
echo 'Started...'
"