blob: b3f84e4ffdcc5b45a9a881be9decaccddda64cfd [file] [log] [blame]
tom5c255702014-09-18 06:57:39 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom1a2908c2014-09-23 16:37:39 -07003# Remotely pushes bits to a remote node and installs ONOS on it.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom5c255702014-09-18 06:57:39 -07005
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
Thomas Vachuskae9fc5962014-10-21 16:10:12 -07009while getopts fn o; do
10 case "$o" in
11 f) uninstall=true;;
12 n) nostart=true;;
13 esac
14done
15let OPC=$OPTIND-1
16shift $OPC
17
18# If the -f was given, attempt uninstall first.
19[ -n "$uninstall" ] && onos-uninstall ${1:-$OCI}
tom3014aef2014-09-18 08:44:39 -070020
tom0768a022014-09-24 16:16:16 -070021node=${1:-$OCI}
22remote=$ONOS_USER@$node
tom5c255702014-09-18 06:57:39 -070023
tom3014aef2014-09-18 08:44:39 -070024scp -q $ONOS_TAR $remote:/tmp
tom5c255702014-09-18 06:57:39 -070025
tom3014aef2014-09-18 08:44:39 -070026ssh $remote "
27 [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
28
tom1f3805d2014-09-18 19:58:47 -070029 # Prepare a landing zone and unroll the bits
Pavlin Radoslavov3c4d3412014-10-15 10:22:52 -070030 sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_USER} $ONOS_INSTALL_DIR
tom5c255702014-09-18 06:57:39 -070031 tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1
32
tom0eaa97f2014-09-22 16:13:06 -070033 # Make a link to the log file directory and make a home for auxiliaries
tomecd0fbd2014-09-19 08:47:05 -070034 ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
tom0eaa97f2014-09-22 16:13:06 -070035 mkdir $ONOS_INSTALL_DIR/var
tomdefed6f2014-09-29 11:37:02 -070036 mkdir $ONOS_INSTALL_DIR/config
tom0eaa97f2014-09-22 16:13:06 -070037
tomb41d1ac2014-09-24 01:51:24 -070038 # Install the upstart configuration file and setup options for debugging
Thomas Vachuskae9fc5962014-10-21 16:10:12 -070039 [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf
tomb41d1ac2014-09-24 01:51:24 -070040 echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
tom0eaa97f2014-09-22 16:13:06 -070041
Thomas Vachuska5c4324e2014-10-21 20:26:40 -070042 # Remove any previous ON.Lab bits from ~/.m2 repo and re-stage it.
tom2d7acb72014-09-22 22:13:00 -070043 rm -fr ~/.m2/repository/org/onlab
Thomas Vachuska5c4324e2014-10-21 20:26:40 -070044 cp -r $ONOS_INSTALL_DIR/$KARAF_DIST/system/org/onlab ~/.m2/repository/org/onlab
tom9ccb2512014-10-07 12:54:53 -070045
46 # Drop log level for the console
Thomas Vachuskae9fc5962014-10-21 16:10:12 -070047 echo "log4j.logger.org.apache.sshd = WARN" \
48 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
tom9ccb2512014-10-07 12:54:53 -070049
tom5c255702014-09-18 06:57:39 -070050"
tom0768a022014-09-24 16:16:16 -070051
52# Configure the ONOS installation
53onos-config $node
54
Thomas Vachuskae9fc5962014-10-21 16:10:12 -070055# Unless -n option was given, attempt to ignite the ONOS service.
56[ -z "$nostart" ] && onos-service $node start