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 | |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame^] | 6 | function _usage () { |
| 7 | cat << _EOF_ |
| 8 | usage: |
| 9 | $(basename $0) [-fn] [-m] <settings> [node] |
| 10 | |
| 11 | flags: |
| 12 | - -f : forces uninstall of currently installed ONOS |
| 13 | - -n : do not copy over onos.conf upstart configuration file. |
| 14 | - -m <settings> : pass <settings> XML file to remote maven installation |
| 15 | |
| 16 | options: |
| 17 | - [node] : remote node to install ONOS on. |
| 18 | |
| 19 | summary: |
| 20 | Remotely pushes bits to a remote node and installs ONOS on it. |
| 21 | |
| 22 | The [-n] flag assumes that Upstart is used. The [-f] flag depends on |
| 23 | and 'onos-config'. |
| 24 | |
| 25 | If [node] is not specified the default target is \$OCI. |
| 26 | |
| 27 | _EOF_ |
| 28 | } |
| 29 | |
| 30 | [ "$1" = "-h" ] && _usage && exit 0 |
| 31 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 32 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 33 | . $ONOS_ROOT/tools/build/envDefaults |
| 34 | |
Kenji HIKICHI | 237787c | 2015-01-06 19:57:44 +0900 | [diff] [blame] | 35 | while getopts fnm: o; do |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame] | 36 | case "$o" in |
| 37 | f) uninstall=true;; |
| 38 | n) nostart=true;; |
Kenji HIKICHI | 237787c | 2015-01-06 19:57:44 +0900 | [diff] [blame] | 39 | m) mvn_settings=$OPTARG;; |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame] | 40 | esac |
| 41 | done |
| 42 | let OPC=$OPTIND-1 |
| 43 | shift $OPC |
| 44 | |
| 45 | # If the -f was given, attempt uninstall first. |
| 46 | [ -n "$uninstall" ] && onos-uninstall ${1:-$OCI} |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 47 | |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 48 | node=${1:-$OCI} |
| 49 | remote=$ONOS_USER@$node |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 50 | |
Thomas Vachuska | 52e6580 | 2014-12-08 09:26:01 -0800 | [diff] [blame] | 51 | $(dirname $0)/onos-push-bits $node |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 52 | |
Kenji HIKICHI | 237787c | 2015-01-06 19:57:44 +0900 | [diff] [blame] | 53 | [ ! -z "$mvn_settings" ] && scp -q $mvn_settings $remote:/tmp/settings.xml |
| 54 | |
Pavlin Radoslavov | 20bc6ae | 2014-12-03 05:35:04 +0000 | [diff] [blame] | 55 | ssh $remote " |
tom | 3014aef | 2014-09-18 08:44:39 -0700 | [diff] [blame] | 56 | [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1 |
| 57 | |
tom | 1f3805d | 2014-09-18 19:58:47 -0700 | [diff] [blame] | 58 | # Prepare a landing zone and unroll the bits |
Charles M.C. Chan | dfbc6d8 | 2014-12-18 23:11:36 +0800 | [diff] [blame] | 59 | sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_GROUP} $ONOS_INSTALL_DIR |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 60 | tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1 |
| 61 | |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 62 | # 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] | 63 | ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 64 | mkdir $ONOS_INSTALL_DIR/var |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 65 | mkdir $ONOS_INSTALL_DIR/config |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 66 | |
Yuta HIGUCHI | 43e3a7e | 2014-11-30 23:22:11 -0800 | [diff] [blame] | 67 | # create dir for Raft log |
| 68 | # TODO: use $KARAF_DATA |
| 69 | mkdir -p -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft |
| 70 | |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 71 | # Install the upstart configuration file and setup options for debugging |
Brian O'Connor | 0eed29e | 2015-09-16 11:38:33 -0700 | [diff] [blame] | 72 | [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.conf /etc/init/onos.conf |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 73 | echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 74 | |
Charles M.C. Chan | 0a4fa79 | 2014-12-11 18:50:08 +0800 | [diff] [blame] | 75 | # Setup correct user to run onos-service |
| 76 | echo 'export ONOS_USER="${ONOS_USER:-sdn}"' >> $ONOS_INSTALL_DIR/options |
| 77 | |
Thomas Vachuska | 96a303c | 2015-04-28 16:04:50 -0700 | [diff] [blame] | 78 | # Remove any previous ON.Lab bits from ~/.m2 repo. |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 79 | rm -fr ~/.m2/repository/org/onosproject |
tom | 9ccb251 | 2014-10-07 12:54:53 -0700 | [diff] [blame] | 80 | |
Kenji HIKICHI | 237787c | 2015-01-06 19:57:44 +0900 | [diff] [blame] | 81 | [ ! -z "$mvn_settings" ] && cp /tmp/settings.xml ~/.m2/settings.xml |
| 82 | |
tom | 9ccb251 | 2014-10-07 12:54:53 -0700 | [diff] [blame] | 83 | # Drop log level for the console |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame] | 84 | echo "log4j.logger.org.apache.sshd = WARN" \ |
| 85 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg |
tom | 9ccb251 | 2014-10-07 12:54:53 -0700 | [diff] [blame] | 86 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 87 | " |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 88 | |
| 89 | # Configure the ONOS installation |
| 90 | onos-config $node |
| 91 | |
Thomas Vachuska | e9fc596 | 2014-10-21 16:10:12 -0700 | [diff] [blame] | 92 | # Unless -n option was given, attempt to ignite the ONOS service. |
| 93 | [ -z "$nostart" ] && onos-service $node start |