This commit is contained in:
Julien VAUBOURG
2014-11-09 22:48:31 +01:00
parent b9db02821b
commit c92b131f23
4 changed files with 91 additions and 76 deletions

View File

@@ -25,7 +25,7 @@ is_ip6addr_set() {
} }
is_serverip6route_set() { is_serverip6route_set() {
server_ip6=$1 server_ip6=${1}
ip -6 route | grep -q "${server_ip6}/" ip -6 route | grep -q "${server_ip6}/"
} }
@@ -47,16 +47,16 @@ set_ip6addr() {
} }
set_serverip6route() { set_serverip6route() {
server_ip6=$1 server_ip6=${1}
ip6_gw=$2 ip6_gw=${2}
wired_device=$3 wired_device=${3}
ip route add "${server_ip6}/128" via "${ip6_gw}" dev "${wired_device}" ip route add "${server_ip6}/128" via "${ip6_gw}" dev "${wired_device}"
} }
start_openvpn() { start_openvpn() {
ip6_gw=$1 ip6_gw=${1}
server_ip6=$2 server_ip6=${2}
if [ ! -z "${ip6_gw}" -a ! -z "${server_ip6}" ]; then if [ ! -z "${ip6_gw}" -a ! -z "${server_ip6}" ]; then
proto=udp6 proto=udp6
@@ -88,9 +88,9 @@ unset_ip6addr() {
} }
unset_serverip6route() { unset_serverip6route() {
server_ip6=$1 server_ip6=${1}
ip6_gw=$2 ip6_gw=${2}
wired_device=$3 wired_device=${3}
ip route delete "${server_ip6}/128" via "${ip6_gw}" dev "${wired_device}" ip route delete "${server_ip6}/128" via "${ip6_gw}" dev "${wired_device}"
} }
@@ -102,7 +102,7 @@ stop_openvpn() {
## Tools ## Tools
moulinette_get() { moulinette_get() {
var=$1 var=${1}
value=$(yunohost app setting vpnclient "${var}") value=$(yunohost app setting vpnclient "${var}")
@@ -115,8 +115,8 @@ moulinette_get() {
} }
moulinette_set() { moulinette_set() {
var=$1 var=${1}
value=$2 value=${2}
msg=$(yunohost app setting vpnclient "${var}" -v "${value}") msg=$(yunohost app setting vpnclient "${var}" -v "${value}")
@@ -151,7 +151,7 @@ echo "OK"
# Script # Script
case "$1" in case "${1}" in
start) start)
if is_running; then if is_running; then
echo "Already started" echo "Already started"

View File

@@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
# Retrieve arguments # Retrieve arguments
domain=$1 domain=${1}
url_path=$2 url_path=${2}
server_name=$3 server_name=${3}
crt_client_path=$4 crt_client_path=${4}
crt_client_key_path=$5 crt_client_key_path=${5}
crt_server_ca_path=$6 crt_server_ca_path=${6}
ip6_net=$7 ip6_net=${7}
# Check arguments # Check arguments
# TODO # TODO
@@ -44,7 +44,6 @@ sudo install -b -o root -g root -m 0644 ../conf/phpfpm_vpnadmin.conf /etc/php5/f
# Copy web sources # Copy web sources
sudo mkdir -pm 0755 /var/www/vpnadmin/ sudo mkdir -pm 0755 /var/www/vpnadmin/
sudo cp -a ../sources/* /var/www/vpnadmin/ sudo cp -a ../sources/* /var/www/vpnadmin/
sudo chown -R root: /var/www/vpnadmin/ sudo chown -R root: /var/www/vpnadmin/
@@ -109,7 +108,7 @@ sudo yunohost app ssowatconf
# A new start will fix the interface without unsetting all stuff # A new start will fix the interface without unsetting all stuff
sudo yunohost app list -f hotspot --json | grep -q '"installed": true' sudo yunohost app list -f hotspot --json | grep -q '"installed": true'
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo yunohost service start ynh-hotspot sudo service ynh-hotspot start
fi fi
exit 0 exit 0

View File

@@ -4,7 +4,7 @@
domain=$(sudo yunohost app setting vpnclient domain) domain=$(sudo yunohost app setting vpnclient domain)
# The End # The End
sudo yunohost service stop ynh-vpnclient sudo service ynh-vpnclient stop
sudo yunohost service remove ynh-vpnclient sudo yunohost service remove ynh-vpnclient
sudo rm -f /etc/init.d/ynh-vpnclient sudo rm -f /etc/init.d/ynh-vpnclient
@@ -31,7 +31,7 @@ sudo userdel -f vpnadmin
# A new start will fix the interface without unsetting all stuff # A new start will fix the interface without unsetting all stuff
sudo yunohost app list -f hotspot --json | grep -q '"installed": true' sudo yunohost app list -f hotspot --json | grep -q '"installed": true'
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
sudo yunohost service start ynh-hotspot sudo service ynh-hotspot start
fi fi
# Remove packets # Remove packets

View File

@@ -7,62 +7,78 @@
<form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form"> <form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form">
<input type="hidden" name="_method" value="put" /> <input type="hidden" name="_method" value="put" />
<div class="form-group"> <div class="panel panel-default">
<label for="server_name" class="col-sm-3 control-label"><?= T_('Server Address') ?></label> <div class="panel-heading">
<div class="col-sm-9"> <h3 class="panel-title"><?= T_("VPN") ?></h3>
<input type="text" class="form-control" name="server_name" id="server_name" placeholder="access.ldn-fai.net" value="<?= $server_name ?>" /> </div>
<div style="padding: 14px 14px 0 10px">
<div class="form-group">
<label for="server_name" class="col-sm-3 control-label"><?= T_('Server Address') ?></label>
<div class="col-sm-9">
<input type="text" class="form-control" name="server_name" id="server_name" placeholder="access.ldn-fai.net" value="<?= $server_name ?>" />
</div>
</div>
<div class="form-group">
<label for="server_port" class="col-sm-3 control-label"><?= T_('Server Port') ?></label>
<div class="col-sm-9">
<input type="text" data-toggle="tooltip" data-title="<?= T_('With restricted access, you should use 443 (TCP) or 53 (UDP)') ?>" class="form-control" name="server_port" id="server_port" placeholder="1194" value="<?= $server_port ?>" />
</div>
</div>
<div class="form-group">
<label for="server_port" class="col-sm-3 control-label"><?= T_('Protocol') ?></label>
<div class="btn-group col-sm-9" data-toggle="buttons">
<label class="btn btn-default <?= $server_proto == 'udp' ? 'active' : '' ?>">
<input type="radio" name="server_proto" value="udp" <?= $server_proto == 'udp' ? 'checked="cheked"' : '' ?> /> <?= T_('UDP') ?>
</label>
<label class="btn btn-default <?= $server_proto == 'tcp' ? 'active' : '' ?>" data-toggle="tooltip" data-title="<?= T_('UDP is more efficient than TCP (but more filtered in case of restrictive access)') ?>">
<input type="radio" name="server_proto" value="tcp" <?= $server_proto == 'tcp' ? 'checked="cheked"' : '' ?> /> <?= T_('TCP') ?>
</label>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?= T_("Certificates") ?></h3>
</div>
<div style="padding: 14px 14px 0 10px">
<div class="form-group">
<label for="crt_client" class="col-sm-3 control-label"><?= T_('Update Client Cert.') ?></label>
<div class="input-group col-sm-9" style="padding: 0 15px">
<input id="crt_client" name="crt_client" type="file" style="display: none" />
<input type="text" class="form-control fileinput" id="crt_client_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
<a class="btn input-group-addon fileinput" id="crt_client_chooserbtn"><?= T_('Browse') ?></a>
</div>
</div>
<div class="form-group">
<label for="crt_client_key" class="col-sm-3 control-label"><?= T_('Update Client Key') ?></label>
<div class="input-group col-sm-9" style="padding: 0 15px">
<input id="crt_client_key" name="crt_client_key" type="file" style="display: none" />
<input type="text" class="form-control fileinput" id="crt_client_key_choosertxt" placeholder="-----BEGIN PRIVATE KEY-----" readonly="readonly" />
<a class="btn input-group-addon fileinput" id="crt_client_key_chooserbtn"><?= T_('Browse') ?></a>
</div>
</div>
<div class="form-group">
<label for="crt_server_ca" class="col-sm-3 control-label"><?= T_('Update Server CA') ?></label>
<div class="input-group col-sm-9" style="padding: 0 15px">
<input id="crt_server_ca" name="crt_server_ca" type="file" style="display: none" />
<input type="text" class="form-control fileinput" id="crt_server_ca_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
<a class="btn input-group-addon fileinput" id="crt_server_ca_chooserbtn"><?= T_('Browse') ?></a>
</div>
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="server_port" class="col-sm-3 control-label"><?= T_('Server Port') ?></label> <div style="text-align: center">
<div class="col-sm-9">
<input type="text" data-toggle="tooltip" data-title="<?= T_('With restricted access, you should use 443 (TCP) or 53 (UDP)') ?>" class="form-control" name="server_port" id="server_port" placeholder="1194" value="<?= $server_port ?>" />
</div>
</div>
<div class="form-group">
<label for="server_port" class="col-sm-3 control-label"><?= T_('Protocol') ?></label>
<div class="btn-group col-sm-9" data-toggle="buttons">
<label class="btn btn-default <?= $server_proto == 'udp' ? 'active' : '' ?>">
<input type="radio" name="server_proto" value="udp" <?= $server_proto == 'udp' ? 'checked="cheked"' : '' ?> /> <?= T_('UDP') ?>
</label>
<label class="btn btn-default <?= $server_proto == 'tcp' ? 'active' : '' ?>" data-toggle="tooltip" data-title="<?= T_('UDP is more efficient than TCP (but more filtered in case of restrictive access)') ?>">
<input type="radio" name="server_proto" value="tcp" <?= $server_proto == 'tcp' ? 'checked="cheked"' : '' ?> /> <?= T_('TCP') ?>
</label>
</div>
</div>
<div class="form-group">
<label for="crt_client" class="col-sm-3 control-label"><?= T_('Update Client Cert.') ?></label>
<div class="input-group col-sm-9" style="padding: 0 15px">
<input id="crt_client" name="crt_client" type="file" style="display: none" />
<input type="text" class="form-control fileinput" id="crt_client_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
<a class="btn input-group-addon fileinput" id="crt_client_chooserbtn"><?= T_('Browse') ?></a>
</div>
</div>
<div class="form-group">
<label for="crt_client_key" class="col-sm-3 control-label"><?= T_('Update Client Cert. Key') ?></label>
<div class="input-group col-sm-9" style="padding: 0 15px">
<input id="crt_client_key" name="crt_client_key" type="file" style="display: none" />
<input type="text" class="form-control fileinput" id="crt_client_key_choosertxt" placeholder="-----BEGIN PRIVATE KEY-----" readonly="readonly" />
<a class="btn input-group-addon fileinput" id="crt_client_key_chooserbtn"><?= T_('Browse') ?></a>
</div>
</div>
<div class="form-group">
<label for="crt_server_ca" class="col-sm-3 control-label"><?= T_('Update Server CA') ?></label>
<div class="input-group col-sm-9" style="padding: 0 15px">
<input id="crt_server_ca" name="crt_server_ca" type="file" style="display: none" />
<input type="text" class="form-control fileinput" id="crt_server_ca_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
<a class="btn input-group-addon fileinput" id="crt_server_ca_chooserbtn"><?= T_('Browse') ?></a>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-3 col-sm-9">
<button type="submit" class="btn btn-default" data-toggle="tooltip" data-title="<?= T_('Reloading may take a few minutes. Be patient.') ?>"><?= T_('Save and reload') ?></button> <button type="submit" class="btn btn-default" data-toggle="tooltip" data-title="<?= T_('Reloading may take a few minutes. Be patient.') ?>"><?= T_('Save and reload') ?></button>
</div> </div>
</div> </div>