Skip to content
Snippets Groups Projects
Commit b73e1653 authored by ale's avatar ale
Browse files

add init script for http server

parent 6ec57e17
No related branches found
No related tags found
No related merge requests found
liber (0.1p6) unstable; urgency=medium
* Fixed issues with user input.
* Init script for the HTTP daemon.
-- ale <ale@incal.net> Sat, 07 Feb 2015 09:47:16 +0000
liber (0.1p5) unstable; urgency=low
* Built with updated Bleve and Go.
......
# Uncomment this line to start the HTTP interface daemon.
#ENABLE_SERVER=true
# Set the address (host:port) to listen on.
#ADDR=:4040
# Directory where books are stored.
#BOOK_DIR=/var/lib/liber/books
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: liber
# Required-Start: $remote_fs $time
# Required-Stop: $remote_fs $time
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ebook collection server
# Description: Ebook collection server.
### END INIT INFO
NAME=liber
DESC="Liber"
DAEMON=/usr/bin/liber
PIDFILE=/var/run/liber.pid
ENABLE_SERVER=false
USER=liber
ADDR=:4040
BOOK_DIR=/var/lib/liber/books
DAEMON_OPTS=
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
[ -x "$DAEMON" ] || exit 0
if [ "$ENABLE_SERVER" != "true" ]; then
echo "$NAME disabled, set ENABLE_SERVER=true in /etc/default/$NAME to enable it" >&2
exit 0
fi
. /lib/lsb/init-functions
do_start() {
DAEMON_OPTS="--http-server=$ADDR --book-dir=$BOOK_DIR $DAEMON_OPTS"
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --quiet --background \
--pidfile $PIDFILE --make-pidfile --chuid $USER \
--exec /bin/sh -- -c \
"$DAEMON $DAEMON_OPTS 2>&1 | logger -t liber"
log_end_msg $?
}
do_stop() {
log_daemon_msg "Stopping $DESC" "$NAME"
start_stop_daemon --stop --quiet --oknodo \
--pidfile $PIDFILE --user $USER
log_end_msg $?
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 3
;;
esac
exit 0
#!/bin/sh
case "$1" in
configure)
OLDVERSION="$2"
# see below
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
adduser --quiet --system --home /var/lib/liber --no-create-home --ingroup nogroup liber
for dir in /var/lib/liber /var/lib/liber/books; do
test -d $dir || mkdir $dir
chmod 700 $dir
chown liber:nogroup $dir
done
update-rc.d liber defaults >/dev/null
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment