2023-02-23 05:44:27 +00:00
#!/bin/bash
2020-12-24 22:25:51 +00:00
CONTAINER = homebridge
2023-02-22 16:49:54 +00:00
# Get DataDir location
DATA_DIR = "/data"
case " $( ubnt-device-info firmware || true ) " in
1*)
2024-05-14 02:34:28 +00:00
DATA_DIR = "/mnt/data"
; ;
2* | 3* | 4*)
DATA_DIR = "/data"
; ;
2023-02-22 16:49:54 +00:00
*)
2024-05-14 02:34:28 +00:00
echo "ERROR: No persistent storage found." 1>& 2
exit 1
; ;
esac
2021-01-30 08:40:55 +00:00
## network configuration and startup:
2023-02-22 16:49:54 +00:00
CNI_PATH = ${ DATA_DIR } /podman/cni
# Check if the directory exists
if [ ! -d " $CNI_PATH " ] ; then
# If it does not exist, create the directory
mkdir -p " $CNI_PATH "
echo " Directory ' $CNI_PATH ' created. "
else
# If it already exists, print a message
echo " Directory ' $CNI_PATH ' already exists. Moving on. "
fi
2021-01-30 08:40:55 +00:00
if [ ! -f " $CNI_PATH " /tuning ] ; then
2023-02-22 16:49:54 +00:00
mkdir -p $CNI_PATH
curl -L https://github.com/containernetworking/plugins/releases/download/v0.9.1/cni-plugins-linux-arm64-v0.9.1.tgz | tar -xz -C $CNI_PATH
2021-01-30 08:40:55 +00:00
fi
mkdir -p /opt/cni
rm -f /opt/cni/bin
ln -s $CNI_PATH /opt/cni/bin
2023-02-22 16:49:54 +00:00
for file in " $CNI_PATH " /*.conflist; do
if [ -f " $file " ] ; then
ln -s " $file " " /etc/cni/net.d/ $( basename " $file " ) "
fi
2021-01-30 08:40:55 +00:00
done
2020-12-24 22:25:51 +00:00
# Starts the homebridge container on boot.
2023-02-22 16:49:54 +00:00
# All configs stored in /data/homebridge
2020-12-24 22:25:51 +00:00
if podman container exists ${ CONTAINER } ; then
podman start ${ CONTAINER }
else
logger -s -t homebridge -p ERROR Container $CONTAINER not found, make sure you set the proper name, you can ignore this error if it is your first time setting it up
fi