9e3a60d7a9d951dec4a4ac09c19f671e1c190317
[staging/xdg-launcher.git] / ssh / 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     afb-daemon --workdir=$RSYNC_PREFIX --port=$AFB_REMPORT --roothttp=./htdocs --ldpath=./lib --verbose --token=$AFB_TOKEN &
18     PID_DAEMON=\$!
19
20     trap "echo REMOTE-SIGNAL TRAP; kill -15 \$PID_DAEMON" INT QUIT TERM EXIT
21
22     # wait for daemon to finish
23     wait \$PID_DAEMON
24     exit
25 EOF