Merge pull request #822 from orazioedoardo/patch-1

Fix .ovpn12 file, make pivpn -a options discoverable
Fixes #820
This commit is contained in:
4s3ti 2019-09-02 11:26:56 +02:00 committed by GitHub
commit add3daf8de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

2
pivpn
View file

@ -58,7 +58,6 @@ function helpFunc {
echo ":::" echo ":::"
echo "::: Commands:" echo "::: Commands:"
echo "::: -a, add [nopass] Create a client ovpn profile, optional nopass" echo "::: -a, add [nopass] Create a client ovpn profile, optional nopass"
echo "::: -b,--bitwarden Create and save a client through Bitwarden"
echo "::: -c, clients List any connected clients to the server" echo "::: -c, clients List any connected clients to the server"
echo "::: -d, debug Start a debugging session if having trouble" echo "::: -d, debug Start a debugging session if having trouble"
echo "::: -l, list List all valid and revoked certificates" echo "::: -l, list List all valid and revoked certificates"
@ -75,7 +74,6 @@ fi
# Handle redirecting to specific functions based on arguments # Handle redirecting to specific functions based on arguments
case "$1" in case "$1" in
"-a" | "add" ) makeOVPNFunc "$@";; "-a" | "add" ) makeOVPNFunc "$@";;
"-b" | "bitwarden" ) makeOVPNFunc "$@";;
"-c" | "clients" ) listClientsFunc;; "-c" | "clients" ) listClientsFunc;;
"-d" | "debug" ) debugFunc;; "-d" | "debug" ) debugFunc;;
"-l" | "list" ) listOVPNFunc;; "-l" | "list" ) listOVPNFunc;;

View file

@ -15,19 +15,25 @@ INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash
helpFunc() { helpFunc() {
echo "::: Create a client ovpn profile, optional nopass" echo "::: Create a client ovpn profile, optional nopass"
echo ":::" echo ":::"
echo "::: Usage: pivpn <-a|add> [-n|--name <arg>] [-p|--password <arg>]|[nopass] [-d|--days <number>] [-i|--iOS] [-h|--help]" echo "::: Usage: pivpn <-a|add> [-n|--name <arg>] [-p|--password <arg>]|[nopass] [-d|--days <number>] [-b|--bitwarden] [-i|--iOS] [-h|--help]"
echo ":::" echo ":::"
echo "::: Commands:" echo "::: Commands:"
echo "::: [none] Interactive mode" echo "::: [none] Interactive mode"
echo "::: nopass Create a client without a password" echo "::: nopass Create a client without a password"
echo "::: -b,--bitwarden Create and save a client through Bitwarden"
echo "::: -d,--days Expire the certificate after specified number of days (default: 1080)"
echo "::: -n,--name Name for the Client (default: '"$(hostname)"')" echo "::: -n,--name Name for the Client (default: '"$(hostname)"')"
echo "::: -p,--password Password for the Client (no default)" echo "::: -p,--password Password for the Client (no default)"
echo "::: -d,--days Expire the certificate after specified number of days (default: 1080)"
echo "::: -b,--bitwarden Create and save a client through Bitwarden"
echo "::: -i,--iOS Generate a certificate that leverages iOS keychain" echo "::: -i,--iOS Generate a certificate that leverages iOS keychain"
echo "::: -h,--help Show this help dialog" echo "::: -h,--help Show this help dialog"
} }
if [ ! -f /etc/pivpn/HELP_SHOWN ]; then
helpFunc
echo
touch /etc/pivpn/HELP_SHOWN
fi
# Parse input arguments # Parse input arguments
while test $# -gt 0 while test $# -gt 0
do do
@ -342,7 +348,7 @@ if [ "$iOS" = "1" ]; then
printf "Please remember the export password\n" printf "Please remember the export password\n"
printf "as you will need this import the certificate on your iOS device\n" printf "as you will need this import the certificate on your iOS device\n"
printf "========================================================\n" printf "========================================================\n"
openssl pkcs12 -passin env:$PASSWD -export -in issued/${NAME}${CRT} -inkey private/${NAME}${KEY} -certfile ${CA} -name ${NAME} -out /home/$INSTALL_USER/ovpns/$NAME.ovpn12 openssl pkcs12 -passin pass:"$PASSWD" -export -in "issued/${NAME}${CRT}" -inkey "private/${NAME}${KEY}" -certfile ${CA} -name "${NAME}" -out "/home/$INSTALL_USER/ovpns/$NAME.ovpn12"
chown "$INSTALL_USER" "/home/$INSTALL_USER/ovpns/$NAME.ovpn12" chown "$INSTALL_USER" "/home/$INSTALL_USER/ovpns/$NAME.ovpn12"
chmod 600 "/home/$INSTALL_USER/ovpns/$NAME.ovpn12" chmod 600 "/home/$INSTALL_USER/ovpns/$NAME.ovpn12"
printf "========================================================\n" printf "========================================================\n"