mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-02-02 01:47:44 +01:00
Revert + allow RUN_AS
https://github.com/alexbelgium/hassio-addons/issues/1450#issuecomment-2651980887
This commit is contained in:
@@ -49,11 +49,14 @@
|
|||||||
"SYS_ADMIN",
|
"SYS_ADMIN",
|
||||||
"SYS_RAWIO"
|
"SYS_RAWIO"
|
||||||
],
|
],
|
||||||
|
"schema": {
|
||||||
|
"RUN_AS": "str?"
|
||||||
|
},
|
||||||
"slug": "signalk",
|
"slug": "signalk",
|
||||||
"uart": true,
|
"uart": true,
|
||||||
"udev": true,
|
"udev": true,
|
||||||
"url": "https://github.com/alexbelgium/hassio-addons",
|
"url": "https://github.com/alexbelgium/hassio-addons",
|
||||||
"usb": true,
|
"usb": true,
|
||||||
"version": "2.13.1-2",
|
"version": "2.13.1-2_test2",
|
||||||
"webui": "http://[HOST]:[PORT:3000]"
|
"webui": "http://[HOST]:[PORT:3000]"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,43 @@
|
|||||||
set -e
|
set -e
|
||||||
# hadolint ignore=SC2155
|
# hadolint ignore=SC2155
|
||||||
|
|
||||||
# Set configuration directory
|
# Variables
|
||||||
mkdir -p /config/.signalk
|
USER=node
|
||||||
if [ -d "/home/node/.signalk" ]; then
|
if bashio::config_has.value "RUN_AS"; then
|
||||||
if [ -n "$(find /home/node/.signalk -mindepth 1 -print -quit 2>/dev/null)" ]; then
|
USER="$(bashio::config "RUN_AS")"
|
||||||
cp -r /home/node/.signalk/* /config/.signalk/
|
bashio::log.warning "RUN_AS is set, app will run as $USER"
|
||||||
fi
|
|
||||||
rm -rf "/home/node/.signalk"
|
|
||||||
fi
|
fi
|
||||||
ln -sf /config/.signalk "/home/node/.signalk"
|
|
||||||
|
|
||||||
# Set single user for SSL files
|
# Set configuration directory
|
||||||
|
if [ -d "/home/node/.signalk" ]; then
|
||||||
|
rm -r "/home/node/.signalk"
|
||||||
|
fi
|
||||||
|
ln -sf /config "/home/node/.signalk"
|
||||||
|
chown -R "$USER:$USER" /config
|
||||||
|
chown -R "$USER:$USER" "/home/node/.signalk"
|
||||||
|
|
||||||
|
# Option 1 : define permissions for /dev/ttyUSB
|
||||||
|
for device in /dev/ttyUSB /dev/ttyUSB0 /dev/ttyUSB1; do
|
||||||
|
if [ -e "$device" ]; then
|
||||||
|
# Check if 'node' is already in the 'root' group before modifying
|
||||||
|
if ! groups node | grep -q '\broot\b'; then
|
||||||
|
sudo usermod -a -G root node || true
|
||||||
|
echo "User 'node' added to group 'root'."
|
||||||
|
else
|
||||||
|
echo "User 'node' is already in group 'root'."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Option 2 : set single user for SSL files
|
||||||
for file in ssl-key.pem ssl-cert.pem; do
|
for file in ssl-key.pem ssl-cert.pem; do
|
||||||
if [ -e "/config/.signalk/$file" ]; then
|
if [ -e "/config/.signalk/$file" ]; then
|
||||||
chown "$(id -u):$(id -g)" "/config/.signalk/$file"
|
chown "$USER:$USER" "/config/.signalk/$file"
|
||||||
chmod 600 "/config/.signalk/$file"
|
chmod 600 "/config/.signalk/$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
bashio::log.info "Starting application"
|
bashio::log.info "Starting application"
|
||||||
exec /home/node/signalk/startup.sh
|
|
||||||
|
sudo -u "$USER" -s /bin/sh -c "/home/node/signalk/startup.sh"
|
||||||
|
|||||||
Reference in New Issue
Block a user