mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 05:44:03 +02:00
addition of transmission
This commit is contained in:
30
transmission/rootfs/etc/cont-init.d/10-requirements.sh
Normal file
30
transmission/rootfs/etc/cont-init.d/10-requirements.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# This files check if all user configuration requirements are met
|
||||
# ==============================================================================
|
||||
|
||||
# Check authentication requirements, if enabled
|
||||
if bashio::config.true 'authentication_required'; then
|
||||
if ! bashio::config.has_value 'username'; then
|
||||
bashio::exit.nok 'Transmission authentication is enabled, but no username was specified'
|
||||
fi
|
||||
|
||||
if ! bashio::config.has_value 'password'; then
|
||||
bashio::exit.nok 'Transmission authentication is enabled, but no password was specified'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check OpenVPN requirements, if enabled
|
||||
if bashio::config.true 'openvpn_enabled'; then
|
||||
if ! bashio::config.has_value 'openvpn_username'; then
|
||||
bashio::exit.nok 'OpenVPN is enabled, but no username was specified'
|
||||
fi
|
||||
|
||||
if ! bashio::config.has_value 'openvpn_password'; then
|
||||
bashio::exit.nok 'OpenVPN is enabled, but no password was specified'
|
||||
fi
|
||||
|
||||
if ! bashio::fs.file_exists "/config/openvpn/$(bashio::config 'openvpn_config').ovpn"; then
|
||||
bashio::exit.nok "The configured /config/openvpn/$(bashio::config 'openvpn_config').ovpn file is not found"
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
|
||||
declare CONFIG
|
||||
declare authentication_required
|
||||
declare username
|
||||
declare password
|
||||
|
||||
if ! bashio::fs.directory_exists '/data/transmission'; then
|
||||
mkdir '/data/transmission'
|
||||
fi
|
||||
|
||||
if ! bashio::fs.file_exists '/data/transmission/settings.json'; then
|
||||
echo "{}" > /data/transmission/settings.json
|
||||
fi
|
||||
|
||||
CONFIG=$(</data/transmission/settings.json)
|
||||
|
||||
# Defaults
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir\"=\"/share/incomplete\"")
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=true")
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"download-dir\"=\"/share/downloads\"")
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist-enabled\"=false")
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-host-whitelist-enabled\"=false")
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"bind-address-ipv4\"=\"0.0.0.0\"")
|
||||
|
||||
authentication_required=$(bashio::config 'authentication_required')
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-authentication-required\"=${authentication_required}")
|
||||
|
||||
|
||||
username=$(bashio::config 'username')
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-username\"=\"${username}\"")
|
||||
|
||||
|
||||
password=$(bashio::config 'password')
|
||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-password\"=\"${password}\"")
|
||||
|
||||
echo "${CONFIG}" > /data/transmission/settings.json
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
|
||||
declare openvpn_config
|
||||
declare openvpn_username
|
||||
declare openvpn_password
|
||||
|
||||
if bashio::config.true 'openvpn_enabled'; then
|
||||
|
||||
openvpn_config=$(bashio::config 'openvpn_config')
|
||||
|
||||
cp "/config/openvpn/${openvpn_config}.ovpn" /etc/openvpn/config.ovpn
|
||||
|
||||
openvpn_username=$(bashio::config 'openvpn_username')
|
||||
echo "${openvpn_username}" > /etc/openvpn/credentials
|
||||
openvpn_password=$(bashio::config 'openvpn_password')
|
||||
echo "${openvpn_password}" >> /etc/openvpn/credentials
|
||||
|
||||
sed -i 's/auth-user-pass.*/auth-user-pass \/etc\/openvpn\/credentials/g' /etc/openvpn/config.ovpn
|
||||
|
||||
sed -i "1a\/etc/openvpn/up-transmission.sh \"\${4}\" &\n" /etc/openvpn/up.sh
|
||||
|
||||
fi
|
||||
29
transmission/rootfs/etc/cont-init.d/30-nginx.sh
Normal file
29
transmission/rootfs/etc/cont-init.d/30-nginx.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
declare port
|
||||
declare certfile
|
||||
declare ingress_interface
|
||||
declare ingress_port
|
||||
declare keyfile
|
||||
|
||||
port=$(bashio::addon.port 80)
|
||||
if bashio::var.has_value "${port}"; then
|
||||
bashio::config.require.ssl
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
|
||||
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
||||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf
|
||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf
|
||||
|
||||
else
|
||||
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
ingress_port=$(bashio::addon.ingress_port)
|
||||
ingress_interface=$(bashio::addon.ip_address)
|
||||
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|
||||
21
transmission/rootfs/etc/cont-init.d/50-mounts.sh
Normal file
21
transmission/rootfs/etc/cont-init.d/50-mounts.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
bashio::log.info 'Mounting external hdd...'
|
||||
|
||||
# Mount local Share if configured and if Protection Mode is active
|
||||
if bashio::config.has_value 'localdisks'; then
|
||||
MOREDISKS=$(bashio::config 'localdisks')
|
||||
bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && \
|
||||
for disk in $MOREDISKS
|
||||
do
|
||||
bashio::log.info "Mount ${disk}"
|
||||
mkdir -p /share/$disk && \
|
||||
if [ ! -d /share/$disk ]; then
|
||||
echo "Creating /share/$disk"
|
||||
mkdir -p /share/$disk
|
||||
chown -R abc:abc /share/$disk
|
||||
fi
|
||||
mount /dev/$disk /share/$disk && \
|
||||
bashio::log.info "Success!"
|
||||
done || \
|
||||
bashio::log.warning "Protection mode is ON. Unable to mount local drives!"
|
||||
fi
|
||||
Reference in New Issue
Block a user