Github bot : script beautyshied

This commit is contained in:
github-actions
2023-12-31 00:13:36 +00:00
parent c2297f5328
commit 2efe2a7f14

View File

@@ -20,16 +20,16 @@ if bashio::config.true 'openvpn_enabled'; then
# Function to check for files path # Function to check for files path
function check_path () { function check_path () {
# Get variable # Get variable
file="$1" file="$1"
# Double check exists # Double check exists
if [ ! -f "$file" ]; then if [ ! -f "$file" ]; then
bashio::warning "$file not found" bashio::warning "$file not found"
return 1 return 1
fi fi
cp "$file" /tmpfile cp "$file" /tmpfile
# Loop through each line of the input file # Loop through each line of the input file
while read -r line while read -r line
@@ -54,24 +54,24 @@ if bashio::config.true 'openvpn_enabled'; then
fi fi
done < /tmpfile done < /tmpfile
rm /tmpfile rm /tmpfile
# Standardize lf # Standardize lf
dos2unix "$file" dos2unix "$file"
# Remove custom up & down # Remove custom up & down
sed -i '/^up /s/^/#/' "$file" sed -i '/^up /s/^/#/' "$file"
sed -i '/^down /s/^/#/' "$file" sed -i '/^down /s/^/#/' "$file"
# Remove blank lines # Remove blank lines
sed -i '/^[[:blank:]]*$/d' "$file" sed -i '/^[[:blank:]]*$/d' "$file"
# Ensure config ends with a line feed # Ensure config ends with a line feed
sed -i "\$q" "$file" sed -i "\$q" "$file"
# Correct paths # Correct paths
sed -i "s=/etc/openvpn=/config/openvpn=g" "$file" sed -i "s=/etc/openvpn=/config/openvpn=g" "$file"
sed -i "s=/config/openvpn/credentials=/etc/openvpn/credentials=g" "$file" sed -i "s=/config/openvpn/credentials=/etc/openvpn/credentials=g" "$file"
} }
@@ -97,7 +97,7 @@ if bashio::config.true 'openvpn_enabled'; then
bashio::exit.nok "Configured ovpn file : $openvpn_config not found! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?" bashio::exit.nok "Configured ovpn file : $openvpn_config not found! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?"
fi fi
# If openvpn_config not set, but folder is not empty # If openvpn_config not set, but folder is not empty
elif ls /config/openvpn/*.ovpn > /dev/null 2>&1; then elif ls /config/openvpn/*.ovpn > /dev/null 2>&1; then
# Look for openvpn files # Look for openvpn files
# Wildcard search for openvpn config files and store results in array # Wildcard search for openvpn config files and store results in array
@@ -110,7 +110,7 @@ if bashio::config.true 'openvpn_enabled'; then
printf '%s\n' "${VPN_CONFIGS[@]}" printf '%s\n' "${VPN_CONFIGS[@]}"
# Check path # Check path
check_path /config/openvpn/"${openvpn_config}" check_path /config/openvpn/"${openvpn_config}"
# If openvpn_enabled set, config not set, and openvpn folder empty # If openvpn_enabled set, config not set, and openvpn folder empty
else else
bashio::exit.nok "openvpn_enabled is set, however, your openvpn folder is empty ! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?" bashio::exit.nok "openvpn_enabled is set, however, your openvpn folder is empty ! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?"
fi fi