tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
tom | 1a2908c | 2014-09-23 16:37:39 -0700 | [diff] [blame] | 3 | # Remotely pushes bits to a remote node and installs ONOS on it. |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 4 | #------------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 9 | # If the first option is -f attempt uninstall first. |
tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 10 | [ "$1" = "-f" ] && shift && onos-uninstall ${1:-$OCI} |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 11 | |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 12 | node=${1:-$OCI} |
| 13 | remote=$ONOS_USER@$node |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 14 | |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 15 | scp -q $ONOS_TAR $remote:/tmp |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 16 | |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 17 | ssh $remote " |
| 18 | [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1 |
| 19 | |
tom | 1f3805d | 2014-09-18 19:58:47 -0700 | [diff] [blame] | 20 | # Prepare a landing zone and unroll the bits |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 21 | sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown sdn:sdn $ONOS_INSTALL_DIR |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 22 | tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1 |
| 23 | |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 24 | # Make a link to the log file directory and make a home for auxiliaries |
tom | ecd0fbd | 2014-09-19 08:47:05 -0700 | [diff] [blame] | 25 | ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 26 | mkdir $ONOS_INSTALL_DIR/var |
| 27 | |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 28 | # Install the upstart configuration file and setup options for debugging |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 29 | sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 30 | echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 31 | |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 32 | # Remove any previous ON.Lab bits from ~/.m2 repo |
| 33 | rm -fr ~/.m2/repository/org/onlab |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 34 | " |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 35 | |
| 36 | # Configure the ONOS installation |
| 37 | onos-config $node |
| 38 | |
| 39 | # Ignite the ONOS service. |
tom | 7d197c4 | 2014-09-24 16:48:29 -0700 | [diff] [blame] | 40 | onos-service $node start |