chmod +x scripts

This commit is contained in:
Alexandre
2022-06-15 20:44:11 +02:00
parent 0047e2489f
commit 3351e5b29c
218 changed files with 0 additions and 9448 deletions

View File

@@ -1,50 +0,0 @@
#!/bin/bash
# If dockerfile failed install manually
##############################
# Automatic modules download #
##############################
if [ -e "/MODULESFILE" ]; then
MODULES=$(</MODULESFILE)
MODULES="${MODULES:-00-banner.sh}"
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 \
&& apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \
&& 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
#######################
# Automatic installer #
#######################
if [ -e "/ENVFILE" ]; then
PACKAGES=$(</ENVFILE)
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
fi
if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then
for scripts in $MODULES; do
echo "$scripts : executing"
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts"
chmod a+x /etc/cont-init.d/"$scripts"
/./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?"
rm /etc/cont-init.d/"$scripts"
done | tac
fi
#######################
# Correct permissions #
#######################
[ -d /etc/services.d ] && chmod -R 777 /etc/services.d
[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d

View File

@@ -1,124 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
rm -rf /etc/cont-init.d/20-config || true
declare CONFIG
#declare incomplete_bool
declare download_dir
declare incomplete_dir
declare USER
declare PASS
declare WHITELIST
#declare HOST_WHITELIST
CONFIGDIR="/config/transmission"
###############
# PERMISSIONS #
###############
#Default folders
echo "Updating folders"
mkdir -p /config/transmission || true
mkdir -p /watch || true
chown -R abc:abc /config/transmission || true
if ! bashio::fs.file_exists "$CONFIGDIR/settings.json"; then
echo "Creating default config"
cp "/defaults/settings.json" "$CONFIGDIR/settings.json"
fi
#################
# CONFIGURATION #
#################
# Alternate UI
##############
if bashio::config.has_value 'customUI'; then
CUSTOMUI=$(bashio::config 'customUI')
[ "$CUSTOMUI" != "standard" ] && sed -i "1a export TRANSMISSION_WEB_HOME=\"/$CUSTOMUI/\"" /etc/services.d/transmission/run
# Enable transmission-web-control return to default UI
if [ ! -f "/transmission-web-control/index.original.html" ]; then
ln -s /usr/share/transmission/web/style /transmission-web-control
ln -s /usr/share/transmission/web/images /transmission-web-control
ln -s /usr/share/transmission/web/javascript /transmission-web-control
ln -s /usr/share/transmission/web/index.html /transmission-web-control/index.original.html
fi
fi
bashio::log.info "UI selected : $CUSTOMUI"
# INCOMPLETE DIR
################
echo "Creating config"
download_dir=$(bashio::config 'download_dir')
incomplete_dir=$(bashio::config 'incomplete_dir')
CONFIG=$(<$CONFIGDIR/settings.json)
# Permissions
echo "Updating permissions"
mkdir -p "$download_dir"
chown abc:abc "$download_dir"
# if incomplete dir > 2, to allow both null and '', set it as existing
if [ ${#incomplete_dir} -ge 2 ]; then
echo "Incomplete dir set: $incomplete_dir"
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=true")
mkdir -p "$incomplete_dir"
chown abc:abc "$incomplete_dir"
else
echo "Incomplete dir disabled"
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=false")
fi
# Defaults
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir\"=\"${incomplete_dir}\"")
CONFIG=$(bashio::jq "${CONFIG}" ".\"download-dir\"=\"${download_dir}\"")
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-host-whitelist-enabled\"=false")
CONFIG=$(bashio::jq "${CONFIG}" ".\"bind-address-ipv4\"=\"0.0.0.0\"")
if bashio::config.has_value 'watch_dir'; then
CONFIG=$(bashio::jq "${CONFIG}" ".\"watch-dir\"=\"$(bashio::config 'watch_dir')\"")
fi
echo "${CONFIG}" >"$CONFIGDIR"/settings.json &&
jq . -S "$CONFIGDIR"/settings.json | cat >temp.json && mv temp.json $CONFIGDIR/settings.json
# USER and PASS
###############
CONFIG=$(<"$CONFIGDIR"/settings.json)
USER=$(bashio::config 'user')
PASS=$(bashio::config 'pass')
if bashio::config.has_value 'user'; then
BOOLEAN=true
bashio::log.info "User & Pass set, authentification will be with user : $USER and pass : $PASS"
else
BOOLEAN=false
bashio::log.warning "User & Pass not set, no authentification required"
fi
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-authentication-required\"=${BOOLEAN}")
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-username\"=\"${USER}\"")
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-password\"=\"${PASS}\"")
echo "${CONFIG}" >"$CONFIGDIR"/settings.json &&
jq . -S "$CONFIGDIR"/settings.json | cat >temp.json && mv temp.json "$CONFIGDIR"/settings.json
# WHITELIST
###########
CONFIG=$(<"$CONFIGDIR"/settings.json)
WHITELIST=$(bashio::config 'whitelist')
if bashio::config.has_value 'whitelist'; then
BOOLEAN=true
bashio::log.info "Whitelist set, no authentification from IP $WHITELIST"
else
BOOLEAN=false
sed -i "2 i\"rpc-whitelist-enabled\": false," "$CONFIGDIR"/settings.json
fi
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist-enabled\"=${BOOLEAN}")
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist\"=\"$WHITELIST\"")
echo "${CONFIG}" >"$CONFIGDIR"/settings.json &&
jq . -S "$CONFIGDIR"/settings.json | cat >temp.json && mv temp.json "$CONFIGDIR"/settings.json

