tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 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. |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame^] | 9 | while getopts fn o; do |
| 10 | case "$o" in |
| 11 | f) uninstall=true;; |
| 12 | n) nostart=true;; |
| 13 | esac |
| 14 | done |
| 15 | let OPC=$OPTIND-1 |
| 16 | shift $OPC |
| 17 | |
| 18 | # If the -f was given, attempt uninstall first. |
| 19 | [ -n "$uninstall" ] && onos-uninstall ${1:-$OCI} |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 20 | |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 21 | node=${1:-$OCI} |
| 22 | remote=$ONOS_USER@$node |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 23 | |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 24 | scp -q $ONOS_TAR $remote:/tmp |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 25 | |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 26 | ssh $remote " |
| 27 | [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1 |
| 28 | |
tom | 1f3805d | 2014-09-18 19:58:47 -0700 | [diff] [blame] | 29 | # Prepare a landing zone and unroll the bits |
Pavlin Radoslavov | 3c4d341 | 2014-10-15 10:22:52 -0700 | [diff] [blame] | 30 | sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_USER} $ONOS_INSTALL_DIR |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 31 | tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1 |
| 32 | |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 33 | # 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] | 34 | ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 35 | mkdir $ONOS_INSTALL_DIR/var |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 36 | mkdir $ONOS_INSTALL_DIR/config |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 37 | |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 38 | # Install the upstart configuration file and setup options for debugging |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame^] | 39 | [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 40 | echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 41 | |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 42 | # Remove any previous ON.Lab bits from ~/.m2 repo |
| 43 | rm -fr ~/.m2/repository/org/onlab |
tom | 9ccb251 | 2014-10-07 12:54:53 -0700 | [diff] [blame] | 44 | |
| 45 | # Drop log level for the console |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame^] | 46 | echo "log4j.logger.org.apache.sshd = WARN" \ |
| 47 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg |
tom | 9ccb251 | 2014-10-07 12:54:53 -0700 | [diff] [blame] | 48 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 49 | " |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 50 | |
| 51 | # Configure the ONOS installation |
| 52 | onos-config $node |
| 53 | |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame^] | 54 | # Unless -n option was given, attempt to ignite the ONOS service. |
| 55 | [ -z "$nostart" ] && onos-service $node start |