mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-02-21 11:00:32 +01:00
Disable chown if not root
This commit is contained in:
@@ -11,9 +11,15 @@ for SCRIPTS in /etc/cont-init.d/*; do
|
|||||||
[ -e "$SCRIPTS" ] || continue
|
[ -e "$SCRIPTS" ] || continue
|
||||||
echo "$SCRIPTS: executing"
|
echo "$SCRIPTS: executing"
|
||||||
|
|
||||||
# Ensure permissions
|
# Check if run as root
|
||||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
if test "$(id -u)" == 0 && test "$(id -u)" == 0; then
|
||||||
chmod a+x "$SCRIPTS"
|
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||||
|
chmod a+x "$SCRIPTS"
|
||||||
|
else
|
||||||
|
bashio::log.warning "Script executed with user $(id -u):$(id -g), things can break and chown won't work"
|
||||||
|
# Disable chown in scripts
|
||||||
|
sed -i "s/chown /true # chown /g" "$SCRIPTS"
|
||||||
|
fi
|
||||||
|
|
||||||
# Get current shebang, if not available use another
|
# Get current shebang, if not available use another
|
||||||
currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")"
|
currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")"
|
||||||
|
|||||||
Reference in New Issue
Block a user