Compare commits

...

13 Commits

7 changed files with 36 additions and 13 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Version>1.0.2.63</Version>
<Version>1.0.2.72</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup>
<ItemGroup>

View File

@ -208,12 +208,16 @@ namespace BTCPayServer.Controllers
}
catch (Exception ex)
{
ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid domain ({ex.Message})");
var messages = new List<object>();
messages.Add(ex.Message);
if (ex.InnerException != null)
messages.Add(ex.InnerException.Message);
ModelState.AddModelError(nameof(vm.DNSDomain), $"Invalid domain ({string.Join(", ", messages.ToArray())})");
return View(vm);
}
}
var error = RunSSH(vm, command, $"sudo bash -c '. /etc/profile.d/btcpay-env.sh && . changedomain.sh {vm.DNSDomain}'");
var error = RunSSH(vm, $"changedomain.sh {vm.DNSDomain}");
if (error != null)
return error;
@ -221,6 +225,13 @@ namespace BTCPayServer.Controllers
builder.Query = null;
StatusMessage = $"Domain name changing... the server will restart, please use \"{builder.Uri.AbsoluteUri}\"";
}
else if (command == "update")
{
var error = RunSSH(vm, $"btcpay-update.sh");
if (error != null)
return error;
StatusMessage = $"The server might restart soon if an update is available...";
}
else
{
return NotFound();
@ -239,8 +250,9 @@ namespace BTCPayServer.Controllers
return BadRequest();
}
private IActionResult RunSSH(MaintenanceViewModel vm, string command, string ssh)
private IActionResult RunSSH(MaintenanceViewModel vm, string ssh)
{
ssh = $"sudo bash -c '. /etc/profile.d/btcpay-env.sh && nohup {ssh} > /dev/null 2>&1 & disown'";
var sshClient = vm.CreateSSHClient(this.Request.Host.Host);
try
{
@ -270,7 +282,7 @@ namespace BTCPayServer.Controllers
{
try
{
Logs.PayServer.LogInformation("Running SSH command: " + command);
Logs.PayServer.LogInformation("Running SSH command: " + ssh);
var result = sshCommand.EndExecute(ar);
Logs.PayServer.LogInformation("SSH command executed: " + result);
}

View File

@ -1,6 +1,6 @@
@model BTCPayServer.Models.ServerViewModels.MaintenanceViewModel
@{
ViewData.SetActivePageAndTitle(ServerNavPages.Maintainance);
ViewData.SetActivePageAndTitle(ServerNavPages.Maintenance);
}
@ -13,7 +13,7 @@
<form method="post">
<div class="form-group">
<h5>SSH Settings</h5>
<span>You need SSH credentials to run any of those actions</span>
<span>For changing any settings, you need to enter your SSH credentials:</span>
</div>
<div class="form-group">
<label asp-for="UserName"></label>
@ -28,21 +28,31 @@
</div>
<div class="form-group">
<h5>Actions</h5>
<span>Run any of those administrative functions</span>
<h5>Change domain name</h5>
<span>You can change the domain name of your server by following <a href="https://github.com/btcpayserver/btcpayserver-doc/blob/master/ChangeDomain.md">this guide</a></span>
</div>
<div class="form-group">
<div class="input-group">
<input asp-for="DNSDomain" class="form-control" />
<span class="input-group-btn">
<button type="submit" class="btn btn-primary" name="command" value="changedomain" title="Change domain">
<button name="command" type="submit" class="btn btn-primary" value="changedomain" title="Change domain">
<span class="fa fa-check"></span> Confirm
</button>
</span>
</div>
<span asp-validation-for="DNSDomain" class="text-danger"></span>
</div>
<div class="form-group">
<h5>Update</h5>
<span>Click here to update your server</span>
</div>
<div class="form-group">
<div class="input-group">
<button name="command" type="submit" class="btn btn-primary" value="update">Update</button>
</div>
</div>
</form>
</div>
</div>

View File

@ -7,6 +7,6 @@ namespace BTCPayServer.Views.Server
{
public enum ServerNavPages
{
Index, Users, Rates, Emails, Policies, Theme, Hangfire, Services, Maintainance
Index, Users, Rates, Emails, Policies, Theme, Hangfire, Services, Maintenance
}
}

View File

@ -5,7 +5,7 @@
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Policies)" asp-action="Policies">Policies</a>
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Services)" asp-action="Services">Services</a>
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Theme)" asp-action="Theme">Theme</a>
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Maintainance)" asp-action="Maintenance">Maintenance</a>
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Maintenance)" asp-action="Maintenance">Maintenance</a>
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Hangfire)" href="~/hangfire" target="_blank">Hangfire</a>
</div>

View File

@ -15,7 +15,8 @@ ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
WORKDIR /app
# This should be removed soon https://github.com/dotnet/corefx/issues/30003
RUN apk add --no-cache curl
RUN mkdir /datadir
ENV BTCPAY_DATADIR=/datadir
VOLUME /datadir