create directory before, to avoid No Such File error. Use OPENVPN_CONFIG env var to get choosen domain
This commit is contained in:
@@ -7,20 +7,22 @@ DIR="/tmp/freevpn"
|
||||
TARGET="/etc/openvpn/freevpn"
|
||||
ZIP_FILE="/tmp/freevpn.zip"
|
||||
|
||||
URL=`curl -s https://freevpn.me/accounts/`
|
||||
# Use the OPENVPN_CONFIG env var to obtain running domain
|
||||
URL=`curl -s https://freevpn."${OPENVPN_CONFIG%%-*}"/accounts/`
|
||||
REGEX='<a +.*href="(https:.*\.zip)"'
|
||||
|
||||
# Create directory if not exits
|
||||
if [[ ! -d "$DIR" ]]
|
||||
then
|
||||
mkdir -p $DIR
|
||||
fi
|
||||
|
||||
# Download FreeVPN Zip file
|
||||
[[ $URL =~ $REGEX ]] && curl -s ${BASH_REMATCH[1]} -o ${ZIP_FILE}
|
||||
|
||||
# Unzip file
|
||||
unzip -qo ${ZIP_FILE} -d $DIR
|
||||
|
||||
# Create directory if not exits
|
||||
if [[ ! -d "$DIR" ]]
|
||||
then
|
||||
mkdir $DIR
|
||||
fi
|
||||
|
||||
# Process content file
|
||||
IFS=$'\n'
|
||||
|
Reference in New Issue
Block a user