blob: 4bc41a486d23815c300a1636e72a467490324267 [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
Thomas Vachuska52e65802014-12-08 09:26:01 -080024$(dirname $0)/onos-push-bits $node
tom5c255702014-09-18 06:57:39 -070025
Pavlin Radoslavov20bc6ae2014-12-03 05:35:04 +000026ssh $remote "
tom3014aef2014-09-18 08:44:39 -070027 [ -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
Yuta HIGUCHI43e3a7e2014-11-30 23:22:11 -080038 # create dir for Raft log
39 # TODO: use $KARAF_DATA
40 mkdir -p -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft
41
tomb41d1ac2014-09-24 01:51:24 -070042 # Install the upstart configuration file and setup options for debugging
Thomas Vachuskae9fc5962014-10-21 16:10:12 -070043 [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf
tomb41d1ac2014-09-24 01:51:24 -070044 echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
tom0eaa97f2014-09-22 16:13:06 -070045
Charles M.C. Chan0a4fa792014-12-11 18:50:08 +080046 # Setup correct user to run onos-service
47 echo 'export ONOS_USER="${ONOS_USER:-sdn}"' >> $ONOS_INSTALL_DIR/options
48
Thomas Vachuska5c4324e2014-10-21 20:26:40 -070049 # Remove any previous ON.Lab bits from ~/.m2 repo and re-stage it.
Brian O'Connorabafb502014-12-02 22:26:20 -080050 rm -fr ~/.m2/repository/org/onosproject
51 cp -r $ONOS_INSTALL_DIR/$KARAF_DIST/system/org/onosproject ~/.m2/repository/org/onosproject
tom9ccb2512014-10-07 12:54:53 -070052
53 # Drop log level for the console
Thomas Vachuskae9fc5962014-10-21 16:10:12 -070054 echo "log4j.logger.org.apache.sshd = WARN" \
55 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
tom9ccb2512014-10-07 12:54:53 -070056
tom5c255702014-09-18 06:57:39 -070057"
tom0768a022014-09-24 16:16:16 -070058
59# Configure the ONOS installation
60onos-config $node
61
Thomas Vachuskae9fc5962014-10-21 16:10:12 -070062# Unless -n option was given, attempt to ignite the ONOS service.
63[ -z "$nostart" ] && onos-service $node start