Skip to content

Commit

Permalink
Merge pull request statsd#295 from mfournier/deb-packaging-fixes
Browse files Browse the repository at this point in the history
Deb packaging fixes
  • Loading branch information
mrtazz committed May 14, 2013
2 parents d16d744 + f3720a4 commit 7278d8b
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
statsd (0.0.3-1) unstable; urgency=low

* avoid running daemon as root
* install docs and examples

-- Marc Fournier <[email protected]> Tue, 14 May 2013 21:22:45 +0200

statsd (0.0.3) unstable; urgency=low

* removed rdio references from init scripts and config
Expand Down
3 changes: 2 additions & 1 deletion debian/dirs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
var/log/statsd
var/log/statsd
var/run/statsd
2 changes: 2 additions & 0 deletions debian/docs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
README.md
docs/
examples/
21 changes: 17 additions & 4 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/bin/sh

if [ "`stat -c %G /var/log/statsd`" != 'nogroup' ]; then
chown root.nogroup /var/log/statsd
chmod 770 /var/log/statsd
fi
set -e

if [ "$1" = configure ]; then

if ! getent passwd _statsd > /dev/null; then
adduser --system --quiet --home /nonexistent --no-create-home \
--shell /bin/false --force-badname --group --gecos "StatsD User" _statsd
fi

if ! dpkg-statoverride --list /var/run/statsd >/dev/null 2>&1; then
dpkg-statoverride --update --add _statsd _statsd 0755 /var/run/statsd
fi

if ! dpkg-statoverride --list /var/log/statsd >/dev/null 2>&1; then
dpkg-statoverride --update --add _statsd _statsd 0755 /var/log/statsd
fi
fi
21 changes: 21 additions & 0 deletions debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -e

if [ "$1" = purge ]; then

update-rc.d statsd remove >/dev/null || true

rm -rf /var/log/statsd /var/run/statsd

if dpkg-statoverride --list /var/log/statsd >/dev/null 2>&1; then
dpkg-statoverride --remove /var/log/statsd
fi

if dpkg-statoverride --list /var/run/statsd >/dev/null 2>&1; then
dpkg-statoverride --remove /var/run/statsd
fi

deluser --system --quiet _statsd || true
delgroup --system --quiet _statsd || true
fi
7 changes: 4 additions & 3 deletions debian/statsd.init
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ fi
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="StatsD"
NAME=statsd
USER=_statsd
DAEMON=$NODE_BIN
DAEMON_ARGS="/usr/share/statsd/stats.js /etc/statsd/localConfig.js 2>&1 >> /var/log/statsd/statsd.log "
PIDFILE=/var/run/$NAME.pid
PIDFILE=/var/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CHDIR="/usr/share/statsd"

Expand All @@ -49,9 +50,9 @@ do_start()
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet -m --pidfile $PIDFILE --startas $DAEMON --background --test > /dev/null \
start-stop-daemon --start --quiet -m --pidfile $PIDFILE --startas $DAEMON --chuid $USER:$USER --background --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet -m --pidfile $PIDFILE --startas $DAEMON --background --chdir $CHDIR -- \
start-stop-daemon --start --quiet -m --pidfile $PIDFILE --startas $DAEMON --chuid $USER:$USER --background --chdir $CHDIR -- \
$DAEMON_ARGS > /dev/null 2> /var/log/$NAME-stderr.log \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
Expand Down
2 changes: 1 addition & 1 deletion debian/statsd.upstart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ stop on shutdown
script
chdir /usr/share/statsd

exec sudo -u nobody /usr/share/statsd/scripts/start
exec sudo -u _statsd /usr/share/statsd/scripts/start
end script

0 comments on commit 7278d8b

Please sign in to comment.