mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 18:31:02 +01: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
|
||||
# Increment the line number
|
||||
((line_number++))
|
||||
# Extract the second argument
|
||||
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
||||
# If second argument is null or -
|
||||
if [ -z "$file_name" ] || [[ "$file_name" == -* ]]; then
|
||||
# Comment out the line
|
||||
sed -i "${line_number}s/^/# /" "$file"
|
||||
|
||||
# Check if lines starting with auth-user-pass have a valid argument
|
||||
###################################################################
|
||||
if [[ "$line" == "auth-user-pass"* ]]; then
|
||||
# Extract the second argument
|
||||
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
|
||||
|
||||
# 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
|
||||
file_name="$(echo "$line" | awk -F' ' '{print $2}')"
|
||||
# Check if the txt file exists
|
||||
|
||||
Reference in New Issue
Block a user