Commit 9948701f authored by Xavier Guimard's avatar Xavier Guimard

Create pid directory at startup (Closes: #969)

parent 5d4877dd
......@@ -484,7 +484,7 @@ install_fastcgi_server:
@chmod +x $(RSBINDIR)/llng-fastcgi-server
@cp -f fastcgi-server/rc/llng-fastcgi-server $(RINITDIR)
@cp -f fastcgi-server/default/llng-fastcgi-server $(RETCDEFAULTDIR)
@$(PERL) -pi -e 's#__SBINDIR__#$(SBINDIR)#;s#__DEFAULTDIR__#$(ETCDEFAULTDIR)#;s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#g' \
@$(PERL) -pi -e 's#__SBINDIR__#$(SBINDIR)#;s#__DEFAULTDIR__#$(ETCDEFAULTDIR)#;s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#g;s#__USER__#$(FASTCGIUSER)#;s#__GROUP__#$(FASTCGIGROUP)#;' \
$(RETCDEFAULTDIR)/llng-fastcgi-server \
$(RSBINDIR)/llng-fastcgi-server \
$(RINITDIR)/llng-fastcgi-server
......
......@@ -35,6 +35,19 @@ if [ -z "$SOCKET" ]; then
SOCKET=/var/run/llng-fastcgi-server/llng-fastcgi.sock
fi
for f in "$PID" "$SOCKET"; do
DIR=`dirname "$f"`
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR"
if [ -n "$USER" ]; then
chown "$USER" "$DIR"
fi
if [ -n "$GROUP" ]; then
chgrp "$GROUP" "$DIR"
fi
fi
done
DAEMON_OPTS="-p ${PID} -u ${USER} -g ${GROUP} -s ${SOCKET}"
if [ -z "$CUSTOM_FUNCTIONS_FILE" ]; then
......
#!/bin/sh
set -e
USER="www-data"
GROUP="www-data"
CHOWN="/bin/chown"
ID="/usr/bin/id"
if ! test -d /var/run/llng-fastcgi-server; then
rm -rf /var/run/llng-fastcgi-server
mkdir /var/run/llng-fastcgi-server
fi
$CHOWN $USER:$GROUP /var/run/llng-fastcgi-server
#DEBHELPER#
exit 0
......@@ -6,6 +6,8 @@ After=network.target
Type=forking
EnvironmentFile=/etc/default/lemonldap-ng-fastcgi-server
PIDFile=/var/run/llng-fastcgi-server/llng-fastcgi-server.pid
ExecStartPre=-/bin/mkdir /var/run/llng-fastcgi-server
ExecStartPre=/bin/chown www-data:www-data /var/run/llng-fastcgi-server
ExecStart=/usr/sbin/llng-fastcgi-server
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile ${PID}
KillMode=mixed
......
......@@ -10,5 +10,5 @@ pre-start script
[ -x /usr/sbin/llng-fastcgi-server ] || { stop; exit 0; }
end script
exec /usr/sbin/llng-fastcgi-server -u www-data -g www-data -s /var/run/llng-fastcgi-server/llng-fastcgi.sock -p /var/run/llng-fastcgi-server/llng-fastcgi-server.pid
exec mkdir /var/run/llng-fastcgi-server; chown www-data:www-data /var/run/llng-fastcgi-server && /usr/sbin/llng-fastcgi-server -u www-data -g www-data -s /var/run/llng-fastcgi-server/llng-fastcgi.sock -p /var/run/llng-fastcgi-server/llng-fastcgi-server.pid
......@@ -35,6 +35,19 @@ if [ -z "$SOCKET" ]; then
SOCKET=__FASTCGISOCKDIR__/llng-fastcgi.sock
fi
for f in "$PID" "$SOCKET"; do
DIR=`dirname "$f"`
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR"
if [ -n "$USER" ]; then
chown "$USER" "$DIR"
fi
if [ -n "$GROUP" ]; then
chgrp "$GROUP" "$DIR"
fi
fi
done
DAEMON_OPTS="-p ${PID} -u ${USER} -g ${GROUP} -s ${SOCKET}"
if [ -z "$CUSTOM_FUNCTIONS_FILE" ]; then
......
......@@ -10,5 +10,5 @@ pre-start script
[ -x /usr/sbin/llng-fastcgi-server ] || { stop; exit 0; }
end script
exec /usr/sbin/llng-fastcgi-server -u www-data -g www-data -s __FASTCGISOCKDIR__/llng-fastcgi.sock -p __FASTCGISOCKDIR__/llng-fastcgi-server.pid
exec mkdir __FASTCGISOCKDIR__; chown __USER__:__GROUP__ __FASTCGISOCKDIR__ && /usr/sbin/llng-fastcgi-server -u __USER__ -g __GROUP__ -s __FASTCGISOCKDIR__/llng-fastcgi.sock -p __FASTCGISOCKDIR__/llng-fastcgi-server.pid
......@@ -6,6 +6,8 @@ After=network.target
Type=forking
EnvironmentFile=/etc/default/llng-fastcgi-server
PIDFile=__FASTCGISOCKDIR__/llng-fastcgi-server.pid
ExecStartPre=-/bin/mkdir __FASTCGISOCKDIR__
ExecStartPre=/bin/chown __USER__:__GROUP__ __FASTCGISOCKDIR__
ExecStart=__SBINDIR__/llng-fastcgi-server
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile ${PID}
KillMode=mixed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment