mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 18:31:02 +01:00
new logic entrypoint
This commit is contained in:
@@ -8,15 +8,16 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
ARG BUILD_VERSION
|
||||
ARG BUILD_UPSTREAM="2.1.27"
|
||||
ENV BASHIO_VERSION=0.14.3
|
||||
ENV PACKAGES="wget \
|
||||
jq \
|
||||
nginx"
|
||||
|
||||
RUN \
|
||||
#Install bashio
|
||||
apt-get clean \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
wget \
|
||||
jq \
|
||||
nginx \
|
||||
&& apt-get install -y --no-install-recommends ${PACKAGES} \
|
||||
\
|
||||
##################
|
||||
# Install bashio #
|
||||
##################
|
||||
@@ -28,10 +29,11 @@ RUN \
|
||||
--strip 1 -C /tmp/bashio \
|
||||
\
|
||||
&& mv /tmp/bashio/lib /usr/lib/bashio \
|
||||
&& ln -s /usr/lib/bashio/bashio /usr/bin/bashio \
|
||||
\
|
||||
&& ln -s /usr/lib/bashio/bashio /usr/bin/bashio || true
|
||||
|
||||
RUN \
|
||||
#Install Joal
|
||||
&& wget -O /tmp/joal.tar.gz "https://github.com/anthonyraymond/joal/releases/download/$BUILD_UPSTREAM/joal.tar.gz" \
|
||||
wget -O /tmp/joal.tar.gz "https://github.com/anthonyraymond/joal/releases/download/$BUILD_UPSTREAM/joal.tar.gz" \
|
||||
&& mkdir -p /data/joal \
|
||||
&& tar zxvf /tmp/joal.tar.gz -C /data/joal \
|
||||
&& rm /data/joal/jack-of* \
|
||||
@@ -43,11 +45,12 @@ RUN \
|
||||
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
RUN chmod 777 /run.sh
|
||||
|
||||
ENTRYPOINT [ "/run.sh" ]
|
||||
# copy local files
|
||||
COPY rootfs/ /
|
||||
#WORKDIR /
|
||||
RUN chmod 777 /entrypoint.sh
|
||||
ENTRYPOINT [ "/usr/bin/env" ]
|
||||
CMD [ "/entrypoint.sh" ]
|
||||
|
||||
### LABELS
|
||||
ARG BUILD_ARCH
|
||||
|
||||
44
joal/rootfs/entrypoint.sh
Normal file
44
joal/rootfs/entrypoint.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Starting..."
|
||||
|
||||
###################################
|
||||
# Export all addon options as env #
|
||||
###################################
|
||||
|
||||
# For all keys in options.json
|
||||
JSONSOURCE="/data/options.json"
|
||||
|
||||
# Export keys as env variables
|
||||
echo "All addon options were exported as variables"
|
||||
mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE})
|
||||
for KEYS in ${arr[@]}; do
|
||||
# export key
|
||||
VALUE=$(jq .$KEYS ${JSONSOURCE})
|
||||
export ${KEYS}=${VALUE//[\"\']/} &>/dev/null
|
||||
done
|
||||
|
||||
################
|
||||
# Set timezone #
|
||||
################
|
||||
if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then
|
||||
if [ -f /usr/share/zoneinfo/$TZ ]; then
|
||||
echo "Timezone set from $(cat /etc/timezone) to $TZ"
|
||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
|
||||
else
|
||||
echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)"
|
||||
fi
|
||||
fi
|
||||
|
||||
####################
|
||||
# Starting scripts #
|
||||
####################
|
||||
|
||||
for SCRIPTS in scripts/*; do
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
chown $(id -u):$(id -g) $SCRIPTS
|
||||
chmod a+x $SCRIPTS
|
||||
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true
|
||||
./$SCRIPTS || echo "$SCRIPTS: exiting $?"
|
||||
done
|
||||
29
joal/rootfs/scripts/00-aaa_dockerfile_backup.sh
Normal file
29
joal/rootfs/scripts/00-aaa_dockerfile_backup.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# If dockerfile failed install manually
|
||||
if [ ! -f "/usr/bin/bashio" ]; then
|
||||
echo "Bashio does not exist, executing script"
|
||||
(
|
||||
################
|
||||
# Install apps #
|
||||
################
|
||||
PACKAGES="${PACKAGES:="curl"}"
|
||||
|
||||
apt-get clean \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ${PACKAGES} 2>/dev/null \
|
||||
|| apk add --no-cache ${PACKAGES}
|
||||
|
||||
###################
|
||||
# Install bashio #
|
||||
##################
|
||||
|
||||
mkdir -p /tmp/bashio
|
||||
curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" |
|
||||
tar -xzf - --strip 1 -C /tmp/bashio
|
||||
mv /tmp/bashio/lib /usr/lib/bashio
|
||||
ln -s /usr/lib/bashio/bashio /usr/bin/bashio
|
||||
rm -rf /tmp/bashio
|
||||
|
||||
) >/dev/null
|
||||
|
||||
fi
|
||||
39
joal/rootfs/scripts/00-banner.sh
Normal file
39
joal/rootfs/scripts/00-banner.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Displays a simple add-on banner on startup
|
||||
# ==============================================================================
|
||||
|
||||
if bashio::supervisor.ping; then
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
||||
bashio::log.blue " $(bashio::addon.description)"
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
|
||||
bashio::log.blue " Add-on version: $(bashio::addon.version)"
|
||||
if bashio::var.true "$(bashio::addon.update_available)"; then
|
||||
bashio::log.magenta ' There is an update available for this add-on!'
|
||||
bashio::log.magenta \
|
||||
" Latest add-on version: $(bashio::addon.version_latest)"
|
||||
bashio::log.magenta ' Please consider upgrading as soon as possible.'
|
||||
else
|
||||
bashio::log.green ' You are running the latest version of this add-on.'
|
||||
fi
|
||||
|
||||
bashio::log.blue " System: $(bashio::info.operating_system)" \
|
||||
" ($(bashio::info.arch) / $(bashio::info.machine))"
|
||||
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
||||
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
||||
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue \
|
||||
' Please, share the above information when looking for help'
|
||||
bashio::log.blue \
|
||||
' or support in, e.g., GitHub, forums'
|
||||
bashio::log.green \
|
||||
' https://github.com/alexbelgium/hassio-addons'
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
fi
|
||||
@@ -1,44 +1,5 @@
|
||||
#!/usr/bin/env bashio
|
||||
|
||||
##########
|
||||
# BANNER #
|
||||
##########
|
||||
|
||||
if bashio::supervisor.ping; then
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
||||
bashio::log.blue " $(bashio::addon.description)"
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
|
||||
bashio::log.blue " Add-on version: $(bashio::addon.version)"
|
||||
if bashio::var.true "$(bashio::addon.update_available)"; then
|
||||
bashio::log.magenta ' There is an update available for this add-on!'
|
||||
bashio::log.magenta \
|
||||
" Latest add-on version: $(bashio::addon.version_latest)"
|
||||
bashio::log.magenta ' Please consider upgrading as soon as possible.'
|
||||
else
|
||||
bashio::log.green ' You are running the latest version of this add-on.'
|
||||
fi
|
||||
|
||||
bashio::log.blue " System: $(bashio::info.operating_system)" \
|
||||
" ($(bashio::info.arch) / $(bashio::info.machine))"
|
||||
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
||||
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
||||
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue \
|
||||
' Please, share the above information when looking for help'
|
||||
bashio::log.blue \
|
||||
' or support in, e.g., GitHub, forums or the Discord chat.'
|
||||
bashio::log.green \
|
||||
' https://github.com/alexbelgium/hassio-addons'
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
fi
|
||||
|
||||
################
|
||||
# JOAL SETTING #
|
||||
################
|
||||
Reference in New Issue
Block a user