Hello - this is completely free. Just my ideas and absolutely no
guarantee that it is correct (it's working for me at least but I'm
rather new to such kind of things and just try to learn stuff like that
by trial-and-error). You can do whatever you want with it :-). And maybe
others do have better ideas!
Am 21.01.2017 um 14:17 schrieb Ben:
Hi,
I'd like to integrate your init file in the contrib directory of the galileo repository [0]. Who knows, it might interest other people !
Can you provide me with a name (and email) I should use for correct authorship ?
Thanks.
Ben.
[0] https://bitbucket.org/benallard/galileo/src/default/contrib/
On Thu, Jan 12, 2017 at 9:43 AM Linux <linux@xxxxxxxxxxxxxxx <mailto:linux@xxxxxxxxxxxxxxx>> wrote:
Hello all,
I was asking earlier on for installing galileo as a service under
Debian
but the question didn't make it to the mailing list - in the
meantime I
spent quite some time in investigating, testing and checking and
think I
found a solution (at least galileo is running fine as a service now,
although I could not test with a reboot yet).
I don't know if what I did is correct and good practice or no. So
comments are welcome and if there is a solid solution then this can
maybe be published/documented for others and maybe even included in
galileo setup somehow. Something I was missing is a log file
/var/log/galileo where I could check (just entries like service
started,
stopped, synchronized device XXX successfully, sync skipped, ...)
If I remember correctly the steps I took were:
make a file 'galileo' in /etc/init.d/ (attached down below)
sudo chown root: galileo
chmod +x galileo
sudo systemctl daemon-reload
manual testing with:
sudo ./galileo stop
sudo ./galileo start
sudo ./galileo status
htop
sudo update-rc.d galileo defaults (to register the service for good)
my 'galileo' file in /etc/init.d/:
#!/bin/sh
### BEGIN INIT INFO
# Provides: galileo
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Synchronization of fitbit devices (galileo
daemon)
# Description: Run the galileo daemon which provides background
synchronization service for fitbit devices
### END INIT INFO
# Change the next 3 lines to suit where you install your script
and what
you want to call it
DIR=/usr/local/bin
DAEMON=$DIR/galileo
DAEMON_NAME=galileo
# Add any command line options for your daemon here
DAEMON_OPTS="--syslog --no-dump --daemon-period 60000 daemon"
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the
Raspberry Pi GPIO from Python.
DAEMON_USER=admin
# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE
--make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas
$DAEMON -- $DAEMON_OPTS
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
sleep 1
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME
{start|stop|restart|status}"
exit 1
;;
esac
exit 0