|
Revision 298, 1.2 kB
(checked in by weasel, 3 years ago)
|
|
Init script for xlogsync
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #! /bin/sh |
|---|
| 2 | |
|---|
| 3 | set -e |
|---|
| 4 | |
|---|
| 5 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
|---|
| 6 | DESC="Postgres xlog syncer" |
|---|
| 7 | NAME=xlogsync |
|---|
| 8 | PIDFILE=/var/run/xlogsync.pid |
|---|
| 9 | DAEMON=/usr/local/bin/xlogsync |
|---|
| 10 | |
|---|
| 11 | # Gracefully exit if the package has been removed. |
|---|
| 12 | test -x $DAEMON || exit 0 |
|---|
| 13 | |
|---|
| 14 | d_start() { |
|---|
| 15 | if start-stop-daemon \ |
|---|
| 16 | --signal 0 \ |
|---|
| 17 | --stop \ |
|---|
| 18 | --quiet \ |
|---|
| 19 | --pidfile $PIDFILE \ |
|---|
| 20 | --user postgres \ |
|---|
| 21 | --group postgres \ |
|---|
| 22 | --name "$NAME"; then |
|---|
| 23 | echo "ABORTED: already running." >&2 |
|---|
| 24 | exit 0; |
|---|
| 25 | fi |
|---|
| 26 | |
|---|
| 27 | env -i PATH=$PATH \ |
|---|
| 28 | start-stop-daemon \ |
|---|
| 29 | --start \ |
|---|
| 30 | --quiet \ |
|---|
| 31 | --pidfile "$PIDFILE" \ |
|---|
| 32 | --background \ |
|---|
| 33 | --make-pidfile \ |
|---|
| 34 | --user postgres \ |
|---|
| 35 | --group postgres \ |
|---|
| 36 | --chuid postgres \ |
|---|
| 37 | --exec "$DAEMON" |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | # |
|---|
| 41 | # Function that stops the daemon/service. |
|---|
| 42 | # |
|---|
| 43 | d_stop() { |
|---|
| 44 | if ! start-stop-daemon --oknodo \ |
|---|
| 45 | --stop \ |
|---|
| 46 | --retry 10 \ |
|---|
| 47 | --quiet \ |
|---|
| 48 | --pidfile $PIDFILE \ |
|---|
| 49 | --user postgres \ |
|---|
| 50 | --group postgres \ |
|---|
| 51 | --name "$NAME"; then |
|---|
| 52 | echo -n "FAILED" >&2 |
|---|
| 53 | fi |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | case "$1" in |
|---|
| 57 | start) |
|---|
| 58 | echo -n "Starting $DESC: $NAME" |
|---|
| 59 | d_start |
|---|
| 60 | echo "." |
|---|
| 61 | ;; |
|---|
| 62 | stop) |
|---|
| 63 | echo -n "Stopping $DESC: $NAME" |
|---|
| 64 | d_stop |
|---|
| 65 | echo "." |
|---|
| 66 | ;; |
|---|
| 67 | restart|force-reload) |
|---|
| 68 | echo -n "Restarting $DESC: $NAME" |
|---|
| 69 | d_stop |
|---|
| 70 | sleep 1 |
|---|
| 71 | d_start |
|---|
| 72 | echo "." |
|---|
| 73 | ;; |
|---|
| 74 | *) |
|---|
| 75 | echo "Usage: $0 {start|stop|restart|force-reload}" >&2 |
|---|
| 76 | exit 1 |
|---|
| 77 | ;; |
|---|
| 78 | esac |
|---|
| 79 | |
|---|
| 80 | exit 0 |
|---|