mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 05:44:03 +02:00
Update 93-openvpn.sh
This commit is contained in:
@@ -28,21 +28,20 @@ if bashio::config.true 'openvpn_enabled'; then
|
|||||||
bashio::warning "$file not found"
|
bashio::warning "$file not found"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Avoid single auth-user-pass
|
# Check each lines
|
||||||
if grep -q "^auth-user-pass" "$file" ; then
|
|
||||||
second_word="$(sed -n "/^auth-user-pass/p" "$file" | awk -F' ' '{print $2}')"
|
|
||||||
# If the second word is empty or starts with a dash
|
|
||||||
if [ -z "$second_word" ] || [[ "$second_word" == -* ]]; then
|
|
||||||
# Comment out the line with #
|
|
||||||
sed -i '/^auth-user-pass/s/^/#/' "$file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check referenced files
|
|
||||||
cp "$file" /tmpfile
|
cp "$file" /tmpfile
|
||||||
while read -r line
|
line_number=0
|
||||||
do
|
while read -r line; do
|
||||||
|
# Increment the line number
|
||||||
|
((line_number++))
|
||||||
|
# Extract the second argument
|
||||||
|
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
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
Reference in New Issue
Block a user