mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-02-04 02:47:45 +01:00
clean
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
bashio::log.info "Creating folders"
|
||||
|
||||
mkdir -p \
|
||||
/data/cache \
|
||||
/data/chrome \
|
||||
/config/meili \
|
||||
/usr/src/chrome/extensions
|
||||
|
||||
if id chrome &>/dev/null; then
|
||||
chown -R chrome:chrome /data/cache /data/chrome /usr/src/chrome/extensions
|
||||
fi
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
generate_secret() {
|
||||
# Avoid SIGPIPE from `tr` when `head` terminates early under pipefail.
|
||||
(
|
||||
set +o pipefail 2>/dev/null || true
|
||||
tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 64
|
||||
)
|
||||
}
|
||||
|
||||
set_option() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
|
||||
# Store permanently in Home Assistant add-on options
|
||||
bashio::addon.option "${key}" "${value}"
|
||||
|
||||
# Export into current process
|
||||
export "${key}=${value}"
|
||||
|
||||
# Export into s6 so all services inherit it
|
||||
if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "${value}" > "/var/run/s6/container_environment/${key}"
|
||||
fi
|
||||
}
|
||||
|
||||
load_option() {
|
||||
local key="$1"
|
||||
local value
|
||||
|
||||
value="$(bashio::config "${key}")"
|
||||
export "${key}=${value}"
|
||||
|
||||
if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "${value}" > "/var/run/s6/container_environment/${key}"
|
||||
fi
|
||||
}
|
||||
|
||||
for key in MEILI_MASTER_KEY NEXTAUTH_SECRET; do
|
||||
if bashio::config.has_value "${key}"; then
|
||||
bashio::log.info "Using existing ${key}"
|
||||
load_option "${key}"
|
||||
else
|
||||
bashio::log.warning "${key} not set, generating persistent secret"
|
||||
value="$(generate_secret)"
|
||||
set_option "${key}" "${value}"
|
||||
fi
|
||||
done
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
EXTENSIONS_DIR="${CHROME_EXTENSIONS_DIR:-/usr/src/chrome/extensions}"
|
||||
bashio::log.info "Refreshing Chromium extensions in ${EXTENSIONS_DIR}"
|
||||
|
||||
mkdir -p "${EXTENSIONS_DIR}"
|
||||
|
||||
download_extension() {
|
||||
local name="$1"
|
||||
local extension_id="$2"
|
||||
local crx_path rc
|
||||
|
||||
crx_path="$(mktemp)"
|
||||
|
||||
if ! curl -fsSL \
|
||||
"https://clients2.google.com/service/update2/crx?response=redirect&prodversion=120.0&acceptformat=crx2,crx3&x=id%3D${extension_id}%26installsource%3Dondemand%26uc" \
|
||||
-o "${crx_path}"; then
|
||||
rm -f "${crx_path}"
|
||||
bashio::log.warning "Failed to download extension ${name}. Continuing without refresh."
|
||||
return 0
|
||||
fi
|
||||
|
||||
rm -rf "${EXTENSIONS_DIR:?}/${name}"
|
||||
mkdir -p "${EXTENSIONS_DIR}/${name}"
|
||||
|
||||
rc=0
|
||||
unzip -q "${crx_path}" -d "${EXTENSIONS_DIR}/${name}" || rc=$?
|
||||
rm -f "${crx_path}"
|
||||
|
||||
# unzip may return 1 even though files extracted (common with CRX zip metadata)
|
||||
if [ "${rc}" -ne 0 ] && [ "${rc}" -ne 1 ]; then
|
||||
bashio::log.warning "Failed to unzip extension ${name} (rc=${rc}). Continuing."
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
download_extension "i-dont-care-about-cookies" "fllaojicojecljbmefodhfapmkghcbnh"
|
||||
download_extension "ublock-origin" "cjpalhdlnbpafiamejdnhcphjbkeiagm"
|
||||
|
||||
if id chrome &>/dev/null; then
|
||||
chown -R chrome:chrome "${EXTENSIONS_DIR}"
|
||||
fi
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
EXTENSIONS_DIR="${CHROME_EXTENSIONS_DIR:-/usr/src/chrome/extensions}"
|
||||
|
||||
extensions=()
|
||||
for extension in "${EXTENSIONS_DIR}/i-dont-care-about-cookies" "${EXTENSIONS_DIR}/ublock-origin"; do
|
||||
if [ -d "$extension" ]; then
|
||||
extensions+=("$extension")
|
||||
fi
|
||||
done
|
||||
|
||||
extension_flag=""
|
||||
if [ ${#extensions[@]} -gt 0 ]; then
|
||||
extension_flag="--load-extension=$(IFS=,; echo "${extensions[*]}")"
|
||||
fi
|
||||
|
||||
cd /usr/src/chrome
|
||||
|
||||
exec su chrome -c "chromium-browser --headless=new --no-sandbox --disable-gpu --disable-dev-shm-usage --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --hide-scrollbars --disable-crash-reporter --no-crash-upload --user-data-dir=/data/chrome ${extension_flag}"
|
||||
@@ -1 +0,0 @@
|
||||
longrun
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
mkdir -p "${MEILI_DIR}"
|
||||
|
||||
exec /bin/meilisearch --db-path "${MEILI_DIR}" --no-analytics --experimental-dumpless-upgrade
|
||||
@@ -1 +0,0 @@
|
||||
longrun
|
||||
Reference in New Issue
Block a user