mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-31 18:30:31 +02:00
Update ha_lsio.sh
This commit is contained in:
@@ -8,6 +8,7 @@ set -e
|
|||||||
|
|
||||||
# Set variable
|
# Set variable
|
||||||
CONFIGLOCATION="$1"
|
CONFIGLOCATION="$1"
|
||||||
|
CONFIGLOCATION="${CONFIGLOCATION:-/config}"
|
||||||
echo "Setting config to $CONFIGLOCATION"
|
echo "Setting config to $CONFIGLOCATION"
|
||||||
|
|
||||||
# Avoid custom-init.d duplications
|
# Avoid custom-init.d duplications
|
||||||
@@ -15,22 +16,27 @@ for file in $(grep -sril 'Potential tampering with custom' /etc/cont-init.d /etc
|
|||||||
rm -f "$file"
|
rm -f "$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# If custom config
|
||||||
|
if [ "$CONFIGLOCATION" != "/config" ]; then
|
||||||
|
|
||||||
# Create new config folder if needed
|
# Create new config folder if needed
|
||||||
for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do
|
for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do
|
||||||
sed -i "1a mkdir -p $CONFIGLOCATION" "$file"
|
sed -i "1a mkdir -p $CONFIGLOCATION" "$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Correct config location
|
||||||
|
for file in $(grep -Esril "/config[ '\"/]|/config\$" /etc /defaults); do
|
||||||
|
sed -Ei "s=(/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Allow UID and GID setting
|
# Allow UID and GID setting
|
||||||
for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do
|
for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do
|
||||||
sed -i 's/bash/bashio/g' "$file" && sed -i '1a PUID="$(if bashio::config.has_value "PUID"; then bashio::config "PUID"; else echo "0"; fi)"' "$file"
|
sed -i 's/bash/bashio/g' "$file" && sed -i '1a PUID="$(if bashio::config.has_value "PUID"; then bashio::config "PUID"; else echo "0"; fi)"' "$file"
|
||||||
sed -i '1a PGID="$(if bashio::config.has_value "PGID"; then bashio::config "PGID"; else echo "0"; fi)"' "$file"
|
sed -i '1a PGID="$(if bashio::config.has_value "PGID"; then bashio::config "PGID"; else echo "0"; fi)"' "$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Correct config location
|
|
||||||
for file in $(grep -Esril "/config[ '\"/]|/config\$" /etc /defaults); do
|
|
||||||
sed -Ei "s=(/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" "$file"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Avoid chmod /config if ha config mounted
|
# Avoid chmod /config if ha config mounted
|
||||||
if [ -f /config/configuration.yaml ] || [ -f /config/configuration.json ]; then
|
if [ -f /config/configuration.yaml ] || [ -f /config/configuration.json ]; then
|
||||||
for file in /etc/services.d/*/* /etc/cont-init.d/* /etc/s6-overlay/s6-rc.d/*/*; do
|
for file in /etc/services.d/*/* /etc/cont-init.d/* /etc/s6-overlay/s6-rc.d/*/*; do
|
||||||
|
|||||||
Reference in New Issue
Block a user