mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
Beautify bash
This commit is contained in:
@@ -11,10 +11,10 @@ if [ -e "/MODULESFILE" ]; then
|
||||
echo "Executing modules script : $MODULES"
|
||||
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
fi
|
||||
|
||||
#######################
|
||||
@@ -25,9 +25,9 @@ if [ -e "/ENVFILE" ]; then
|
||||
echo "Executing dependency script with custom elements : $PACKAGES"
|
||||
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
fi
|
||||
|
||||
@@ -9,23 +9,23 @@ PGID=$(bashio::config "PGID")
|
||||
LOCATION=$(bashio::config 'data_location')
|
||||
|
||||
if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then
|
||||
# Default location
|
||||
LOCATION="/share/webtop_kde"
|
||||
# Default location
|
||||
LOCATION="/share/webtop_kde"
|
||||
else
|
||||
bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually"
|
||||
bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually"
|
||||
|
||||
# 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
|
||||
# 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/addons_config/${HOSTNAME#*-}
|
||||
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
|
||||
if [ -z "$LOCATIONOK" ]; then
|
||||
LOCATION=/config/addons_config/${HOSTNAME#*-}
|
||||
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
|
||||
|
||||
|
||||
@@ -4,49 +4,49 @@
|
||||
|
||||
# Add Edge repositories
|
||||
if bashio::config.true 'edge_repositories'; then
|
||||
bashio::log.info "Changing app repositories to edge"
|
||||
{ echo "https://dl-cdn.alpinelinux.org/alpine/edge/community";
|
||||
echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing";
|
||||
echo "https://dl-cdn.alpinelinux.org/alpine/edge/main"; } > /etc/apk/repositories
|
||||
bashio::log.info "Changing app repositories to edge"
|
||||
{ echo "https://dl-cdn.alpinelinux.org/alpine/edge/community";
|
||||
echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing";
|
||||
echo "https://dl-cdn.alpinelinux.org/alpine/edge/main"; } > /etc/apk/repositories
|
||||
fi
|
||||
|
||||
# Install rpi video drivers
|
||||
if bashio::config.true 'rpi_video_drivers'; then
|
||||
bashio::log.info "Installing Rpi graphic drivers"
|
||||
apk add --no-cache mesa-dri-vc4 mesa-dri-swrast mesa-gbm xf86-video-fbdev >/dev/null && bashio::log.green "... done" ||
|
||||
bashio::log.red "... not successful. Are you on a rpi?"
|
||||
bashio::log.info "Installing Rpi graphic drivers"
|
||||
apk add --no-cache mesa-dri-vc4 mesa-dri-swrast mesa-gbm xf86-video-fbdev >/dev/null && bashio::log.green "... done" ||
|
||||
bashio::log.red "... not successful. Are you on a rpi?"
|
||||
fi
|
||||
|
||||
# Fix mate software center
|
||||
if [ -f /usr/lib/dbus-1.0/dbus-daemon-launch-helper ]; then
|
||||
echo "Allow software center"
|
||||
chmod u+s /usr/lib/dbus-1.0/dbus-daemon-launch-helper
|
||||
service dbus restart
|
||||
echo "Allow software center"
|
||||
chmod u+s /usr/lib/dbus-1.0/dbus-daemon-launch-helper
|
||||
service dbus restart
|
||||
fi
|
||||
|
||||
# Install specific apps
|
||||
if bashio::config.has_value 'additional_apps'; then
|
||||
bashio::log.info "Installing additional apps :"
|
||||
# hadolint ignore=SC2005
|
||||
NEWAPPS=$(bashio::config 'additional_apps')
|
||||
for APP in ${NEWAPPS//,/ }; do
|
||||
bashio::log.green "... $APP"
|
||||
# shellcheck disable=SC2015
|
||||
apk add --no-cache "$APP" >/dev/null || bashio::log.red "... not successful, please check package name"
|
||||
done
|
||||
bashio::log.info "Installing additional apps :"
|
||||
# hadolint ignore=SC2005
|
||||
NEWAPPS=$(bashio::config 'additional_apps')
|
||||
for APP in ${NEWAPPS//,/ }; do
|
||||
bashio::log.green "... $APP"
|
||||
# shellcheck disable=SC2015
|
||||
apk add --no-cache "$APP" >/dev/null || bashio::log.red "... not successful, please check package name"
|
||||
done
|
||||
fi
|
||||
|
||||
# Set keyboard
|
||||
if bashio::config.has_value 'KEYBOARD'; then
|
||||
KEYBOARD=$(bashio::config 'KEYBOARD')
|
||||
bashio::log.info "Setting keyboard to $KEYBOARD"
|
||||
sed -i "1a export KEYBOARD=$KEYBOARD" /etc/services.d/web/run
|
||||
KEYBOARD=$(bashio::config 'KEYBOARD')
|
||||
bashio::log.info "Setting keyboard to $KEYBOARD"
|
||||
sed -i "1a export KEYBOARD=$KEYBOARD" /etc/services.d/web/run
|
||||
fi
|
||||
|
||||
# Set password
|
||||
if bashio::config.has_value 'PASSWORD'; then
|
||||
bashio::log.info "Setting password to the value defined in options"
|
||||
PASSWORD=$(bashio::config 'PASSWORD')
|
||||
passwd -d abc
|
||||
echo -e "$PASSWORD\n$PASSWORD" | passwd abc
|
||||
bashio::log.info "Setting password to the value defined in options"
|
||||
PASSWORD=$(bashio::config 'PASSWORD')
|
||||
passwd -d abc
|
||||
echo -e "$PASSWORD\n$PASSWORD" | passwd abc
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user