Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Have separate init script because build process changes shebang to /b…
Browse files Browse the repository at this point in the history
…in/bash
  • Loading branch information
Stefan Nordhausen committed Dec 30, 2015
1 parent 64c7c8d commit 84709a9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 103 deletions.
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def set_properties(project):
project.get_property('copy_resources_glob').append('setup.cfg')
project.get_property('copy_resources_glob').append('pre-install.sh')
project.get_property('copy_resources_glob').append('post-install.sh')
project.install_file('/etc/init.d/alppaca', 'src/main/scripts/alppacad')
project.install_file('/etc/init.d', 'resources/alppaca')
project.get_property('coverage_exceptions').append('afp_alppaca.util')


Expand Down
92 changes: 1 addition & 91 deletions src/main/python/resources/alppaca
Original file line number Diff line number Diff line change
Expand Up @@ -11,95 +11,5 @@
# Short-Description: Alppaca
# Description: A(mazing)LocalPrefetchProxyforAmazonCredentiAls
### END INIT INFO
#
# Source function library
. /etc/rc.d/init.d/functions

APPLICATION="alppaca"
PROC="${APPLICATION}d"
# LOCKFILE must have the same basename as the init script, otherwise the
# script /etc/rc will be confused, at least on RHEL 6. One symptom is
# that the service is not stopped on reboot.
LOCKFILE="/var/lock/subsys/$(basename $0)"
LOGDIR="/var/log/$APPLICATION"

start() {
local RETVAL=0
local STARTTIMEOUT=${STARTTIMEOUT:=60}
local BINPATH="/usr/bin"

if ! status $PROC > /dev/null 2>&1; then
echo -n $"Starting ${APPLICATION}: "

daemonize -u alppaca -l $LOCKFILE \
-o $LOGDIR/${PROC}_init.log \
-e $LOGDIR/${PROC}_err.log \
-c $BINPATH \
"${BINPATH}"/${PROC}

while [ "$RETVAL" -eq '1' -a "$STARTTIMEOUT" -ge '0' ]; do
sleep 1
STARTTIMEOUT=$(( STARTTIMEOUT - 1 ))
status $PROC > /dev/null 2>&1
RETVAL=$?
done

if [ $RETVAL -eq 0 ]; then
success
else
rm -f $LOCKFILE
failure
fi
echo
fi
return $RETVAL
}

stop() {
echo -n "Shutting down ${APPLICATION}:"
killproc $PROC
RETVAL=$?
rm -f $LOCKFILE
echo
return $RETVAL
}

restart() {
stop
start
}

reload() {
restart
}

force_reload() {
restart
}

case "$1" in
start)
$1
;;
stop)
stop
;;
status)
status $PROC
;;
restart)
$1
;;
reload)
status $PROC > /dev/null 2>&1 || exit 7
$1
;;
force-reload)
force_reload
;;
*)
echo "Usage: <servicename> {start|stop|status|restart|reload|force-reload}"
exit 1
;;
esac
exit $?
alppacad $@
11 changes: 0 additions & 11 deletions src/main/scripts/alppacad
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/usr/bin/env python

### BEGIN INIT INFO
# Provides: alppaca
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Alppaca
# Description: A(mazing)LocalPrefetchProxyforAmazonCredentiAls
### END INIT INFO


import argparse

from succubus import Daemon
Expand Down

0 comments on commit 84709a9

Please sign in to comment.