Skip to content

Commit cc0bda9

Browse files
author
David Moravek
committed
improves debian packaging
1 parent 6cc06ce commit cc0bda9

File tree

12 files changed

+268
-6
lines changed

12 files changed

+268
-6
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ pkg
1818

1919
# Debian Files
2020
debian/files
21-
debian/python-beaver*
21+
debian/beaver*
2222

2323
# Sphinx build
2424
doc/_build
2525

2626
# Generated man page
2727
doc/aws_hostname.1
28+
29+
beaver/tests/servers/0.8.2.0/kafka-bin/

conf/beaver.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[beaver]
2+
confd_path: /etc/beaver/conf.d
3+
logstash_version: 1

debian/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
python-beaver (31) stable; urgency=low
1+
beaver (31) stable; urgency=low
22

33
* Initial public debian release
44

debian/conffiles

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/beaver/beaver.conf

debian/control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Source: python-beaver
1+
Source: beaver
22
Section: python
33
Priority: extra
44
Maintainer: Jose Diaz-Gonzalez <email@josediazgonzalez.com>
55
Build-Depends: debhelper (>= 9), python, dh-virtualenv
66
Standards-Version: 3.9.5
77

8-
Package: python-beaver
8+
Package: beaver
99
Architecture: all
1010
Depends: ${python:Depends}, ${misc:Depends}
1111
Homepage: http://github.com/josegonzalez/beaver

debian/dirs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/beaver/conf.d

debian/init.d

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#! /bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: skeleton
4+
# Required-Start: $remote_fs $syslog
5+
# Required-Stop: $remote_fs $syslog
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: Example initscript
9+
# Description: This file should be used to construct scripts to be
10+
# placed in /etc/init.d.
11+
### END INIT INFO
12+
13+
# Author: Foo Bar <foobar@baz.org>
14+
#
15+
# Please remove the "Author" lines above and replace them
16+
# with your own name if you copy and modify this script.
17+
18+
# Do NOT "set -e"
19+
20+
# PATH should only include /usr/* if it runs after the mountnfs.sh script
21+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
22+
DESC="Log forwarding daemon."
23+
NAME=beaver
24+
PIDFILE=/var/run/$NAME.pid
25+
DAEMON=/usr/bin/beaver
26+
# @todo why does beaver need to know where PID is??
27+
DAEMON_ARGS="-c /etc/beaver/beaver.conf -D -P $PIDFILE"
28+
SCRIPTNAME=/etc/init.d/$NAME
29+
30+
# Exit if the package is not installed
31+
[ -x "$DAEMON" ] || exit 0
32+
33+
# Read configuration variable file if it is present
34+
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
35+
36+
# Load the VERBOSE setting and other rcS variables
37+
. /lib/init/vars.sh
38+
39+
# Define LSB log_* functions.
40+
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
41+
# and status_of_proc is working.
42+
. /lib/lsb/init-functions
43+
44+
#
45+
# Function that starts the daemon/service
46+
#
47+
do_start()
48+
{
49+
# Return
50+
# 0 if daemon has been started
51+
# 1 if daemon was already running
52+
# 2 if daemon could not be started
53+
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
54+
|| return 1
55+
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
56+
$DAEMON_ARGS \
57+
|| return 2
58+
# Add code here, if necessary, that waits for the process to be ready
59+
# to handle requests from services started subsequently which depend
60+
# on this one. As a last resort, sleep for some time.
61+
}
62+
63+
#
64+
# Function that stops the daemon/service
65+
#
66+
do_stop()
67+
{
68+
# Return
69+
# 0 if daemon has been stopped
70+
# 1 if daemon was already stopped
71+
# 2 if daemon could not be stopped
72+
# other if a failure occurred
73+
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
74+
RETVAL="$?"
75+
[ "$RETVAL" = 2 ] && return 2
76+
# Wait for children to finish too if this is a daemon that forks
77+
# and if the daemon is only ever run from this initscript.
78+
# If the above conditions are not satisfied then add some other code
79+
# that waits for the process to drop all resources that could be
80+
# needed by services started subsequently. A last resort is to
81+
# sleep for some time.
82+
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
83+
[ "$?" = 2 ] && return 2
84+
# Many daemons don't delete their pidfiles when they exit.
85+
rm -f $PIDFILE
86+
return "$RETVAL"
87+
}
88+
89+
#
90+
# Function that sends a SIGHUP to the daemon/service
91+
#
92+
do_reload() {
93+
#
94+
# If the daemon can reload its configuration without
95+
# restarting (for example, when it is sent a SIGHUP),
96+
# then implement that here.
97+
#
98+
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
99+
return 0
100+
}
101+
102+
case "$1" in
103+
start)
104+
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
105+
do_start
106+
case "$?" in
107+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
108+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
109+
esac
110+
;;
111+
stop)
112+
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
113+
do_stop
114+
case "$?" in
115+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
116+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
117+
esac
118+
;;
119+
status)
120+
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
121+
;;
122+
#reload|force-reload)
123+
#
124+
# If do_reload() is not implemented then leave this commented out
125+
# and leave 'force-reload' as an alias for 'restart'.
126+
#
127+
#log_daemon_msg "Reloading $DESC" "$NAME"
128+
#do_reload
129+
#log_end_msg $?
130+
#;;
131+
restart|force-reload)
132+
#
133+
# If the "reload" option is implemented then remove the
134+
# 'force-reload' alias
135+
#
136+
log_daemon_msg "Restarting $DESC" "$NAME"
137+
do_stop
138+
case "$?" in
139+
0|1)
140+
do_start
141+
case "$?" in
142+
0) log_end_msg 0 ;;
143+
1) log_end_msg 1 ;; # Old process is still running
144+
*) log_end_msg 1 ;; # Failed to start
145+
esac
146+
;;
147+
*)
148+
# Failed to stop
149+
log_end_msg 1
150+
;;
151+
esac
152+
;;
153+
*)
154+
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
155+
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
156+
exit 3
157+
;;
158+
esac
159+
160+
:

