added additional client description to $faqprofile

This commit is contained in:
Pavel Muhortov 2024-01-04 22:10:15 +03:00
parent c206d33a72
commit a5490518ba
2 changed files with 23 additions and 18 deletions

View File

@ -91,8 +91,9 @@ ____
|-----------|--------------|------------------------|---------------|
| 1 |**add\|del**|add or delete client config|**REQUIRED**|
| 2 |**\<username\>**|client username|**REQUIRED**|
| 3 |**\<password\>**|client password||
| 4 |**[-f]**,**[--force]**|service will restart after username delete||
| 3 |**\<password\>**|client password|**REQUIRED**|
| 4 |**\<additional\>**|client description||
| 5 |**[-f]**,**[--force]**|service will restart after username delete||
Example usage:

View File

@ -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 '<ca>'
@ -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 <<END
OpenVPN Connect client and installation instructions:
https://openvpn.net/vpn-client/
OpenVPN Connect client:
https://openvpn.net/client/
OpenVPN GUI client:
https://openvpn.net/community-downloads/
User Login: ${clientname}
User Password: ${clientpass}
${additional}
User Login: \`${clientname}\`
User Password: \`${clientpass}\`
Time Expired: ${validuntil}
END
)
@ -185,7 +187,7 @@ END
}
#######################################
# Send email notification about client connect
# Send email notification about client config
# Globals:
# clientname
# faqprofile
@ -204,13 +206,14 @@ startsendmail() {
--port "$(grep "port=" /usr/local/bin/sendmail.config | cut -d= -f2)" \
--stls "True" \
--subj "${subj}" \
--text "${faqprofile}" \
--text "$(printf "%s\n" "${faqprofile}" | sed 's|`||g')" \
--file "${ovpncfgdir}/${clientname}.ovpn,${ovpncfgdir}/${clientname}.tar" \
>> /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