/etc/init.d/diaspora is in diaspora-common 0.7.3.1+debian2ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | #! /bin/sh
### BEGIN INIT INFO
# Provides: diaspora
# Required-Start: $remote_fs $syslog redis-server
# Required-Stop: $remote_fs $syslog redis-server
# Should-Start: postgresql mysql
# Should-Stop: postgresql mysql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Diaspora application server
# Description: Start / stop the Diaspora app server
### END INIT INFO
# Author: FABIAN Tamas Laszlo <giganetom@gmail.com>
# Updated: Pirate Praveen <praveen@debian.org>
# Read diaspora common variables
. /etc/diaspora/diaspora-common.conf
# Read diaspora environment variables
. ${diaspora_conf}
# PATH should only include /usr/* if it runs after the mountnfs.sh script
# Note: /usr/local/bin for foreman gem
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="Diaspora application server"
NAME=diaspora
DIASPORA_HOME="${diaspora_home}"
STARTSCRIPT="./script/server"
LOGFILE=${diaspora_log_dir}/startscript.log
SCRIPTNAME=$0
USER=diaspora
STARTUP_TIMEOUT=100
. /lib/init/vars.sh
. /lib/lsb/init-functions
if test -d ${DIASPORA_HOME}/vendor/bundle
then
EYE="bundle exec eye"
else
EYE="eye"
fi
# Run commands from DIASPORA_HOME
cd ${DIASPORA_HOME}
check_unicorn() {
pgrep -f "unicorn master"
}
check_sidekiq() {
pgrep -f "sidekiq [0-9\.]* diaspora"
}
check_eye() {
pgrep -f "eye monitoring [a-zA-Z0-9\.]* \[diaspora\]"
}
check_script_server() {
pgrep -f "script/server"
}
do_start()
{
if ! touch $LOGFILE; then
log_failure_msg "Could not touch logfile"
return 2
fi
if ! chown $USER $LOGFILE; then
log_failure_msg "Could not chown logfile"
return 2
fi
if check_unicorn && check_sidekiq; then
log_warning_msg "Diaspora is already running"
return 1
fi
if check_script_server; then
log_warning_msg "Diaspora is starting"
return 1
fi
sudo -u $USER -E -H $STARTSCRIPT >> $LOGFILE 2>&1 &
if [ $? -gt 0 ]
then
log_failure_msg "Could not run start script"
return 2
else
log_success_msg "Starting diaspora server..."
return 0
fi
[ "$VERBOSE" != no ] && log_action_msg "Waiting for Diaspora processes... "
c=0
while ! check_unicorn > /dev/null || ! check_sidekiq > /dev/null; do
if [ $c -gt $STARTUP_TIMEOUT ]; then
log_failure_msg "Timeout waiting for Diaspora processes"
return 2
fi
c=`expr $c + 1`
sleep 1
[ "$VERBOSE" != no ] && echo -n "."
done
[ "$VERBOSE" != no ] && log_action_end_msg 0
}
do_stop()
{
sudo -u $USER -E -H ${EYE} stop diaspora
for i in `check_eye`; do
[ "$VERBOSE" != no ] && log_action_msg "Killing eye with PID $i"
kill -TERM $i
[ "$VERBOSE" != no ] && log_action_end_msg $?
done
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
if ! check_eye
then
log_action_msg "Eye not found, Diaspora is NOT RUNNING"
else
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
fi
;;
status)
log_daemon_msg 'Checking for running Diaspora processes'
if ! check_eye
then
log_action_msg " Eye not found"
if ! check_script_server
then
log_action_msg "Diaspora is DOWN"
else
log_action_msg "Diaspora is STARTING"
fi
else
for i in `check_eye`; do
log_action_msg " Found eye with PID $i"
sudo -u $USER -E -H ${EYE} info diaspora
done
fi
;;
restart|force-reload)
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
if ! check_eye
then
log_action_msg "Eye not found, Diaspora is DOWN"
do_start
else
for i in `check_eye`; do
log_action_msg "Found eye with PID $i"
sudo -u $USER -E -H ${EYE} restart diaspora
done
fi
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
|