Skip to contentSkip to conversation

lighttpd: source default file from startup script

PATCH New Philipp Skadorov 3 participants 8 messages Mar 8, 2017 – Mar 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lighttpd: source default file from startup script

lighttpd server runs cgi application that has no way to get environment variables that are set up for it.

S50lighttpd is changed to source /etc/default/lighttpd file where these environment variables can be set up.

---
 package/lighttpd/S50lighttpd | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/lighttpd/S50lighttpd +8 -2
index 44ac257c1..b3518cd27 100644
@@ -2,15 +2,21 @@
 #
 # Starts lighttpd.
 #
+NAME=lighttpd
+DAEMON=/usr/sbin/$NAME
+PID_FILE="/var/run/$NAME.pid"
+CONF_FILE="/etc/$NAME/$NAME.conf"
+
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
 start() {
 	printf "Starting lighttpd: "
-	start-stop-daemon -S -q -p /var/run/lighttpd.pid --exec /usr/sbin/lighttpd -- -f /etc/lighttpd/lighttpd.conf
+	start-stop-daemon -S -q -p $PID_FILE --exec $DAEMON -- -f $CONF_FILE
 	echo "OK"
 }
 stop() {
 	printf "Stopping lighttpd: "
-	start-stop-daemon -K -q -p /var/run/lighttpd.pid
+	start-stop-daemon -K -q -p $PID_FILE
 	echo "OK"
 }
 restart() {
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 lighttpd: source default file from startup script

Hi Philipp,

Quoted 16 lines · Philipp Skadorov

lighttpd server runs cgi application that has no way to get environment variables that are set up for it.

S50lighttpd is changed to source /etc/default/lighttpd file where these environment variables can be set up.

---
 package/lighttpd/S50lighttpd | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/lighttpd/S50lighttpd +0 -0
index 44ac257c1..b3518cd27 100644

package/lighttpd/S50lighttpd line 8

Quoted 7 lines
package/lighttpd/S50lighttpd +4 -0
@@ -2,15 +2,21 @@
 #
 # Starts lighttpd.
 #
+NAME=lighttpd
+DAEMON=/usr/sbin/$NAME
+PID_FILE="/var/run/$NAME.pid"
+CONF_FILE="/etc/$NAME/$NAME.conf"

Should be

CONF_FILE="/etc/default/$NAME.conf"

to mach the commit log text.

Quoted 6 lines
package/lighttpd/S50lighttpd +2 -1
+
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
 start() {
 	printf "Starting lighttpd: "
-	start-stop-daemon -S -q -p /var/run/lighttpd.pid --exec /usr/sbin/lighttpd -- -f /etc/lighttpd/lighttpd.conf

package/lighttpd/S50lighttpd line 22

Quoted 10 lines
package/lighttpd/S50lighttpd +2 -1
+	start-stop-daemon -S -q -p $PID_FILE --exec $DAEMON -- -f $CONF_FILE
 	echo "OK"
 }
 stop() {
 	printf "Stopping lighttpd: "
-	start-stop-daemon -K -q -p /var/run/lighttpd.pid
+	start-stop-daemon -K -q -p $PID_FILE
 	echo "OK"
 }
 restart() {

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 lighttpd: source default file from startup script

Hi Baruch,

----- Original Message -----

Quoted 35 lines

From: "Baruch Siach" <[email protected]>
To: "Philipp Skadorov" <[email protected]>
Cc: buildroot at buildroot.org
Sent: Wednesday, March 8, 2017 12:34:20 PM
Subject: Re: [Buildroot] [PATCH 1/1] lighttpd: source default file from startup script

Hi Philipp,

Quoted 16 lines · Philipp Skadorov

lighttpd server runs cgi application that has no way to get environment variables that are set up for it.

S50lighttpd is changed to source /etc/default/lighttpd file where these environment variables can be set up.

---
 package/lighttpd/S50lighttpd | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/lighttpd/S50lighttpd +0 -0
index 44ac257c1..b3518cd27 100644

package/lighttpd/S50lighttpd line 8

Quoted 7 lines
package/lighttpd/S50lighttpd +4 -0
@@ -2,15 +2,21 @@
 #
 # Starts lighttpd.
 #
+NAME=lighttpd
+DAEMON=/usr/sbin/$NAME
+PID_FILE="/var/run/$NAME.pid"
+CONF_FILE="/etc/$NAME/$NAME.conf"

Should be

Quoted 4 lines

CONF_FILE="/etc/default/$NAME.conf"

to mach the commit log text.

You are referring to the package original config file, /etc/lighttpd/lighttpd.conf. It has gone nowhere from /etc/lighttpd dir.

Before the daemon is run with it, the new file /etc/default/lighttpd is sourced (if present) to set up the custom environment.

Regards,
Philipp

Quoted 24 lines
Quoted 7 lines
package/lighttpd/S50lighttpd +2 -2
+
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
 start() {
 	printf "Starting lighttpd: "
-	start-stop-daemon -S -q -p /var/run/lighttpd.pid --exec /usr/sbin/lighttpd --
-f /etc/lighttpd/lighttpd.conf

package/lighttpd/S50lighttpd line 22

Quoted 10 lines
package/lighttpd/S50lighttpd +2 -1
+	start-stop-daemon -S -q -p $PID_FILE --exec $DAEMON -- -f $CONF_FILE
 	echo "OK"
 }
 stop() {
 	printf "Stopping lighttpd: "
-	start-stop-daemon -K -q -p /var/run/lighttpd.pid
+	start-stop-daemon -K -q -p $PID_FILE
 	echo "OK"
 }
 restart() {

baruch

--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

#3 lore raw

PATCH 1/1 lighttpd: source default file from startup script

Hi Philipp,

Quoted 11 lines · Philipp Skadorov

----- Original Message -----

Quoted 10 lines · Philipp Skadorov

package/lighttpd/S50lighttpd line 8

Quoted 4 lines
package/lighttpd/S50lighttpd +4 -0
+NAME=lighttpd
+DAEMON=/usr/sbin/$NAME
+PID_FILE="/var/run/$NAME.pid"
+CONF_FILE="/etc/$NAME/$NAME.conf"

Should be

CONF_FILE="/etc/default/$NAME.conf"

Quoted 7 lines
Quoted 1 line

to mach the commit log text.

You are referring to the package original config file, /etc/lighttpd/lighttpd.conf. It has gone nowhere from /etc/lighttpd dir.

Before the daemon is run with it, the new file /etc/default/lighttpd is sourced (if present) to set up the custom environment.

You are right, of course. I mixed it up. Sorry for the noise.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#4 lore raw

PATCH 1/1 lighttpd: source default file from startup script

In reply to Philipp Skadorov

Hello,

Quoted 7 lines · Philipp Skadorov

lighttpd server runs cgi application that has no way to get environment variables that are set up for it.

S50lighttpd is changed to source /etc/default/lighttpd file where these environment variables can be set up.

There is a mismatch between the commit log (which only talks about sourcing a default file) and the actual commit which not only sources a default file, but also refactors other aspects of the init script to use variables.

So this should probably be two separate commits, or at the very least be mentioned in the commit log.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#5 lore raw

PATCH v2 1/2 lighttpd: carry common keywords out to variables

S50lighttpd contains repeating keywords that are worth carrying out as
variables: pid file name, daemon name, config file name.

---
 package/lighttpd/S50lighttpd | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/lighttpd/S50lighttpd +6 -2
index 44ac257c1..7a14ec8a9 100644
@@ -2,15 +2,19 @@
 #
 # Starts lighttpd.
 #
+NAME=lighttpd
+DAEMON=/usr/sbin/$NAME
+PID_FILE="/var/run/$NAME.pid"
+CONF_FILE="/etc/$NAME/$NAME.conf"
 
 start() {
 	printf "Starting lighttpd: "
-	start-stop-daemon -S -q -p /var/run/lighttpd.pid --exec /usr/sbin/lighttpd -- -f /etc/lighttpd/lighttpd.conf
+	start-stop-daemon -S -q -p $PID_FILE --exec $DAEMON -- -f $CONF_FILE
 	echo "OK"
 }
 stop() {
 	printf "Stopping lighttpd: "
-	start-stop-daemon -K -q -p /var/run/lighttpd.pid
+	start-stop-daemon -K -q -p $PID_FILE
 	echo "OK"
 }
 restart() {
Signature · 1 line
2.11.0
#6 lore raw

PATCH v2 2/2 lighttpd: source default file from startup script

lighttpd server runs cgi application that has no way to get environment variables that are set up for it.

S50lighttpd is changed to source /etc/default/lighttpd file where these environment variables can be set up.

---
 package/lighttpd/S50lighttpd | 2 ++
 1 file changed, 2 insertions(+)
package/lighttpd/S50lighttpd +2 -0
index 7a14ec8a9..b3518cd27 100644
@@ -7,6 +7,8 @@ DAEMON=/usr/sbin/$NAME
 PID_FILE="/var/run/$NAME.pid"
 CONF_FILE="/etc/$NAME/$NAME.conf"
 
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
 start() {
 	printf "Starting lighttpd: "
 	start-stop-daemon -S -q -p $PID_FILE --exec $DAEMON -- -f $CONF_FILE
Signature · 1 line
2.11.0
#7 lore raw

PATCH v2 1/2 lighttpd: carry common keywords out to variables

In reply to Philipp Skadorov

Hello,

Quoted 7 lines · Philipp Skadorov

S50lighttpd contains repeating keywords that are worth carrying out as
variables: pid file name, daemon name, config file name.

---
 package/lighttpd/S50lighttpd | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Both patches applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com