mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-12 18:41:27 +02:00
Update 93-openvpn.sh
This commit is contained in:
@@ -35,16 +35,28 @@ if bashio::config.true 'openvpn_enabled'; then
|
|||||||
while read -r line; do
|
while read -r line; do
|
||||||
# Increment the line number
|
# Increment the line number
|
||||||
((line_number++))
|
((line_number++))
|
||||||
# Extract the second argument
|
|
||||||
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
# Check if lines starting with auth-user-pass have a valid argument
|
||||||
# If second argument is null or -
|
###################################################################
|
||||||
if [ -z "$file_name" ] || [[ "$file_name" == -* ]]; then
|
if [[ "$line" == "auth-user-pass"* ]]; then
|
||||||
# Comment out the line
|
# Extract the second argument
|
||||||
sed -i "${line_number}s/^/# /" "$file"
|
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
||||||
|
# If second argument is null or -
|
||||||
|
if [ -z "$file_name" ] || [[ "$file_name" == -* ]]; then
|
||||||
|
# Insert to explain why a comment is made
|
||||||
|
sed -i "${line_number}i # The following line is commented out as does not contain a valid argument" "$file"
|
||||||
|
# Increment as new line added
|
||||||
|
((line_number++))
|
||||||
|
# Comment out the line
|
||||||
|
sed -i "${line_number}s/^/# /" "$file"
|
||||||
|
# Go to next line
|
||||||
|
continue
|
||||||
|
fi
|
||||||
fi
|
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
|
||||||
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
||||||
# Check if the txt file exists
|
# Check if the txt file exists
|
||||||
|
|||||||
Reference in New Issue
Block a user