Updated with new design index page
This commit is contained in:
parent
0e6212bf6c
commit
4bd15b0d78
65
index.sh
65
index.sh
@ -7,12 +7,19 @@ echo ""
|
||||
echo "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Simple OpenVPN Server</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>vpn.wberu.be</title>
|
||||
<link href="https://ajusa.github.io/lit/dist/lit.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,700" rel="stylesheet">
|
||||
</head>
|
||||
<body>"
|
||||
|
||||
echo "<h1>Simple OpenVPN Server</h1>"
|
||||
<body class="m0">
|
||||
<div class="c">
|
||||
<header class="mb3">
|
||||
<h1 class="tc mb0"><b>vpn.wberu.be</b></h1>
|
||||
<h5 class="tc mb1">Service de tunnel OpenVPN</h5>
|
||||
<hr>
|
||||
</header>"
|
||||
|
||||
eval `echo "${QUERY_STRING}"|tr '&' ';'`
|
||||
|
||||
@ -20,7 +27,14 @@ IP=$(wget -4qO- "http://whatismyip.akamai.com/")
|
||||
|
||||
newclient () {
|
||||
# Generates the custom client.ovpn
|
||||
cp /etc/openvpn/client-common.txt /etc/openvpn/clients/$1.ovpn
|
||||
case $2 in
|
||||
"webaccess")
|
||||
cp /etc/openvpn/client-webaccess.txt /etc/openvpn/clients/$1.ovpn
|
||||
;;
|
||||
"telephony")
|
||||
cp /etc/openvpn/client-telephony.txt /etc/openvpn/clients/$1.ovpn
|
||||
;;
|
||||
esac
|
||||
echo "<ca>" >> /etc/openvpn/clients/$1.ovpn
|
||||
cat /etc/openvpn/easy-rsa/pki/ca.crt >> /etc/openvpn/clients/$1.ovpn
|
||||
echo "</ca>" >> /etc/openvpn/clients/$1.ovpn
|
||||
@ -41,42 +55,49 @@ case $option in
|
||||
"add") #Add a client
|
||||
./easyrsa build-client-full $client nopass
|
||||
# Generates the custom client.ovpn
|
||||
newclient "$client"
|
||||
echo "<h3>Certificate for client <span style='color:red'>$client</span> added.</h3>"
|
||||
newclient "$client" "$type"
|
||||
echo " Le certificat du client <span style='color:red'>$client</span> a été ajouté.<br><br>"
|
||||
;;
|
||||
"revoke") #Revoke a client
|
||||
echo "<span style='display:none'>"
|
||||
./easyrsa --batch revoke $client
|
||||
./easyrsa gen-crl
|
||||
echo "</span>"
|
||||
./easyrsa --batch revoke $client > /dev/null
|
||||
./easyrsa gen-crl > /dev/null
|
||||
rm -rf pki/reqs/$client.req
|
||||
rm -rf pki/private/$client.key
|
||||
rm -rf pki/issued/$client.crt
|
||||
rm -rf /etc/openvpn/crl.pem
|
||||
cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem
|
||||
# CRL is read with each client connection, when OpenVPN is dropped to nobody
|
||||
echo "<h3>Certificate for client <span style='color:red'>$client</span> revoked.</h3>"
|
||||
echo " Le certificat du client <span style='color:red'>$client</span> a été révoqué.<br><br>"
|
||||
;;
|
||||
esac
|
||||
|
||||
NUMBEROFCLIENTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c "^V")
|
||||
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
||||
echo "<h3>You have no existing clients.<h3>"
|
||||
echo " Vous n'avez pas de clients existants."
|
||||
else
|
||||
while read c; do
|
||||
if [[ $(echo $c | grep -c "^V") = '1' ]]; then
|
||||
clientName=$(echo $c | cut -d '=' -f 2)
|
||||
echo "<p><a href='index.sh?option=revoke&client=$clientName'>Revoke</a> <a target='_blank' href='download.sh?client=$clientName'>Download</a> $clientName</p>"
|
||||
echo " <a href='index.sh?option=revoke&client=$clientName'><button class='btn'>Révoquer</button></a> "
|
||||
echo " <a target='_blank' href='download.sh?client=$clientName'><button class='btn primary'>Télécharger</button></a>"
|
||||
echo " $clientName<br>"
|
||||
fi
|
||||
done </etc/openvpn/easy-rsa/pki/index.txt
|
||||
fi
|
||||
|
||||
echo "
|
||||
<form action='index.sh' method='get'>
|
||||
<input type='hidden' name='option' value='add'>
|
||||
New Client: <input type='text' name='client'><input type='submit' value='Add'>
|
||||
</form>
|
||||
"
|
||||
|
||||
echo "</body></html>"
|
||||
<hr>
|
||||
<form action='index.sh' method='get'>
|
||||
<input type='hidden' name='option' value='add'>
|
||||
<br>Nouveau client: <br>
|
||||
<input class='card' type='text' name='client'>
|
||||
<select class='card' name='type'>
|
||||
<option value='webaccess'>Accès web</option>
|
||||
<option value='telephony'>Téléphonie</option>
|
||||
</select>
|
||||
<button class='btn primary' type='submit'>Créer</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>"
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user