mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-11 18:11:29 +02:00
Update 93-openvpn.sh
This commit is contained in:
@@ -20,38 +20,48 @@ if bashio::config.true 'openvpn_enabled'; then
|
|||||||
# Function to check for files path
|
# Function to check for files path
|
||||||
function check_path () {
|
function check_path () {
|
||||||
|
|
||||||
# Get variable
|
# Get variable
|
||||||
file="$1"
|
file="$1"
|
||||||
|
|
||||||
# Loop through each line of the input file
|
# Double check exists
|
||||||
while read line
|
if [ !-f "$file" ]; then
|
||||||
do
|
bashio::warning "$file not found"
|
||||||
# Check if the line contains a txt file
|
return 1
|
||||||
if [[ "$line" =~ \.txt ]] || [[ "$line" =~ \.crt ]]; then
|
fi
|
||||||
# Extract the txt file name from the line
|
|
||||||
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
cp "$file" "$file2"
|
||||||
# Check if the txt file exists
|
|
||||||
if [ ! -f "$file_name" ]; then
|
# Loop through each line of the input file
|
||||||
# Check if the txt file exists in the /config/openvpn/ directory
|
while read line
|
||||||
if [ -f "/config/openvpn/${file_name##*/}" ]; then
|
do
|
||||||
# Append /config/openvpn/ in front of the original txt file in the ovpn file
|
# Check if the line contains a txt file
|
||||||
sed -i "s|$file_name|/config/openvpn/${file_name##*/}|g" "$file"
|
if [[ "$line" =~ \.txt ]] || [[ "$line" =~ \.crt ]]; then
|
||||||
# Print a success message
|
# Extract the txt file name from the line
|
||||||
bashio::log.warning "Appended /config/openvpn/ to ${file_name##*/} in $file"
|
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
||||||
else
|
# Check if the txt file exists
|
||||||
# Print an error message
|
if [ ! -f "$file_name" ]; then
|
||||||
bashio::log.warning "$file_name is referenced in your ovpn file but does not exist, and can't be found either in the /config/openvpn/ directory"
|
# Check if the txt file exists in the /config/openvpn/ directory
|
||||||
sleep 5
|
if [ -f "/etc/openvpn/custom/${file_name##*/}" ]; then
|
||||||
fi
|
# 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
|
fi
|
||||||
done < "$file"
|
fi
|
||||||
|
done < "$file2"
|
||||||
|
|
||||||
# Standardize lf
|
rm "$file2"
|
||||||
dos2unix "$file"
|
|
||||||
|
|
||||||
# Correct paths
|
# Standardize lf
|
||||||
sed -i "s=/etc/openvpn=/config/openvpn=g" "$file"
|
dos2unix "$file"
|
||||||
|
|
||||||
|
# Correct paths
|
||||||
|
sed -i "s=/etc/openvpn=/config/openvpn=g" "$file"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user