Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add init.scripts and systemd #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need an --exclude="system*" too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do u mean ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works either on Systemd and on the old systemV


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