debian/install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
conf/beaver.conf etc/beaver

debian/links

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/usr/share/python/python-beaver/bin/beaver /usr/bin/beaver
1+
/usr/share/beaver/bin/beaver /usr/bin/beaver

debian/postinst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
dh_installdeb will replace this with shell code automatically
2+
#!/bin/sh
3+
# postinst script for mypackage
4+
#
5+
# see: dh_installdeb(1)
6+
7+
set -e
8+
9+
# summary of how this script can be called:
10+
# * <postinst> `configure' <most-recently-configured-version>
11+
# * <old-postinst> `abort-upgrade' <new version>
12+
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
13+
# <new-version>
14+
# * <postinst> `abort-remove'
15+
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
16+
# <failed-install-package> <version> `removing'
17+
# <conflicting-package> <version>
18+
# for details, see http://www.debian.org/doc/debian-policy/ or
19+
# the debian-policy package
20+
21+
22+
case "$1" in
23+
configure)
24+
if ! id beaver > /dev/null 2>&1 ; then
25+
echo -n "Creating 'beaver' user..."
26+
useradd --home /usr/share/beaver \
27+
--no-create-home \
28+
--shell /bin/false \
29+
beaver
30+
echo " OK"
31+
fi
32+
chown -R beaver:beaver /usr/share/beaver
33+
;;
34+
35+
abort-upgrade|abort-remove|abort-deconfigure)
36+
;;
37+
38+
*)
39+
echo "postinst called with unknown argument \`$1'" >&2
40+
exit 1
41+
;;
42+
esac
43+
44+
# dh_installdeb will replace this with shell code automatically
45+
# generated by other debhelper scripts.
46+
47+
48+
49+
#DEBHELPER#
50+
51+
exit 0

0 commit comments

Comments
 (0)