Add another mode to build a test widget.
[apps/app-templates.git] / template.d / start-on-target.sh.in
1 #!/bin/sh
2 #
3 # File:   start-on-target.sh
4 # Author: Fulup Ar Foll @ IoT.bzh
5 # Object: Forward signal (SIGTERM) to remote process
6 # Created on 24-May-2017, 09:23:37
7 # Usage: remote-target-populate update script under ./build directory
8
9 # Do not change manually use 'make remote-target-populate'
10 export RSYNC_TARGET=@RSYNC_TARGET@
11 export PROJECT_NAME=@PROJECT_NAME@
12 export RSYNC_PREFIX=@RSYNC_PREFIX@/@PROJECT_NAME@
13 export AFB_REMPORT=@AFB_REMPORT@
14 export AFB_TOKEN=@AFB_TOKEN@
15
16 exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -tt $RSYNC_TARGET << EOF
17     CONTROL_CONFIG_PATH=$RSYNC_PREFIX/etc \
18     afb-daemon \
19         --workdir=$RSYNC_PREFIX \
20         --monitoring \
21         --port=$AFB_REMPORT \
22         --roothttp=./htdocs \
23         --ldpaths=./lib \
24         --verbose \
25         --token=$AFB_TOKEN \
26         --name $PROJECT_NAME &
27
28     PID_DAEMON=\$!
29     trap "echo REMOTE-SIGNAL TRAP; kill -15 \$PID_DAEMON" INT QUIT TERM EXIT
30     echo "Target Process Waiting for command"
31
32     # wait for daemon to finish
33     wait \$PID_DAEMON
34     exit
35 EOF