Setting permissions for user node

This commit is contained in:
Alexandre
2025-02-12 22:02:08 +01:00
committed by GitHub
parent 639c1de6a5
commit 7cfa231aae

View File

@@ -16,23 +16,17 @@ if bashio::config.true "RUN_AS_ROOT"; then
ln -sf /config "/root/.signalk" ln -sf /config "/root/.signalk"
ln -sf /usr/lib/node_modules/signalk-server /root/signalk ln -sf /usr/lib/node_modules/signalk-server /root/signalk
fi fi
echo "... creating symlinks and checking permissions"
ln -sf /config "/home/node/.signalk" ln -sf /config "/home/node/.signalk"
chown -R "$USER:$USER" /config chown -R "$USER:$USER" /config
# Option 1 : define permissions for /dev/ttyUSB # Set permissions
for device in /dev/ttyUSB /dev/ttyUSB0 /dev/ttyUSB1; do echo "... setting permissions for node user"
if [ -e "$device" ]; then usermod -o -u 0 node
# Check if 'node' is already in the 'root' group before modifying groupmod -o -g 0 node
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 || true
# Option 2 : set single user for SSL files # Ensure 600 for SSL files
echo "... specifying security files permissions"
for file in ssl-key.pem ssl-cert.pem security.json; do for file in ssl-key.pem ssl-cert.pem security.json; do
if [ -e "/config/$file" ]; then if [ -e "/config/$file" ]; then
chmod 600 "/config/$file" chmod 600 "/config/$file"