Update Shellhttpd

The previous section, Dynamic Configuration File, shows how to send configuration files using Fioctl®. You also saw where the file is located on the device: /var/run/secrets/shellhttpd.conf

However, shellhttpd is not yet using this file.

You will learn how to modify docker-compose.yml so that the app uses the host machine’s /var/run/secrets/shellhttpd.conf.

Start by removing shellhttpd.conf from the Dockerfile to simplify your app:

gedit shellhttpd/Dockerfile
Copy to clipboard
FROM alpine

COPY httpd.sh /usr/local/bin/

CMD ["/usr/local/bin/httpd.sh"]
Copy to clipboard

Edit docker-compose.yml and change the volumes stanza to share the /var/run/secrets folder.

gedit shellhttpd/docker-compose.yml
Copy to clipboard
version: '3.2'

services:
  httpd:
    image: hub.foundries.io/<factory>/shellhttpd:latest
#    image: shellhttpd:1.0
    restart: always
    volumes:
      - /var/run/secrets:/home/shellhttpd/
    ports:
      - 8080:${PORT-8080}
    environment:
      MSG: "${MSG-Hello world}"
Copy to clipboard

Check your changes, add, commit, and push:

git status
git add shellhttpd/Dockerfile
git add shellhttpd/docker-compose.yml
git commit -m "Updating shared folder path"
git push
Copy to clipboard

Make sure you received your update by checking the latest Target on the Devices tab in your Factory.

Once you receive the update, the Docker log will show the new message configured with Fioctl in the previous section:

docker logs -f shellhttpd_httpd_1
Copy to clipboard
PORT=8080
MSG=Hello from fioctl
Copy to clipboard

If you test the app with curl, it will also display the new message:

curl <device IP>:8080
Copy to clipboard
Hello from fioctl
Copy to clipboard

Repeat the fioctl config command in the previous section to confirm everything is working. Update the configuration file using Fioctl on your host machine:

fioctl devices config set <device-name> shellhttpd.conf="MSG=\"New config file updated over-the-air\""
Copy to clipboard

Wait, then test your app again:

curl <device IP>:8080
Copy to clipboard
New config file updated over-the-air
Copy to clipboard