From a5490518ba229334e52eb72311598d545236104d Mon Sep 17 00:00:00 2001 From: Pavel Muhortov Date: Thu, 4 Jan 2024 22:10:15 +0300 Subject: [PATCH] added additional client description to $faqprofile --- README.md | 5 +++-- ovpn-client-management.sh | 36 ++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2449d53..d36b107 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,9 @@ ____ |-----------|--------------|------------------------|---------------| | 1 |**add\|del**|add or delete client config|**REQUIRED**| | 2 |**\**|client username|**REQUIRED**| -| 3 |**\**|client password|| -| 4 |**[-f]**,**[--force]**|service will restart after username delete|| +| 3 |**\**|client password|**REQUIRED**| +| 4 |**\**|client description|| +| 5 |**[-f]**,**[--force]**|service will restart after username delete|| Example usage: diff --git a/ovpn-client-management.sh b/ovpn-client-management.sh index cb511ef..513c430 100644 --- a/ovpn-client-management.sh +++ b/ovpn-client-management.sh @@ -102,11 +102,11 @@ createuser() { ####################################### # shellcheck disable=SC2016 createcert() { - cd ${easyrsadir} || execerror "" - sed -i -e '$aset_var EASYRSA_REQ_CN '"${clientname}"'' ${easyrsavar} + cd "${easyrsadir}" || execerror "" + sed -i -e '$aset_var EASYRSA_REQ_CN '"${clientname}"'' "${easyrsavar}" # ${easyrsaexe} --passout=pass:"${clientpass}" --passin=pass:${easyrsacap} build-client-full "${clientname}" ${easyrsaexe} --passin=pass:"${easyrsacap}" build-client-full "${clientname}" nopass - sed -i '/EASYRSA_REQ_CN/d' ${easyrsavar} + sed -i '/EASYRSA_REQ_CN/d' "${easyrsavar}" } ####################################### @@ -120,7 +120,7 @@ createcert() { # None ####################################### createovpn() { - cd ${easyrsadir} || execerror "" + cd "${easyrsadir}" || execerror "" { cat "${ovpncfgdef}" echo -e '' @@ -146,12 +146,12 @@ createovpn() { ####################################### createtars() { cp "${ovpncfgdir}/${clientname}.ovpn" "${ovpncfgdir}/vpn.cnf" - sed -i "s#auth-user-pass#auth-user-pass /config/openvpn/vpn.txt#g" ${ovpncfgdir}/vpn.cnf + sed -i "s#auth-user-pass#auth-user-pass /config/openvpn/vpn.txt#g" "${ovpncfgdir}/vpn.cnf" { echo -e "${clientname}" echo -e "${clientpass}" } >> "${ovpncfgdir}/vpn.txt" - cd ${ovpncfgdir} || execerror "" + cd "${ovpncfgdir}" || execerror "" tar cf "${clientname}.tar" --remove-files vpn.cnf vpn.txt } @@ -166,17 +166,19 @@ createtars() { # None ####################################### createinfo() { - cd ${easyrsadir} || execerror + cd "${easyrsadir}" || execerror "" validuntil=$(${easyrsaexe} show-cert "${clientname}" | grep "Not After" | cut -d: -f2-) faqprofile=$(cat <> /dev/null 2>&1 & ) addtologs "sent mail with subject '${subj}'" } + ####################################### # Deleting linux user # Globals: @@ -234,9 +237,9 @@ deleteuser() { # None ####################################### deletecert() { - cd ${easyrsadir} || execerror - ${easyrsaexe} --batch --passin=pass:${easyrsacap} revoke "${clientname}" - ${easyrsaexe} --batch --passin=pass:${easyrsacap} gen-crl + cd "${easyrsadir}" || execerror + ${easyrsaexe} --batch --passin=pass:"${easyrsacap}" revoke "${clientname}" + ${easyrsaexe} --batch --passin=pass:"${easyrsacap}" gen-crl } ####################################### @@ -290,6 +293,7 @@ ovpncfgdef="${ovpncfgdir}/client.conf.default" clienttodo=$1 clientname=$2 clientpass=$3 +additional=$4 resetforce=0 for argument in "${@}"; do