Update 93-openvpn.sh

This commit is contained in:
Alexandre
2024-01-09 10:59:43 +01:00
committed by GitHub
parent bd947643a1
commit 47aef03195

View File

@@ -29,20 +29,19 @@ if bashio::config.true 'openvpn_enabled'; then
return 1 return 1
fi fi
# Avoid single auth-user-pass # Check each lines
if grep -q "^auth-user-pass" "$file" ; then cp "$file" /tmpfile
second_word="$(sed -n "/^auth-user-pass/p" "$file" | awk -F' ' '{print $2}')" line_number=0
# If the second word is empty or starts with a dash while read -r line; do
if [ -z "$second_word" ] || [[ "$second_word" == -* ]]; then # Increment the line number
# Comment out the line with # ((line_number++))
sed -i '/^auth-user-pass/s/^/#/' "$file" # Extract the second argument
fi file_name="$(echo "$line" | awk -F' ' '{print $2}')"
if [ -z "$file_name" ] || [[ "$file_name" == -* ]]; then
# Comment out the line
sed -i "${line_number}s/^/# /" "$file"
fi fi
# Check referenced files
cp "$file" /tmpfile
while read -r line
do
# Check if the line contains a txt file # Check if the line contains a txt file
if [[ ! $line =~ ^"#" ]] && [[ ! $line =~ ^";" ]] && [[ "$line" =~ \.txt ]] || [[ "$line" =~ \.crt ]] || [[ "$line" =~ auth-user-pass ]]; then if [[ ! $line =~ ^"#" ]] && [[ ! $line =~ ^";" ]] && [[ "$line" =~ \.txt ]] || [[ "$line" =~ \.crt ]] || [[ "$line" =~ auth-user-pass ]]; then
# Extract the txt file name from the line # Extract the txt file name from the line