minupdate

This commit is contained in:
xdrm-brackets 2018-01-29 18:25:09 +01:00
parent 76cb8e335a
commit 8e7d0a4733
3 changed files with 64 additions and 1 deletions

View File

@ -6,7 +6,7 @@ Type=simple
Restart=always Restart=always
User=pi User=pi
Group=pi Group=pi
ExecStart=/usr/bin/git clone --recursive -b master ssh://smmp-server/satsd/debug /service/debug ExecStartPre=/usr/bin/sudo -u sats git clone --recursive -b master ssh://smmp-server/satsd/debug /service/debug
ExecStart=/bin/bash /service/debug/sats/main %i ExecStart=/bin/bash /service/debug/sats/main %i
ExecStop=/bin/sleep 10 ExecStop=/bin/sleep 10

61
sats/daemon Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash
# (1) Primary init.
#--------------------------------------------------------#
# (1) Get absolute folder #
ROOT=$(dirname `realpath $0`);
ROOT=`dirname $ROOT`;
# (2) Check required arguments
test $# -lt 1 && echo -e "ERR: Missing argument\n\n\tSATS_ID\tThe id for the bash-socket\n" && exit 1;
# (2) Start server in background (keep PID)
#--------------------------------------------------------#
# (1) Start server #
$ROOT/com/launch sats $1 44441 44440 9999&
SERV_PID=$!;
# (3) Start daemons
#--------------------------------------------------------#
# (1) GPIO daemon #
$ROOT/sats/gpio sats&
GPIO_PID=$!;
# (2) SYSTEMD daemon #
$ROOT/sats/sysd sats&
SYSD_PID=$!;
# (4) Manage ending proccess
#--------------------------------------------------------#
# (1) Kill subprocesses if Ctrl+C #
on_exit(){
echo 'sats.main.kill';
## {1} Kill GPIO logger ##
echo 'sats.main.gpio.kill';
kill -9 $GPIO_PID 2>/dev/null;
## {2} Kill SYSD logger ##
echo 'sats.main.sysd.kill';
kill -9 $SYSD_PID 2>/dev/null;
## {3} Kill com server ##
echo 'sats.server.kill';
kill -9 $SERV_PID 2>/dev/null;
exit 0;
}
trap "on_exit" INT KILL;
# (5) Bind server to 'main' (this file)
#--------------------------------------------------------#
wait $SERV_PID;
on_exit;

2
sats/main Executable file → Normal file
View File

@ -9,6 +9,8 @@ ROOT=`dirname $ROOT`;
# (2) Check required arguments # (2) Check required arguments
test $# -lt 1 && echo -e "ERR: Missing argument\n\n\tSATS_ID\tThe id for the bash-socket\n" && exit 1; test $# -lt 1 && echo -e "ERR: Missing argument\n\n\tSATS_ID\tThe id for the bash-socket\n" && exit 1;
# (2) Create config dir (if doesn't exist) #
test ! -d $ROOT/config && sudo -u sats ( mkdir $ROOT/config; chown sats:pi $ROOT/config; chmod 770 $ROOT/config );
# (2) Start server in background (keep PID) # (2) Start server in background (keep PID)
#--------------------------------------------------------# #--------------------------------------------------------#