mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-03-11 07:39:48 +01:00
Correct custom script logic https://github.com/alexbelgium/hassio-addons/issues/1141
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
- BREAKING CHANGE FOR CUSTOM VPN : if you are using a custom VPN provider, you must remove OPENVPN_CUSTOM_PROVIDER from your addon option and instead set OPENVPN_PROVIDER to "custom", then reference your ovpn file in your "OPENVPN_CONFIG". For example, if AIRVPN has provided to you an *.ovpn filed named AIRVPN.ovpn, you need to install an addon such as Filebrowser, go in the /config/addons_config/transmission/openvpn folder and put the AIRVPN.ovpn here. Then, in the addon option you need to write "AIRVPN.ovpn" in the "OPENVPN_CONFIG" option
|
||||
- Removed (not used anymore) : "OPENVPN_CUSTOM_PROVIDER", "OPENVPN_CUSTOM_PROVIDER_OVPN_LOCATION", "TRANSMISSION_V3_UPDATE"
|
||||
|
||||
## v5.3.1 (09-12-2023)
|
||||
- Update to latest version from haugene/docker-transmission-openvpn
|
||||
|
||||
@@ -40,9 +40,7 @@ comparison to installing any other Hass.io add-on.
|
||||
|
||||
Options : see https://github.com/haugene/docker-transmission-openvpn for documentation
|
||||
|
||||
TRANSMISSION_V3_UPDATE: updates to v3. Remove and add all torrents due to transmission changes
|
||||
|
||||
For setting a custom openvpn file, you should flag the "OPENVPN_CUSTOM_PROVIDER" field and reference the path of the \*.ovpn file in the "OPENVPN_CUSTOM_PROVIDER_OVPN_LOCATION" field.
|
||||
For setting a custom openvpn file (even if using AIRVPN), you should set OPENVPN_PROVIDER to "custom", then reference your ovpn file in your "OPENVPN_CONFIG". For example, if AIRVPN has provided to you an *.ovpn filed named AIRVPN.ovpn, you need to install an addon such as Filebrowser, go in the /config/addons_config/transmission/openvpn folder and put the AIRVPN.ovpn here. Then, in the addon option you need to write "AIRVPN.ovpn" in the "OPENVPN_CONFIG" option
|
||||
|
||||
Complete transmission options are in /config/addons_config/transmission (make sure addon is stopped before modifying it as Transmission writes its ongoing values when stopping and could erase your changes)
|
||||
|
||||
|
||||
@@ -112,17 +112,14 @@
|
||||
"DNS_server": "str?",
|
||||
"LOCAL_NETWORK": "str",
|
||||
"OPENVPN_CONFIG": "str?",
|
||||
"OPENVPN_CUSTOM_PROVIDER": "bool?",
|
||||
"OPENVPN_CUSTOM_PROVIDER_OVPN_LOCATION": "str?",
|
||||
"OPENVPN_PASSWORD": "str",
|
||||
"OPENVPN_PROVIDER": "list(|anonine|anonvpn|blackvpn|btguard|bulletvpn|cryptostorm|expressvpn|fastestvpn|freevpn|froot|frostvpn|getflix|ghostpath|giganews|goosevpn|hideme|hidemyass|integrityvpn|ipvanish|ironsocket|ivacy|ivpn|mullvad|nordvpn|octanevpn|ovpn|pia|privado|privatevpn|protonvpn|proxpn|purevpn|ra4w|safervpn|slickvpn|slickvpncore|smartdnsproxy|smartvpn|surfshark|tiger|torguard|trustzone|tunnelbear|vpnac|vpnarea|vpnbook|vpnfacile|vpnht|vpntunnel|vpnunlimited|vyprvpn|wevpn|windscribe|zoogvpn)?",
|
||||
"OPENVPN_PROVIDER": "list(custom|anonine|anonvpn|blackvpn|btguard|bulletvpn|cryptostorm|expressvpn|fastestvpn|freevpn|froot|frostvpn|getflix|ghostpath|giganews|goosevpn|hideme|hidemyass|integrityvpn|ipvanish|ironsocket|ivacy|ivpn|mullvad|nordvpn|octanevpn|ovpn|pia|privado|privatevpn|protonvpn|proxpn|purevpn|ra4w|safervpn|slickvpn|slickvpncore|smartdnsproxy|smartvpn|surfshark|tiger|torguard|trustzone|tunnelbear|vpnac|vpnarea|vpnbook|vpnfacile|vpnht|vpntunnel|vpnunlimited|vyprvpn|wevpn|windscribe|zoogvpn)?",
|
||||
"OPENVPN_USERNAME": "str",
|
||||
"PGID": "int",
|
||||
"PUID": "int",
|
||||
"TRANSMISSION_DOWNLOAD_DIR": "str",
|
||||
"TRANSMISSION_HOME": "str",
|
||||
"TRANSMISSION_INCOMPLETE_DIR": "str",
|
||||
"TRANSMISSION_V3_UPDATE": "bool?",
|
||||
"TRANSMISSION_WATCH_DIR": "str",
|
||||
"TRANSMISSION_WEB_UI": "list(standard|combustion|kettu|transmission-web-control|flood-for-transmission|shift)",
|
||||
"WEBPROXY_ENABLED": "bool",
|
||||
|
||||
@@ -1,29 +1,5 @@
|
||||
#!/usr/bin/bashio
|
||||
|
||||
#################
|
||||
# Update to v3 #
|
||||
################
|
||||
|
||||
if bashio::config.true "TRANSMISSION_V3_UPDATE"; then
|
||||
|
||||
(
|
||||
bashio::log.info "Updating transmission to v3"
|
||||
bashio::log.warning "If your previous version was v2, remove and add torrents again"
|
||||
|
||||
# see https://github.com/haugene/docker-transmission-openvpn/discussions/1937
|
||||
wget -O 976b5901365c5ca1.key "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xa37da909ae70535824d82620976b5901365c5ca1"
|
||||
|
||||
cat > /etc/apt/sources.list.d/transmission.list <<EOF
|
||||
# Transmission PPA https://launchpad.net/~transmissionbt/+archive/ubuntu/ppa
|
||||
deb [signed-by=/976b5901365c5ca1.key] http://ppa.launchpad.net/transmissionbt/ppa/ubuntu focal main
|
||||
#deb-src http://ppa.launchpad.net/transmissionbt/ppa/ubuntu focal main
|
||||
EOF
|
||||
|
||||
apt-get update -o Dir::Etc::sourcelist="sources.list.d/transmission.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
||||
apt-get install -y transmission-daemon transmission-cli
|
||||
) >/dev/null
|
||||
|
||||
fi
|
||||
# shellcheck shell=bash
|
||||
|
||||
####################
|
||||
# Export variables #
|
||||
@@ -81,34 +57,74 @@ done
|
||||
# Custom provider #
|
||||
###################
|
||||
|
||||
if bashio::config.true "OPENVPN_CUSTOM_PROVIDER"; then
|
||||
# Migrate OPENVPN_CUSTOM_PROVIDER to OPENVPN_PROVIDER
|
||||
if bashio::config.true 'OPENVPN_CUSTOM_PROVIDER'; then
|
||||
# Use new option
|
||||
bashio::addon.option "OPENVPN_PROVIDER" "custom"
|
||||
# Remove previous option
|
||||
bashio::addon.option "OPENVPN_CUSTOM_PROVIDER"
|
||||
# log
|
||||
bashio::log.yellow "OPENVPN_CUSTOM_PROVIDER actived, OPENVPN_PROVIDER set to custom"
|
||||
# Restart
|
||||
bashio::addon.restart
|
||||
fi
|
||||
|
||||
OVPNLOCATION="$(bashio::config "OPENVPN_CUSTOM_PROVIDER_OVPN_LOCATION")"
|
||||
OVPNCONFIG="$(bashio::config "OPENVPN_CONFIG")"
|
||||
OPENVPN_PROVIDER="${OVPNLOCATION##*/}"
|
||||
OPENVPN_PROVIDER="${OPENVPN_PROVIDER%.*}"
|
||||
OPENVPN_PROVIDER="${OPENVPN_PROVIDER,,}"
|
||||
bashio::log.info "Custom openvpn provider selected"
|
||||
# Function to check for files path
|
||||
function check_path () {
|
||||
|
||||
# Check that ovpn file exists
|
||||
if [ ! -f "$OVPNLOCATION" ]; then
|
||||
bashio::log.fatal "Ovpn file not found at location provided : $OVPNLOCATION"
|
||||
exit 1
|
||||
# Get variable
|
||||
file="$1"
|
||||
|
||||
# Loop through each line of the input file
|
||||
while read line
|
||||
do
|
||||
# Check if the line contains a txt file
|
||||
if [[ "$line" =~ \.txt ]] || [[ "$line" =~ \.crt ]]; then
|
||||
# Extract the txt file name from the line
|
||||
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
||||
# Check if the txt file exists
|
||||
if [ ! -f "$file_name" ]; then
|
||||
# Check if the txt file exists in the /config/openvpn/ directory
|
||||
if [ -f "/etc/openvpn/custom/${file_name##*/}" ]; then
|
||||
# Append /config/openvpn/ in front of the original txt file in the ovpn file
|
||||
sed -i "s|$file_name|/etc/openvpn/custom/${file_name##*/}|g" "$file"
|
||||
# Print a success message
|
||||
bashio::log.warning "Appended /etc/openvpn/custom/ to ${file_name##*/} in $file"
|
||||
else
|
||||
# Print an error message
|
||||
bashio::log.warning "$file_name is referenced in your ovpn file but does not exist in the $TRANSMISSION_HOME/openvpn folder"
|
||||
sleep 5
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < "$file"
|
||||
|
||||
}
|
||||
|
||||
# Define custom file
|
||||
if [ "$(bashio::config "OPENVPN_PROVIDER")" == "custom" ]; then
|
||||
|
||||
# Validate ovpn file
|
||||
openvpn_config="$(bashio::config "OPENVPN_CONFIG")"
|
||||
openvpn_config="${openvpn_config%.*}.ovpn"
|
||||
|
||||
# log
|
||||
bashio::log.info "OPENVPN_PROVDER set to custom, will use the openvpn file OPENVPN_CONFIG : $openvpn_config"
|
||||
|
||||
# If file found
|
||||
if [ -f /config/openvpn/"$openvpn_config" ]; then
|
||||
echo "... configured ovpn file : using $TRANSMISSION_HOME/openvpn/$openvpn_config"
|
||||
# Copy files
|
||||
rm -r /etc/openvpn/custom
|
||||
# Symlink folder
|
||||
echo "... symlink the $TRANSMISSION_HOME/openvpn foplder to /etc/openvpn/custom"
|
||||
ln -s $TRANSMISSION_HOME/openvpn /etc/openvpn/custom
|
||||
# Check path
|
||||
check_path /etc/openvpn/custom/"$openvpn_config"
|
||||
else
|
||||
bashio::exit.nok "Configured ovpn file : $openvpn_config not found! Are you sure you added it in $TRANSMISSION_HOME/openvpn ?"
|
||||
fi
|
||||
|
||||
# Copy ovpn file
|
||||
sed -i "s|config_repo_temp_dir=\$(mktemp -d)|config_repo_temp_dir=/tmp/tmp2|g" /etc/openvpn/fetch-external-configs.sh
|
||||
echo "Copying ovpn file to proper location"
|
||||
mkdir -p /etc/openvpn/"$OPENVPN_PROVIDER"
|
||||
mkdir -p /tmp/tmp2/temp/openvpn/"$OPENVPN_PROVIDER"
|
||||
cp "$OVPNLOCATION" /tmp/tmp2/temp/openvpn/"$OPENVPN_PROVIDER"/"$OPENVPN_PROVIDER".ovpn || \
|
||||
cp "$OVPNLOCATION/$OVPNCONFIG" /tmp/tmp2/temp/openvpn/"$OPENVPN_PROVIDER"/"$OPENVPN_PROVIDER".ovpn
|
||||
|
||||
# Use custom provider
|
||||
echo "Exporting variable for custom provider : $OPENVPN_PROVIDER"
|
||||
export OPENVPN_PROVIDER="$OPENVPN_PROVIDER"
|
||||
export OPENVPN_CONFIG="$OPENVPN_PROVIDER"
|
||||
|
||||
else
|
||||
|
||||
bashio::log.info "Custom openvpn provider not selected, the provider $OPENVPN_PROVIDER will be used"
|
||||
|
||||
Reference in New Issue
Block a user