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