Committed by
Gerrit Code Review
Proposal for replacing Upstart with init.d script.
Change-Id: I22ad1faac713bb50f0b7ad3dde132363a6588723
Showing
4 changed files
with
62 additions
and
2 deletions
... | @@ -50,4 +50,4 @@ for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do | ... | @@ -50,4 +50,4 @@ for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do |
50 | fi | 50 | fi |
51 | done | 51 | done |
52 | 52 | ||
53 | -exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS | 53 | +exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/start $KARAF_ARGS | ... | ... |
tools/package/init/onos.initd
0 → 100755
1 | +#! /bin/bash | ||
2 | +# ----------------------------------------------------------------------------- | ||
3 | +# init.d script to run ONOS. | ||
4 | +# ----------------------------------------------------------------------------- | ||
5 | + | ||
6 | +start () { | ||
7 | + # TODO check if ONOS is already running first | ||
8 | + | ||
9 | + [ -f /opt/onos/options ] && . /opt/onos/options | ||
10 | + ONOS_USER=${ONOS_USER:-root} | ||
11 | + | ||
12 | + # Ensure that the environment is initialized | ||
13 | + [ -d /opt/onos ] && mkdir /opt/onos/var 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/var | ||
14 | + [ -d /opt/onos ] && mkdir /opt/onos/config 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/config | ||
15 | + [ -d /opt/onos ] && [ ! -h /opt/onos/log ] \ | ||
16 | + && ln -s /opt/onos/karaf/data/log /opt/onos/log || : | ||
17 | + | ||
18 | + [ -f /opt/onos/options ] && . /opt/onos/options | ||
19 | + start-stop-daemon --signal INT --start --chuid ${ONOS_USER:-root} \ | ||
20 | + --exec /opt/onos/bin/onos-service -- ${ONOS_OPTS:-server} \ | ||
21 | + >/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log | ||
22 | +} | ||
23 | + | ||
24 | +stop () { | ||
25 | + /opt/onos/karaf/bin/stop | ||
26 | +} | ||
27 | + | ||
28 | +restart () { | ||
29 | + stop | ||
30 | + start | ||
31 | +} | ||
32 | + | ||
33 | +status () { | ||
34 | + /opt/onos/karaf/bin/status | ||
35 | +} | ||
36 | + | ||
37 | +case $1 in | ||
38 | + start) | ||
39 | + start | ||
40 | + ;; | ||
41 | + stop | force-stop) | ||
42 | + stop | ||
43 | + ;; | ||
44 | + restart) | ||
45 | + shift | ||
46 | + restart "$@" | ||
47 | + ;; | ||
48 | + status) | ||
49 | + status | ||
50 | + exit $? | ||
51 | + ;; | ||
52 | + *) | ||
53 | + echo "Usage: $0 {start|stop|restart|status}" >&2 | ||
54 | + exit 1 | ||
55 | + ;; | ||
56 | +esac | ||
57 | + | ||
58 | +exit 0 |
... | @@ -61,6 +61,7 @@ ssh $remote " | ... | @@ -61,6 +61,7 @@ ssh $remote " |
61 | 61 | ||
62 | # Make a link to the log file directory and make a home for auxiliaries | 62 | # Make a link to the log file directory and make a home for auxiliaries |
63 | ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log | 63 | ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log |
64 | + ln -s $ONOS_INSTALL_DIR/$KARAF_DIST /opt/onos/karaf | ||
64 | mkdir $ONOS_INSTALL_DIR/var | 65 | mkdir $ONOS_INSTALL_DIR/var |
65 | mkdir $ONOS_INSTALL_DIR/config | 66 | mkdir $ONOS_INSTALL_DIR/config |
66 | 67 | ||
... | @@ -70,6 +71,7 @@ ssh $remote " | ... | @@ -70,6 +71,7 @@ ssh $remote " |
70 | 71 | ||
71 | # Install the upstart configuration file and setup options for debugging | 72 | # Install the upstart configuration file and setup options for debugging |
72 | [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.conf /etc/init/onos.conf | 73 | [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.conf /etc/init/onos.conf |
74 | + [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.initd /etc/init.d/onos | ||
73 | echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options | 75 | echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options |
74 | 76 | ||
75 | # Setup correct user to run onos-service | 77 | # Setup correct user to run onos-service | ... | ... |
... | @@ -43,7 +43,7 @@ case $2 in | ... | @@ -43,7 +43,7 @@ case $2 in |
43 | 43 | ||
44 | # Execute the remote commands | 44 | # Execute the remote commands |
45 | for node in $nodes; do | 45 | for node in $nodes; do |
46 | - ssh $ONOS_USER@${node} "sudo ${2:-status} onos" | 46 | + ssh $ONOS_USER@${node} "sudo /etc/init.d/onos ${2:-status}" |
47 | done | 47 | done |
48 | ;; | 48 | ;; |
49 | *) | 49 | *) | ... | ... |
-
Please register or login to post a comment