diff --git a/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh b/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh index 19bd7aba9..6bf6d4d03 100755 --- a/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh @@ -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