Modify Shellhttpd

To change the environment values on the fly without restarting the app, you will edit Open a new terminal on your host and find the container folder used previously.

cd containers/

Edit as below:

vi shellhttpd/
#!/bin/sh -e


while true; do
        [ -f /home/shellhttpd/shellhttpd.conf ] && . /home/shellhttpd/shellhttpd.conf
        echo "PORT=$PORT"
        echo "MSG=$MSG"
        RESPONSE="HTTP/1.1 200 OK\r\n\r\n${MSG}\r\n"
        echo -en "$RESPONSE" | nc -w 5 -l -p "${PORT}" || true
        echo "= $(date) ============================="

The first line in the while loop will check for the file /home/shellhttpd/shellhttpd.conf. If it exists, it will load the variables specified in the file. Then, echo will print the values of PORT and MSG. RESPONSE will be redefined with the new MSG value.

Finally, -w 5 configures nc to stop listening every 5 seconds. This allows the script to reload new variables.