onos-install
2.57 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
62
63
64
65
66
#!/bin/bash
#-------------------------------------------------------------------------------
# Remotely pushes bits to a remote machine and install & starts ONOS.
#-------------------------------------------------------------------------------
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults
# If the first option is -f attempt uninstall first.
[ "$1" = "-f" ] && shift && echo 'Uninstalling...' && onos-uninstall ${1:-$OCI}
remote=$ONOS_USER@${1:-$OCI}
scp -q $ONOS_TAR $remote:/tmp
LOG=$ONOS_INSTALL_DIR/install.log
onos=$ONOS_INSTALL_DIR/bin/onos
ssh $remote "
[ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
# Prepare a landing zone and unroll the bits
echo 'Unpacking...'
sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown sdn:sdn $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.
ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
# TODO: Setup ONOS to run as a daemon; for now we at least startup
echo 'Starting...'
nohup $ONOS_INSTALL_DIR/bin/onos-ctl server </dev/null | 1>/opt/onos/svc.log 2>&1 &
# Wait until we reach the run-level 100
echo 'Waiting for cluster bootstrap...'
running=""
while [ -z \$running ]; do
$onos bundle:list 2>>$LOG | grep -q 'START LEVEL 100' && running=1 || sleep 2
done
# Now create group onos and join it, while quitting the default one
if ! $onos cluster:group-list 2>>$LOG | cut -d \\ -f3 | grep -q onos; then
echo 'Creating ONOS group...'
installRole=primary
$onos cluster:group-create onos 1>>$LOG 2>&1
fi
echo 'Configuring group membership...'
node=\$($onos cluster:node-list 2>>$LOG | grep '^x' | cut -d \\ -f3)
$onos cluster:group-join onos \$node 1>>$LOG 2>&1
$onos cluster:group-quit default \$node 1>>$LOG 2>&1
if [ X\$installRole = Xprimary ]; then
echo 'Installing ONOS bundles...'
$onos cluster:feature-install onos onos-api 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-core 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-openflow 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-cli 1>>$LOG 2>&1
# $onos cluster:feature-install onos onos-gui 1>>$LOG 2>&1
# $onos cluster:feature-install onos onos-rest 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-app-tvue 1>>$LOG 2>&1
$onos cluster:feature-install onos onos-app-fwd 1>>$LOG 2>&1
fi
echo 'Started...'
"