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>
|
echo "<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Simple OpenVPN Server</title>
|
<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>
|
</head>
|
||||||
<body>"
|
<body class="m0">
|
||||||
|
<div class="c">
|
||||||
echo "<h1>Simple OpenVPN Server</h1>"
|
<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 '&' ';'`
|
eval `echo "${QUERY_STRING}"|tr '&' ';'`
|
||||||
|
|
||||||
|
@ -20,7 +27,14 @@ IP=$(wget -4qO- "http://whatismyip.akamai.com/")
|
||||||
|
|
||||||
newclient () {
|
newclient () {
|
||||||
# Generates the custom client.ovpn
|
# 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
|
echo "<ca>" >> /etc/openvpn/clients/$1.ovpn
|
||||||
cat /etc/openvpn/easy-rsa/pki/ca.crt >> /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
|
echo "</ca>" >> /etc/openvpn/clients/$1.ovpn
|
||||||
|
@ -41,42 +55,49 @@ case $option in
|
||||||
"add") #Add a client
|
"add") #Add a client
|
||||||
./easyrsa build-client-full $client nopass
|
./easyrsa build-client-full $client nopass
|
||||||
# Generates the custom client.ovpn
|
# Generates the custom client.ovpn
|
||||||
newclient "$client"
|
newclient "$client" "$type"
|
||||||
echo "<h3>Certificate for client <span style='color:red'>$client</span> added.</h3>"
|
echo " Le certificat du client <span style='color:red'>$client</span> a été ajouté.<br><br>"
|
||||||
;;
|
;;
|
||||||
"revoke") #Revoke a client
|
"revoke") #Revoke a client
|
||||||
echo "<span style='display:none'>"
|
./easyrsa --batch revoke $client > /dev/null
|
||||||
./easyrsa --batch revoke $client
|
./easyrsa gen-crl > /dev/null
|
||||||
./easyrsa gen-crl
|
|
||||||
echo "</span>"
|
|
||||||
rm -rf pki/reqs/$client.req
|
rm -rf pki/reqs/$client.req
|
||||||
rm -rf pki/private/$client.key
|
rm -rf pki/private/$client.key
|
||||||
rm -rf pki/issued/$client.crt
|
rm -rf pki/issued/$client.crt
|
||||||
rm -rf /etc/openvpn/crl.pem
|
rm -rf /etc/openvpn/crl.pem
|
||||||
cp /etc/openvpn/easy-rsa/pki/crl.pem /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
|
# 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
|
esac
|
||||||
|
|
||||||
NUMBEROFCLIENTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c "^V")
|
NUMBEROFCLIENTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c "^V")
|
||||||
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
||||||
echo "<h3>You have no existing clients.<h3>"
|
echo " Vous n'avez pas de clients existants."
|
||||||
else
|
else
|
||||||
while read c; do
|
while read c; do
|
||||||
if [[ $(echo $c | grep -c "^V") = '1' ]]; then
|
if [[ $(echo $c | grep -c "^V") = '1' ]]; then
|
||||||
clientName=$(echo $c | cut -d '=' -f 2)
|
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
|
fi
|
||||||
done </etc/openvpn/easy-rsa/pki/index.txt
|
done </etc/openvpn/easy-rsa/pki/index.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<form action='index.sh' method='get'>
|
<hr>
|
||||||
<input type='hidden' name='option' value='add'>
|
<form action='index.sh' method='get'>
|
||||||
New Client: <input type='text' name='client'><input type='submit' value='Add'>
|
<input type='hidden' name='option' value='add'>
|
||||||
</form>
|
<br>Nouveau client: <br>
|
||||||
"
|
<input class='card' type='text' name='client'>
|
||||||
|
<select class='card' name='type'>
|
||||||
echo "</body></html>"
|
<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
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue