Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let YUNOHOSTDOMAINS = [".noho.st",".ynh.fr",".nohost.me"]

$(document).ready(function() {

if (window.location.pathname != "/install") {
Expand Down Expand Up @@ -184,6 +186,25 @@ $(document).ready(function() {
};
};

function form_update_subscribe(){
var yunohost = false;
for (let i in YUNOHOSTDOMAINS){
if ($("#main_domain").val().endsWith(YUNOHOSTDOMAINS[i])){
yunohost = true;
}
}
var body = $(".subscribe-password-div")
if (yunohost){
body.show();
$("input", body).addClass("validate");
} else {
body.hide();
$("#domain_password").val("");
$("#domain_password_repeat").val("");
$("input", body).removeClass("validate");
}
}

function form_update_optional_section(name)
{
status_ = $("#enable_" + name)[0].checked;
Expand Down Expand Up @@ -232,6 +253,14 @@ $(document).ready(function() {
}
return true;
}
else if (id == "domain_password_repeat")
{
if (item.val() !== $("input[id='domain_password']").val())
{
return "nomatch";
}
return true;
}
};

function form_validate_item(item)
Expand All @@ -250,16 +279,22 @@ $(document).ready(function() {
item.siblings(".invalid-feedback").hide();
item.siblings(".invalid-feedback."+result).css("display", "");
item.addClass("is-invalid");
item.attr("aria-invalid","true");
item.attr("aria-errormessage",item.attr('id')+"_err"+result);
return false;
}
}

item.addClass("is-valid");
item.removeAttr("aria-invalid");
item.removeAttr("aria-errormessage");
return true;
}
else
{
item.addClass("is-invalid");
item.attr("aria-invalid","true");
item.attr("aria-errormessage",item.attr('id')+"_errdefault");
return false;
}
};
Expand Down Expand Up @@ -290,6 +325,9 @@ $(document).ready(function() {
$(".invalid-feedback").hide();
$(".invalid-feedback.default").css("display", "");

$("#main_domain").on("change",form_update_subscribe)
form_update_subscribe()

cube_input = $("input[id='cubefile']");
cube_input.change(form_update_cube_file_input);
if (cube_input.val())
Expand Down
Binary file modified doc/install1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions install_procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ def upgrade(install_params):

@step
def postinstall(install_params):
command = "yunohost tools postinstall --force-diskspace -d '{main_domain}' -p '{password}'".format(**install_params)
if install_params["use_dyndns_domain"] and len(install_params["domain_password"])>0:
command+=f" --subscribe {install_params['domain_password']}"

run_cmd(
"yunohost tools postinstall -d '{main_domain}' -p '{password}'".format(
**install_params
)
)
run_cmd(command)


@step
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Jinja2==2.11.3
MarkupSafe==1.1.1
pytz==2020.1
requests==2.24.0
urllib3==1.26.5
urllib3==1.24
Werkzeug==1.0.1
83 changes: 55 additions & 28 deletions templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,52 @@
{% block main %}
<form id="install_form" action="/" method="POST" novalidate class="mt-5">
<div class="row justify-content-center">
<div class="col-lg-8 col-sm-10 mb-3">
<div class="card">
<h4 class="card-header">{{ _("Server configuration") }}</h4>
<div class="alert alert-info card-header">
<i class="fa fa-info-circle" aria-hidden="true"></i>
{{ _("This is the domain that will be used to name and reach your internet cube. If you do not already own a domain name, you can pick a free domain ending with .nohost.me, .noho.st or .ynh.fr. It will automatically be configured during the setup.") }}
</div>
<div class="card-body">
<div class="form-group row">
<label for="main_domain" class="col-3 col-form-label">{{ _("Main domain") }}</label>
<div class="col-9">
<input type="text" class="validate form-control" name="main_domain" id="main_domain" placeholder="{{ _("myserver.nohost.me") }}" pattern="^([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+([^\W\d_]{2,})$">
<div class="invalid-feedback default">
{{ _("Please specify a valid domain") }}
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-8 col-sm-10 mb-3">
<div class="card">
<h4 class="card-header">{{ _("Server configuration") }}</h4>
<div class="alert alert-info card-header">
<i class="fa fa-info-circle" aria-hidden="true"></i>
{{ _("This is the domain that will be used to name and reach your internet cube. If you do not already own a domain name, you can pick a free domain ending with .nohost.me, .noho.st or .ynh.fr. It will automatically be configured during the setup.") }}
</div>
<div class="card-body">
<div class="form-group row">
<label for="main_domain" class="col-3 col-form-label">{{ _("Main domain") }}</label>
<div class="col-9">
<input type="text" class="validate form-control" name="main_domain" id="main_domain" placeholder="{{ _("myserver.nohost.me") }}" pattern="^([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+([^\W\d_]{2,})$">
<div class="invalid-feedback default" id="main_domain_errdefault">
{{ _("Please specify a valid domain") }}
</div>
</div>
</div>
<div class="subscribe-password-div">
<div class="form-group row">
<div class="alert alert-info card-header">
<i class="fa fa-info-circle" aria-hidden="true"></i>
{{ _("This kind of domain is freely provided by the YunoHost project. Please remember the password you enter, it will be used to keep control of the domain even if you loose control of your server.") }}
</div>
<label for="domain_password" class="col-3 col-form-label">{{ _("Domain password") }}</label>
<div class="col-9">
<input type="password" class="validate form-control" name="domain_password" id="domain_password" pattern="^.{12,}$">
<div class="invalid-feedback default" id="domain_password_errdefault">
{{ _("Passwords must be at least 12 characters") }}
</div>
</div>
</div>
<div class="form-group row">
<label for="domain_password_repeat" class="col-3 col-form-label">{{ _("Domain Password (repeat)") }}</label>
<div class="col-9">
<input type="password" class="validate form-control" name="domain_password_repeat" id="domain_password_repeat" pattern="^.{12,}$" custom-validation>
<div class="invalid-feedback default" id="domain_password_repeat_errdefault">
{{ _("Passwords must be at least 12 characters") }}
</div>
<div class="invalid-feedback nomatch" id="domain_password_repeat_errnomatch">
{{ _("Passwords do not match") }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="col-lg-8 col-sm-10 mb-3">
Expand All @@ -32,7 +59,7 @@ <h4 class="card-header">{{ _("First user (administrator)") }}</h4>
<label for="username" class="col-3 col-form-label">{{ _("Username") }}</label>
<div class="col-9">
<input type="text" class="validate form-control" name="username" id="username" placeholder="{{ _("sasha") }}" pattern="^[a-z0-9_]{3,}$">
<div class="invalid-feedback default">
<div class="invalid-feedback default" id="username_errdefault">
{{ _("Please specify a valid username with at least three characters (only lowercase, numbers or _)") }}
</div>
</div>
Expand All @@ -47,7 +74,7 @@ <h4 class="card-header">{{ _("First user (administrator)") }}</h4>
<label for="password" class="col-3 col-form-label">{{ _("Password") }}</label>
<div class="col-9">
<input type="password" class="validate form-control" name="password" id="password" pattern="^.{8,}$">
<div class="invalid-feedback default">
<div class="invalid-feedback default" id="password_errdefault">
{{ _("Passwords must be at least 8 characters") }}
</div>
</div>
Expand All @@ -56,10 +83,10 @@ <h4 class="card-header">{{ _("First user (administrator)") }}</h4>
<label for="password_repeat" class="col-3 col-form-label">{{ _("Password (repeat)") }}</label>
<div class="col-9">
<input type="password" class="validate form-control" name="password_repeat" id="password_repeat" pattern="^.{8,}$" custom-validation>
<div class="invalid-feedback default">
<div class="invalid-feedback default" id="password_repeat_errdefault">
{{ _("Passwords must be at least 8 characters") }}
</div>
<div class="invalid-feedback nomatch">
<div class="invalid-feedback nomatch" id="password_repeat_errnomatch">
{{ _("Passwords do not match") }}
</div>
</div>
Expand All @@ -86,10 +113,10 @@ <h4 class="card-header">
<div class="custom-file col-9">
<input type="file" class="validate custom-file-input" name="cubefile" id="cubefile" accept=".cube" custom-validation>
<label class="custom-file-label" for="cubefile">{{ _("Choose file") }}</label>
<div class="invalid-feedback default">
<div class="invalid-feedback default" id="cubefile_errdefault">
{{ _("You must provide a valid .cube file to enable the VPN") }}
</div>
<div class="invalid-feedback invalidjson">
<div class="invalid-feedback invalidjson" id="cubefile_errinvalidjson">
{{ _("Could not load this file as json ... Is it a valid .cube file ?") }}
</div>
</div>
Expand Down Expand Up @@ -121,7 +148,7 @@ <h4 class="card-header">
<label for="wifi_password" class="col-3 col-form-label">{{ _("Password") }}</label>
<div class="col-9">
<input type="password" class="validate form-control" name="wifi_password" id="wifi_password" pattern="^.{8,}$">
<div class="invalid-feedback default">
<div class="invalid-feedback default" id="wifi_password_errdefault">
{{ _("Passwords must be at least 8 characters") }}
</div>
</div>
Expand All @@ -130,10 +157,10 @@ <h4 class="card-header">
<label for="wifi_password_repeat" class="col-3 col-form-label">{{ _("Password (repeat)") }}</label>
<div class="col-9">
<input type="password" class="validate form-control" name="wifi_password_repeat" id="wifi_password_repeat" pattern="^.{8,}$" custom-validation>
<div class="invalid-feedback default">
<div class="invalid-feedback default" id="wifi_password_repeat_errdefault">
{{ _("Passwords must be at least 8 characters") }}
</div>
<div class="invalid-feedback nomatch">
<div class="invalid-feedback nomatch" id="wifi_password_repeat_errnomatch">
{{ _("Passwords do not match") }}
</div>
</div>
Expand Down