mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-17 01:48:16 +01:00
clean
This commit is contained in:
@@ -7,66 +7,6 @@ set -e
|
||||
PUID=$(bashio::config "PUID")
|
||||
PGID=$(bashio::config "PGID")
|
||||
|
||||
# Set user for microsoft edge if available
|
||||
if [ -f /usr/bin/microsoft-edge-real ]; then
|
||||
chown "$PUID:$PGID" /usr/bin/microsoft-edge*
|
||||
chmod +x /usr/bin/microsoft-edge*
|
||||
fi
|
||||
|
||||
# Check data location
|
||||
LOCATION=$(bashio::config 'data_location')
|
||||
|
||||
if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then
|
||||
# Default location
|
||||
LOCATION="/config"
|
||||
else
|
||||
# Check if config is located in an acceptable location
|
||||
LOCATIONOK=""
|
||||
for location in "/share" "/config" "/data" "/mnt"; do
|
||||
if [[ "$LOCATION" == "$location"* ]]; then
|
||||
LOCATIONOK=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$LOCATIONOK" ]; then
|
||||
LOCATION="/config"
|
||||
bashio::log.fatal "Your data_location value can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $LOCATION"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set data location
|
||||
bashio::log.info "Setting data location to $LOCATION"
|
||||
|
||||
# Correct home locations
|
||||
for file in /etc/s6-overlay/s6-rc.d/*/run; do
|
||||
if [ "$(sed -n '1{/bash/p};q' "$file")" ]; then
|
||||
sed -i "1a export HOME=$LOCATION" "$file"
|
||||
sed -i "1a export FM_HOME=$LOCATION" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Correct home location
|
||||
for folders in /defaults /etc/cont-init.d /etc/services.d /etc/s6-overlay/s6-rc.d; do
|
||||
if [ -d "$folders" ]; then
|
||||
sed -i "s|/config|$LOCATION|g" $(find "$folders" -type f) &> /dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
# Change user home
|
||||
sed -i "s|^\(abc:[^:]*:[^:]*:[^:]*:[^:]*:\)[^:]*|\1$LOCATION|" /etc/passwd
|
||||
#usermod --home "$LOCATION" abc || true
|
||||
|
||||
# Add environment variables
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME; fi
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME; fi
|
||||
{
|
||||
printf "%s\n" "export HOME=\"$LOCATION\""
|
||||
printf "%s\n" "export FM_HOME=\"$LOCATION\""
|
||||
} >> ~/.bashrc
|
||||
|
||||
# Create folder
|
||||
echo "Creating $LOCATION"
|
||||
mkdir -p "$LOCATION"
|
||||
|
||||
# Create cache
|
||||
mkdir -p /.cache
|
||||
@@ -79,5 +19,5 @@ ln -sf /config/.cache /.cache
|
||||
|
||||
# Set ownership
|
||||
bashio::log.info "Setting ownership to $PUID:$PGID"
|
||||
chown -R "$PUID":"$PGID" "$LOCATION"
|
||||
chmod -R 700 "$LOCATION"
|
||||
chown -R "$PUID":"$PGID" /config
|
||||
chmod -R 700 /config
|
||||
|
||||
@@ -47,26 +47,3 @@ elif ! bashio::config.has_value 'PASSWORD' && [[ -n "$(bashio::addon.port "3000"
|
||||
bashio::log.warning "You are opening an external port but your password is not defined"
|
||||
bashio::log.warning "You risk being hacked ! Please disable the external ports, or use a password"
|
||||
fi
|
||||
|
||||
# Set password
|
||||
if bashio::config.true 'install_ms_edge'; then
|
||||
bashio::log.info "Adding microsoft edge"
|
||||
# Install edge
|
||||
apt-get update
|
||||
echo "**** install edge ****"
|
||||
apt-get install --no-install-recommends -y ca-certificates
|
||||
if [ -z ${EDGE_VERSION+x} ]; then
|
||||
EDGE_VERSION=$(curl -sL https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/ \
|
||||
| awk -F'(<a href="microsoft-edge-stable_|_amd64.deb\")' '/href=/ {print $2}' | sort --version-sort | tail -1)
|
||||
fi
|
||||
curl -o /tmp/edge.deb -L "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_${EDGE_VERSION}_amd64.deb"
|
||||
dpkg -I /tmp/edge.deb
|
||||
apt-get install --no-install-recommends -y /tmp/edge.deb
|
||||
echo "**** edge docker tweaks ****"
|
||||
if [ -f /usr/bin/microsoft-edge-stable ]; then
|
||||
mv /usr/bin/microsoft-edge-stable /usr/bin/microsoft-edge-real
|
||||
else
|
||||
mv /usr/bin/microsoft-edge /usr/bin/microsoft-edge-real
|
||||
fi
|
||||
mv /helpers/microsoft-edge-stable /usr/bin/
|
||||
fi
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
BIN=/usr/bin/microsoft-edge-real
|
||||
|
||||
# Run normally on privved containers or modified un non priv
|
||||
${BIN} \
|
||||
--password-store=basic \
|
||||
--no-sandbox \
|
||||
--test-type \
|
||||
"$@" >/dev/null 2>&1
|
||||
Reference in New Issue
Block a user