Skip to content

Commit

Permalink
add init.scripts and systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
p365labs committed Aug 13, 2017
1 parent c7d64ac commit 5beaf63
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
7 changes: 6 additions & 1 deletion build/build-uniqush-push-exp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ echo "building version " $VERSION
BUILD=`pwd`/uniqush-push-$VERSION
mkdir -p $BUILD/usr/bin
mkdir -p $BUILD/etc/uniqush/
mkdir -p $BUILD/systemd/
mkdir -p $BUILD/systemvinit/

ARCH=`uname -m`

cp $TEMP/bin/uniqush-push $BUILD/usr/bin
cp $TEMP/src/github.com/uniqush/uniqush-push/conf/uniqush-push.conf $BUILD/etc/uniqush
cp ../conf/systemd/uniqush-push.service $BUILD/systemd/uniqush-push.service
cp ../conf/systemvinit/uniqush.init $BUILD/systemvinit/uniqush-push
cp $TEMP/src/github.com/uniqush/uniqush-push/LICENSE $LICENSE

fpm -s dir -t rpm -v $VERSION -n uniqush-push --license=$LICENSE --maintainer="Nan Deng" --vendor "uniqush" --url="http://uniqush.org" --category Network --description "Uniqush is a free and open source software which provides a unified push service for server-side notification to apps on mobile devices" -a $ARCH -C $BUILD .

fpm -s dir -t deb -v $VERSION -n uniqush-push --license=$LICENSE --maintainer="Nan Deng" --vendor "uniqush" --url="http://uniqush.org" --category Network --description "Uniqush is a free and open source software which provides a unified push service for server-side notification to apps on mobile devices" -a $ARCH -C $BUILD .
fpm -s dir -t deb -v $VERSION -n uniqush-push --license=$LICENSE --maintainer="Nan Deng" --vendor "uniqush" --url="http://uniqush.org" --deb-systemd="$BUILD/systemd/uniqush-push.service" --deb-init="$BUILD/systemvinit/uniqush-push" --category Network --description "Uniqush is a free and open source software which provides a unified push service for server-side notification to apps on mobile devices" -a $ARCH -C $BUILD .


TARBALLNAME=uniqush-push_${VERSION}_$ARCH
TARBALLDIR=`pwd`/$TARBALLNAME
Expand Down
6 changes: 5 additions & 1 deletion build/build-uniqush-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ VERSION=`"$TEMP/bin/uniqush-push" --version | sed 's/uniqush-push //'`
BUILD=`pwd`/"uniqush-push-$VERSION"
mkdir -p "$BUILD/usr/bin"
mkdir -p "$BUILD/etc/uniqush/"
mkdir -p "$BUILD/systemd/"
mkdir -p "$BUILD/systemvinit/"

ARCH="`uname -m`"

cp "$TEMP/bin/uniqush-push" "$BUILD/usr/bin"
cp "$TEMP/src/github.com/uniqush/uniqush-push/conf/uniqush-push.conf" "$BUILD/etc/uniqush"
cp "../conf/systemd/uniqush-push.service" "$BUILD/systemd/uniqush-push.service"
cp "../conf/systemvinit/uniqush.init" "$BUILD/systemvinit/uniqush-push"
cp "$TEMP/src/github.com/uniqush/uniqush-push/LICENSE" "$LICENSE"

fpm -s dir -t rpm -v "$VERSION" -n uniqush-push --license="$LICENSE" --maintainer="Nan Deng" --vendor "uniqush" --url="http://uniqush.org" --category Network --description "Uniqush is a free and open source software which provides a unified push service for server-side notification to apps on mobile devices" -a "$ARCH" -C "$BUILD" .

fpm -s dir -t deb -v "$VERSION" -n uniqush-push --license="$LICENSE" --maintainer="Nan Deng" --vendor "uniqush" --url="http://uniqush.org" --category Network --description "Uniqush is a free and open source software which provides a unified push service for server-side notification to apps on mobile devices" -a "$ARCH" -C "$BUILD" .
fpm -s dir -t deb -v "$VERSION" -n uniqush-push --license="$LICENSE" --maintainer="Nan Deng" --vendor "uniqush" --url="http://uniqush.org" --deb-systemd="$BUILD/systemd/uniqush-push.service" --deb-init="$BUILD/systemvinit/uniqush-push" --category Network --description "Uniqush is a free and open source software which provides a unified push service for server-side notification to apps on mobile devices" -a "$ARCH" -C "$BUILD" .

TARBALLNAME="uniqush-push_${VERSION}_$ARCH"
TARBALLDIR=`pwd`/"$TARBALLNAME"
Expand Down
14 changes: 14 additions & 0 deletions conf/systemd/uniqush-push.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=A unified push service for server-side notification to apps on mobile devices.
After=network.target

[Service]
PIDFile=/run/uniqush-push.pid
ExecStart=/usr/bin/uniqush-push -config=/etc/uniqush/uniqush-push.conf
ExecReload=/usr/bin/uniqush-push -config=/etc/uniqush/uniqush-push.conf
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/uniqush-push.pid
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target
67 changes: 67 additions & 0 deletions conf/systemvinit/uniqush.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: uniqush-push
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts uniqush-push
# Description: Starts Uniqush provides a unified push service for server-side notification to apps on mobile devices.
### END INIT INFO

DAEMON="/usr/bin/uniqush-push"
CONF_FILE="/etc/uniqush/uniqush-push.conf"
PID=/run/uniqush-push.pid
NAME=uniqush-push
DESC=uniqush-push
SRV_UID=nobody
SRV_GID=nogroup

test -x $DAEMON || exit 0

set -e

. /lib/lsb/init-functions

start() {
start-stop-daemon --start --quiet --pidfile $PID --chuid ${SRV_UID}:${SRV_GID} --user $SRV_UID --group $SRV_GID \
--retry 5 --exec $DAEMON --oknodo --make-pidfile --background -- -config="$CONF_FILE"
}

stop() {
start-stop-daemon --stop --quiet --pidfile $PID \
--retry 5 --oknodo --exec $DAEMON
}

case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start
log_end_msg $?
;;

stop)
log_daemon_msg "Stopping $DESC" "$NAME"
stop
log_end_msg $?
;;

restart)
log_daemon_msg "Restarting $DESC" "$NAME"
stop
sleep 1
start
log_end_msg $?
;;

status)
status_of_proc -p $PID "$DAEMON" "$NAME"
;;

*)
echo "Usage: $NAME {start|stop|restart|status}" >&2
exit 1
;;
esac

exit 0

0 comments on commit 5beaf63

Please sign in to comment.