onos-install
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# -----------------------------------------------------------------------------
# Remotely pushes bits to a remote node and installs ONOS on it.
# -----------------------------------------------------------------------------
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults
while getopts fn o; do
case "$o" in
f) uninstall=true;;
n) nostart=true;;
esac
done
let OPC=$OPTIND-1
shift $OPC
# If the -f was given, attempt uninstall first.
[ -n "$uninstall" ] && onos-uninstall ${1:-$OCI}
node=${1:-$OCI}
remote=$ONOS_USER@$node
scp -q $ONOS_TAR $remote:/tmp
ssh -t $remote "
[ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
# Prepare a landing zone and unroll the bits
sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_USER} $ONOS_INSTALL_DIR
tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1
# Make a link to the log file directory and make a home for auxiliaries
ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
mkdir $ONOS_INSTALL_DIR/var
mkdir $ONOS_INSTALL_DIR/config
# create dir for Raft log
# TODO: use $KARAF_DATA
mkdir -p -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft
# Install the upstart configuration file and setup options for debugging
[ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf
echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
# Remove any previous ON.Lab bits from ~/.m2 repo and re-stage it.
rm -fr ~/.m2/repository/org/onlab
mkdir -p ~/.m2/repository/org/onlab
cp -r $ONOS_INSTALL_DIR/$KARAF_DIST/system/org/onlab ~/.m2/repository/org/onlab
# Drop log level for the console
echo "log4j.logger.org.apache.sshd = WARN" \
>> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
"
# Configure the ONOS installation
onos-config $node
# Unless -n option was given, attempt to ignite the ONOS service.
[ -z "$nostart" ] && onos-service $node start