View File

@@ -1,54 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
JSONTOCHECK='/config/transmission/settings.json'
JSONSOURCE='/defaults/settings.json'
# If json already exists
if [ -f "${JSONTOCHECK}" ]; then
# Variables
echo "Checking settings.json format"
# Check if json file valid or not
jq . -S "${JSONTOCHECK}" &>/dev/null && ERROR=false || ERROR=true
if [ $ERROR = true ]; then
bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch. Your old file is renamed as settings.json_old"
mv "${JSONSOURCE}" "${JSONSOURCE}"_old
cp "${JSONSOURCE}" "${JSONTOCHECK}"
exit 0
fi
# Get the default keys from the original file
mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}")
# Check if all keys are still there, or add them
# shellcheck disable=SC2086
for KEYS in "${arr[@]}"; do
# Check if key exists
KEYSTHERE=$(jq "has(\"${KEYS}\")" "${JSONTOCHECK}")
if [ "$KEYSTHERE" != "true" ]; then
#Fetch initial value
JSONSOURCEVALUE=$(jq -r ".\"$KEYS\"" "${JSONSOURCE}")
#Add key
sed -i "3 i\"${KEYS}\": \"${JSONSOURCEVALUE}\"," "${JSONTOCHECK}"
# Message
bashio::log.warning "${KEYS} was missing from your settings.json, it was added with the default value ${JSONSOURCEVALUE}"
fi
done
# Show structure in a nice way
jq . -S "${JSONTOCHECK}" | cat >temp.json && mv temp.json "${JSONTOCHECK}"
# Message
bashio::log.info "Your settings.json was checked and seems perfectly normal!"
fi
# Repair structure
################
#jq . -S $CONFIGDIR/settings.json | cat >temp.json && mv temp.json $CONFIGDIR/settings.json
#echo "Making sure settings.json structure is good"
#for KEYS in "incomplete-dir" "download-dir" "rpc-host-whitelist-enabled" "rpc-authentication-required" "rpc-username" "rpc-password" "rpc-whitelist-enabled" "rpc-whitelist"; do
# KEYSTHERE=$(jq "has(\"${KEYS}\")" $CONFIGDIR/settings.json)
# [ "$KEYSTHERE" != "true" ] && sed -i "3 i\"${KEYS}\": null," $CONFIGDIR/settings.json && echo "... $KEYS was missing, added"
#done
#jq . -S $CONFIGDIR/settings.json | cat >temp.json && mv temp.json $CONFIGDIR/settings.json

View File

@@ -1,18 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
#################
# NGINX SETTING #
#################
declare ingress_interface
declare ingress_port
ingress_port=$(bashio::addon.ingress_port)
ingress_interface=$(bashio::addon.ip_address)
ingress_entry=$(bashio::addon.ingress_entry)
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/nginx/servers/ingress.conf
# Avoid error message
grep -rnl "PhotoPrism has been updated…" /opt/photoprism | xargs sed -i "s|PhotoPrism has been updated…|Please click cancel|g"