mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 09:51:02 +01:00
fix: auto-fix linting issues
This commit is contained in:
committed by
github-actions[bot]
parent
3539f328fb
commit
f5428e0950
@@ -18,8 +18,8 @@ CONFIGDIR="/config/addons_config/transmission"
|
||||
####################
|
||||
|
||||
if [ -d /config/transmission ]; then
|
||||
cp -r /config/transmission /config/addons_config/transmission
|
||||
rm -r /config/transmission
|
||||
cp -r /config/transmission /config/addons_config/transmission
|
||||
rm -r /config/transmission
|
||||
fi
|
||||
|
||||
###############
|
||||
@@ -33,8 +33,8 @@ mkdir -p /watch || true
|
||||
chown -R "$PUID:$PGID" "$CONFIGDIR"
|
||||
|
||||
if ! bashio::fs.file_exists "$CONFIGDIR/settings.json"; then
|
||||
echo "Creating default config"
|
||||
cp "/defaults/settings.json" "$CONFIGDIR/settings.json"
|
||||
echo "Creating default config"
|
||||
cp "/defaults/settings.json" "$CONFIGDIR/settings.json"
|
||||
fi
|
||||
|
||||
#################
|
||||
@@ -45,7 +45,7 @@ fi
|
||||
##############
|
||||
|
||||
if bashio::config.has_value 'customUI'; then
|
||||
CUSTOMUI=$(bashio::config 'customUI')
|
||||
CUSTOMUI=$(bashio::config 'customUI')
|
||||
|
||||
fi
|
||||
bashio::log.info "UI selected : $CUSTOMUI"
|
||||
@@ -57,7 +57,7 @@ bashio::log.warning "If UI was changed, you need to clear browser cache for it t
|
||||
echo "Creating config"
|
||||
download_dir=$(bashio::config 'download_dir')
|
||||
incomplete_dir=$(bashio::config 'incomplete_dir')
|
||||
CONFIG=$(<$CONFIGDIR/settings.json)
|
||||
CONFIG=$(< $CONFIGDIR/settings.json)
|
||||
|
||||
# Permissions
|
||||
echo "Updating permissions"
|
||||
@@ -66,13 +66,13 @@ chown "$PUID:$PGID" "$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 "$PUID:$PGID" "$incomplete_dir"
|
||||
echo "Incomplete dir set: $incomplete_dir"
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=true")
|
||||
mkdir -p "$incomplete_dir"
|
||||
chown "$PUID:$PGID" "$incomplete_dir"
|
||||
else
|
||||
echo "Incomplete dir disabled"
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=false")
|
||||
echo "Incomplete dir disabled"
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=false")
|
||||
fi
|
||||
|
||||
# Defaults
|
||||
@@ -82,44 +82,44 @@ 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')\"")
|
||||
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
|
||||
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)
|
||||
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"
|
||||
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"
|
||||
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
|
||||
echo "${CONFIG}" > "$CONFIGDIR"/settings.json \
|
||||
&& jq . -S "$CONFIGDIR"/settings.json | cat > temp.json && mv temp.json "$CONFIGDIR"/settings.json
|
||||
|
||||
# WHITELIST
|
||||
###########
|
||||
|
||||
CONFIG=$(<"$CONFIGDIR"/settings.json)
|
||||
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"
|
||||
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
|
||||
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
|
||||
echo "${CONFIG}" > "$CONFIGDIR"/settings.json \
|
||||
&& jq . -S "$CONFIGDIR"/settings.json | cat > temp.json && mv temp.json "$CONFIGDIR"/settings.json
|
||||
|
||||
@@ -7,41 +7,41 @@ JSONSOURCE='/defaults/settings.json'
|
||||
|
||||
# If json already exists
|
||||
if [ -f "${JSONTOCHECK}" ]; then
|
||||
# Variables
|
||||
echo "Checking settings.json format"
|
||||
# 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
|
||||
# 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}")
|
||||
# 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
|
||||
# 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}"
|
||||
# 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!"
|
||||
# Message
|
||||
bashio::log.info "Your settings.json was checked and seems perfectly normal!"
|
||||
fi
|
||||
|
||||
# Repair structure
|
||||
|
||||
@@ -10,67 +10,67 @@ CUSTOMUI=$(bashio::config 'customUI')
|
||||
|
||||
# Install webui
|
||||
if bashio::config.has_value 'customUI' && [ ! "$CUSTOMUI" = default ] && [ ! "$CUSTOMUI" = custom ]; then
|
||||
# Variables
|
||||
bashio::log.info "Alternate UI enabled : $CUSTOMUI. If webui don't work, disable this option"
|
||||
# Variables
|
||||
bashio::log.info "Alternate UI enabled : $CUSTOMUI. If webui don't work, disable this option"
|
||||
|
||||
# Clean folders
|
||||
if [ -d /"$CUSTOMUI" ]; then rm -r /"${CUSTOMUI:?}"; fi
|
||||
if [ -f /"$CUSTOMUI" ]; then rm -r /"${CUSTOMUI:?}"; fi
|
||||
# Clean folders
|
||||
if [ -d /"$CUSTOMUI" ]; then rm -r /"${CUSTOMUI:?}"; fi
|
||||
if [ -f /"$CUSTOMUI" ]; then rm -r /"${CUSTOMUI:?}"; fi
|
||||
|
||||
### Download WebUI
|
||||
case $CUSTOMUI in
|
||||
"combustion-release")
|
||||
curl -o /tmp/combustion.zip -L "https://github.com/Secretmapper/combustion/archive/release.zip"
|
||||
unzip /tmp/combustion.zip -d /
|
||||
;;
|
||||
### Download WebUI
|
||||
case $CUSTOMUI in
|
||||
"combustion-release")
|
||||
curl -o /tmp/combustion.zip -L "https://github.com/Secretmapper/combustion/archive/release.zip"
|
||||
unzip /tmp/combustion.zip -d /
|
||||
;;
|
||||
|
||||
"transmission-web-control")
|
||||
### Install WebUI
|
||||
mkdir -p /transmission-web-control
|
||||
curl -sL "$(curl -s https://api.github.com/repos/ronggang/transmission-web-control/releases/latest | jq --raw-output '.tarball_url')" | tar -C /transmission-web-control/ --strip-components=2 -xz
|
||||
# Enables the original UI button in transmission-web-control
|
||||
ln -s /usr/share/transmission/public_html/* /transmission-web-control/ 2>/dev/null || true
|
||||
ln -s /usr/share/transmission/public_html/index.html /transmission-web-control/index.original.html
|
||||
;;
|
||||
"transmission-web-control")
|
||||
### Install WebUI
|
||||
mkdir -p /transmission-web-control
|
||||
curl -sL "$(curl -s https://api.github.com/repos/ronggang/transmission-web-control/releases/latest | jq --raw-output '.tarball_url')" | tar -C /transmission-web-control/ --strip-components=2 -xz
|
||||
# Enables the original UI button in transmission-web-control
|
||||
ln -s /usr/share/transmission/public_html/* /transmission-web-control/ 2> /dev/null || true
|
||||
ln -s /usr/share/transmission/public_html/index.html /transmission-web-control/index.original.html
|
||||
;;
|
||||
|
||||
"kettu")
|
||||
mkdir -p /kettu &&
|
||||
curl -o /tmp/kettu.tar.gz -L "https://github.com/endor/kettu/archive/master.tar.gz"
|
||||
tar xf /tmp/kettu.tar.gz -C /kettu --strip-components=1
|
||||
;;
|
||||
"kettu")
|
||||
mkdir -p /kettu \
|
||||
&& curl -o /tmp/kettu.tar.gz -L "https://github.com/endor/kettu/archive/master.tar.gz"
|
||||
tar xf /tmp/kettu.tar.gz -C /kettu --strip-components=1
|
||||
;;
|
||||
|
||||
"flood-for-transmission")
|
||||
curl -o /tmp/flood-for-transmission.tar.gz -L "https://github.com/johman10/flood-for-transmission/releases/download/latest/flood-for-transmission.tar.gz"
|
||||
tar xf /tmp/flood-for-transmission.tar.gz -C /
|
||||
;;
|
||||
"flood-for-transmission")
|
||||
curl -o /tmp/flood-for-transmission.tar.gz -L "https://github.com/johman10/flood-for-transmission/releases/download/latest/flood-for-transmission.tar.gz"
|
||||
tar xf /tmp/flood-for-transmission.tar.gz -C /
|
||||
;;
|
||||
|
||||
"transmissionic")
|
||||
TRANSMISSIONIC_VERSION=$(curl -s -L "https://api.github.com/repos/6c65726f79/Transmissionic/releases/latest" | jq -r .tag_name)
|
||||
echo "**** grab transmissionic ****" &&
|
||||
if [ -z "${TRANSMISSIONIC_VERSION+x}" ]; then
|
||||
TRANSMISSIONIC_VERSION="$(curl -s "https://api.github.com/repos/6c65726f79/Transmissionic/releases/latest" |
|
||||
jq -rc ".tag_name")"
|
||||
fi &&
|
||||
curl -o \
|
||||
/tmp/transmissionic.zip -L \
|
||||
"https://github.com/6c65726f79/Transmissionic/releases/download/${TRANSMISSIONIC_VERSION}/Transmissionic-webui-${TRANSMISSIONIC_VERSION}.zip" &&
|
||||
unzip \
|
||||
/tmp/transmissionic.zip -d \
|
||||
/themes &&
|
||||
mv /themes/web /transmissionic
|
||||
;;
|
||||
"transmissionic")
|
||||
TRANSMISSIONIC_VERSION=$(curl -s -L "https://api.github.com/repos/6c65726f79/Transmissionic/releases/latest" | jq -r .tag_name)
|
||||
echo "**** grab transmissionic ****" \
|
||||
&& if [ -z "${TRANSMISSIONIC_VERSION+x}" ]; then
|
||||
TRANSMISSIONIC_VERSION="$(curl -s "https://api.github.com/repos/6c65726f79/Transmissionic/releases/latest" \
|
||||
| jq -rc ".tag_name")"
|
||||
fi \
|
||||
&& curl -o \
|
||||
/tmp/transmissionic.zip -L \
|
||||
"https://github.com/6c65726f79/Transmissionic/releases/download/${TRANSMISSIONIC_VERSION}/Transmissionic-webui-${TRANSMISSIONIC_VERSION}.zip" \
|
||||
&& unzip \
|
||||
/tmp/transmissionic.zip -d \
|
||||
/themes \
|
||||
&& mv /themes/web /transmissionic
|
||||
;;
|
||||
|
||||
**)
|
||||
exit 0
|
||||
;;
|
||||
**)
|
||||
exit 0
|
||||
;;
|
||||
|
||||
esac
|
||||
esac
|
||||
|
||||
# Define variable
|
||||
CUSTOMUI="/${CUSTOMUI}"
|
||||
chown -R abc:abc "$CUSTOMUI"
|
||||
if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export TRANSMISSION_WEB_HOME=$CUSTOMUI" /etc/services.d/*/*run* 2>/dev/null; fi
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$CUSTOMUI" >/var/run/s6/container_environment/TRANSMISSION_WEB_HOME; fi
|
||||
printf "%s\n" "TRANSMISSION_WEB_HOME=\"$CUSTOMUI\"" >>~/.bashrc
|
||||
# Define variable
|
||||
CUSTOMUI="/${CUSTOMUI}"
|
||||
chown -R abc:abc "$CUSTOMUI"
|
||||
if cat /etc/services.d/*/*run* &> /dev/null; then sed -i "1a export TRANSMISSION_WEB_HOME=$CUSTOMUI" /etc/services.d/*/*run* 2> /dev/null; fi
|
||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$CUSTOMUI" > /var/run/s6/container_environment/TRANSMISSION_WEB_HOME; fi
|
||||
printf "%s\n" "TRANSMISSION_WEB_HOME=\"$CUSTOMUI\"" >> ~/.bashrc
|
||||
|
||||
fi
|
||||
|
||||
0
transmission/rootfs/etc/services.d/nginx/run
Normal file → Executable file
0
transmission/rootfs/etc/services.d/nginx/run
Normal file → Executable file
Reference in New Issue
Block a user