Skip to content

Add‐ons feature : customisation

Alexandre edited this page Dec 30, 2023 · 3 revisions

Auto scripting feature

All add-ons include a feature to execute your own script when it is starting.

The path is described just after the 01-custom_script.sh text in the addon log after starting. You therefore need to create this file (for example using my Filebrowser or Cloudbrowser addons) with the code that you wish to see executed.

This will execute only once at startup (for example you can use it to install graphic drivers). If you need repeated runs, you need to use this script to install cron and set a job.

The script will add execution permissions, and convert CRLF to CR by itself so you don't need to.

You can use bashio commands if you keep the default shebang

Examples

Example 1 : create cron job to say "hello" every hours on a Ubuntu-based addon
#!/usr/bin/env bashio
echo "Starting script"
# Installing cron
apt-get update
apt-get install cron -yqq
# Setting cron
echo "echo \"hello\"" > /etc/cron.hourly/hello
chmod 777 /etc/cron.hourly/hello
# Starting cron
service cron start & true
Example 2 : modify script on the fly to add a parameter to the smb mount
#!/bin/bash
echo "Starting script"
sed -i "3a export WHOOGLE_URL_PREFIX=\'$(bashio::addon.ingress_entry)\'" /etc/cont-init.d/99-run.sh

if ! grep -q "iocharset=utf8,rw" /etc/cont-init.d/92-smb_mounts.sh; then
  echo "File needs modification"
  sed -i "s|cifs -o \"rw,|cifs -o \"iocharset=utf8,rw,|g" /etc/cont-init.d/92-smb_mounts.sh
fi
echo "... done"
Example 3 : add graphic drivers on Alpine-based containers
#!/usr/bin/env bashio
apk add --no-cache mesa-dri-vc4 mesa-dri-swrast mesa-gbm xf86-video-fbdev >/dev/null