X-Git-Url: http://git.squeep.com/?p=awsible;a=blobdiff_plain;f=createVPNAccount.sh;fp=createVPNAccount.sh;h=276d9c1d9ecb88e807a6d91f2fc3b5edd5e600f3;hp=0000000000000000000000000000000000000000;hb=37253e1b3651d2e3f1c714c55fb05894abacf398;hpb=588872ef49cb75a5ffa775e738ae3c61f9d7bad0 diff --git a/createVPNAccount.sh b/createVPNAccount.sh new file mode 100755 index 0000000..276d9c1 --- /dev/null +++ b/createVPNAccount.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +set -e + +DIR_SUFFIX="_ca" +ME=`basename "${0}"` +RED='\033[0;31m' +NC='\033[0m' + +echo "${ME} - Create VPN Configs" +echo "" + +allDone() +{ + echo -e " ${RED}-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-${NC}" + echo -e " ${RED}L O O K A T W H A T T O D O${NC}" + echo -e " ${RED}-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-${NC}" + echo "" + echo "Assuming no failures were output above, here's what you should have:" + echo " VPNConfigs/${1}-${2}.ovpn" + echo "" + echo "For Windows users, you should rename this to ${1}.ovpn and put it into the configurations directory" + echo "as described on the confluence page." + echo "" + echo "For Mac users (running tunnelblick) you should create a directory named ${1}.tblk and put" + echo "VPNConfigs/${1}-${2}.ovpn into it. Once you have that on your Mac, you should just be able" + echo "to double click on it." + echo "" + echo "...magics..." +} + +usage(){ + local i + cat< "VPNConfigs/${environment}-${user}.ovpn" +} + +if [ -z $2 ] || [ "$1" == "-h" ] ; then + usage; +fi +if [ ! -d "${1}${DIR_SUFFIX}" ] || [ ! -e "userManagementTemplates/${1}.sh" ] ; then + echo "Invalid configuration profile: ${1}" + echo "" + usage +fi + +if [ -e ${1}${DIR_SUFFIX}/pki/issued/${2}.crt ]; then + echo "${2} already has a certificate..." + echo "" + genConfiguration "${1}" "${2}" +else + echo "Well, you didn't ask for help, and you provided a valid profile, and the user doesn't already exist..." + echo "" + echo -e "${RED}**************************************************************************${NC}" + echo -e "${RED}*** ***${NC}" + echo -e "${RED}*** ${NC}The next step will ask you for a password, this is the CA password ${RED}***${NC}" + echo -e "${RED}*** ***${NC}" + echo -e "${RED}**************************************************************************${NC}" + + pushd "${1}${DIR_SUFFIX}" >/dev/null + ./easyrsa build-client-full "${2}" nopass + popd >/dev/null + genConfiguration "${1}" "${2}" +fi + +allDone "${1}" "${2}"