[1.0.7] Code cleanup and refactoring + Exposing two new methods "/ping" and "/version" in a new controller "/system".
parent
4e6586033e
commit
4063685a17
|
@ -1,7 +1,7 @@
|
|||
<Project>
|
||||
<Import Project="dependencies.props" />
|
||||
<PropertyGroup>
|
||||
<Version>1.0.3</Version>
|
||||
<Version>1.0.7</Version>
|
||||
<Authors>Tudor Stanciu</Authors>
|
||||
<Company>STA</Company>
|
||||
<PackageTags>NetworkResurrector</PackageTags>
|
||||
|
|
|
@ -5,17 +5,6 @@ VisualStudioVersion = 17.0.32014.148
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Server", "src\server\NetworkResurrector.Server\NetworkResurrector.Server.csproj", "{F6600491-5D79-4548-8745-59D9D337D3DB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FDDE879C-E0A3-4BF1-945F-7FEA324C8EBA}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.dockerignore = .dockerignore
|
||||
.gitattributes = .gitattributes
|
||||
.gitignore = .gitignore
|
||||
dependencies.props = dependencies.props
|
||||
Directory.Build.props = Directory.Build.props
|
||||
NuGet.config = NuGet.config
|
||||
ReleaseNotes.xml = ReleaseNotes.xml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Server.Application", "src\server\NetworkResurrector.Server.Application\NetworkResurrector.Server.Application.csproj", "{15D65D65-CC96-45DE-8590-AF9132889D98}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Server.Domain", "src\server\NetworkResurrector.Server.Domain\NetworkResurrector.Server.Domain.csproj", "{EC78E88E-22DC-4FFD-881E-DEECF0D2494E}"
|
||||
|
@ -40,16 +29,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Api.Doma
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Api.Domain.Data", "src\api\NetworkResurrector.Api.Domain.Data\NetworkResurrector.Api.Domain.Data.csproj", "{509767A7-D11C-4143-8D45-01E62DFC2C74}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{DF5CBFF4-B348-4D4C-A6D4-B65BA1D64CEF}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{C5096F61-7319-453B-AA28-7A1A854A6220}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build-amd64.sh = build-amd64.sh
|
||||
buildx-arm32.sh = buildx-arm32.sh
|
||||
buildx.sh = buildx.sh
|
||||
release.sh = release.sh
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent", "src\agent\NetworkResurrector.Agent\NetworkResurrector.Agent.csproj", "{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E}"
|
||||
|
@ -66,14 +45,35 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Server.P
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Api.PublishedLanguage", "src\api\NetworkResurrector.Api.PublishedLanguage\NetworkResurrector.Api.PublishedLanguage.csproj", "{1EA9EAD7-8896-4756-A2C2-7969E9073FA6}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "notes", "notes", "{6973CB33-B940-41B0-B3BB-22ED2ECB8E1D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent.Wrapper", "src\agent\NetworkResurrector.Agent.Wrapper\NetworkResurrector.Agent.Wrapper.csproj", "{3624DFF4-C692-42F8-BDC2-1C2107E6EDC8}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{C683E36F-A75F-4620-9D4F-2D73EE933AE1}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
notes\generic.txt = notes\generic.txt
|
||||
notes\nugets.txt = notes\nugets.txt
|
||||
notes\proxmox-shutdown-notes.txt = notes\proxmox-shutdown-notes.txt
|
||||
.dockerignore = .dockerignore
|
||||
.gitattributes = .gitattributes
|
||||
.gitignore = .gitignore
|
||||
dependencies.props = dependencies.props
|
||||
Directory.Build.props = Directory.Build.props
|
||||
NuGet.config = NuGet.config
|
||||
ReleaseNotes.xml = ReleaseNotes.xml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent.Wrapper", "src\agent\NetworkResurrector.Agent.Wrapper\NetworkResurrector.Agent.Wrapper.csproj", "{3624DFF4-C692-42F8-BDC2-1C2107E6EDC8}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{F92904AA-DC7A-4FD7-9807-3C5583C26D98}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{1AE7B305-E24D-48A3-A732-91DAAACA39D6}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
solution items\scripts\api\build-amd64.sh = solution items\scripts\api\build-amd64.sh
|
||||
solution items\scripts\api\buildx-arm32.sh = solution items\scripts\api\buildx-arm32.sh
|
||||
solution items\scripts\api\buildx.sh = solution items\scripts\api\buildx.sh
|
||||
solution items\scripts\api\release.sh = solution items\scripts\api\release.sh
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "notes", "notes", "{A28CE618-9D99-491A-8DCF-23D4A19E7750}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
solution items\notes\generic.txt = solution items\notes\generic.txt
|
||||
solution items\notes\nugets.txt = solution items\notes\nugets.txt
|
||||
solution items\notes\proxmox-shutdown-notes.txt = solution items\notes\proxmox-shutdown-notes.txt
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -170,8 +170,6 @@ Global
|
|||
{EE31B126-12EC-46B3-8FB4-AD5BCF14C029} = {43C78941-52E6-4AB8-9170-CC7C006E4784}
|
||||
{885D5625-028A-4B35-8C89-7EF718BC6E34} = {43C78941-52E6-4AB8-9170-CC7C006E4784}
|
||||
{509767A7-D11C-4143-8D45-01E62DFC2C74} = {43C78941-52E6-4AB8-9170-CC7C006E4784}
|
||||
{DF5CBFF4-B348-4D4C-A6D4-B65BA1D64CEF} = {FDDE879C-E0A3-4BF1-945F-7FEA324C8EBA}
|
||||
{C5096F61-7319-453B-AA28-7A1A854A6220} = {DF5CBFF4-B348-4D4C-A6D4-B65BA1D64CEF}
|
||||
{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302} = {B0C5F0C1-0BF8-4651-AAFC-BE01F516D7B8}
|
||||
{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E} = {C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}
|
||||
{3795AB02-7F2A-424B-BFD2-1B915E155829} = {C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}
|
||||
|
@ -180,8 +178,10 @@ Global
|
|||
{696DAC79-9C18-4DC3-9925-755AD6C1FEC9} = {6889D39C-D8DA-4B99-AFC1-F0B6355E73C0}
|
||||
{388D632D-8104-45E2-8017-D04848941F29} = {6889D39C-D8DA-4B99-AFC1-F0B6355E73C0}
|
||||
{1EA9EAD7-8896-4756-A2C2-7969E9073FA6} = {43C78941-52E6-4AB8-9170-CC7C006E4784}
|
||||
{6973CB33-B940-41B0-B3BB-22ED2ECB8E1D} = {FDDE879C-E0A3-4BF1-945F-7FEA324C8EBA}
|
||||
{3624DFF4-C692-42F8-BDC2-1C2107E6EDC8} = {C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}
|
||||
{F92904AA-DC7A-4FD7-9807-3C5583C26D98} = {C683E36F-A75F-4620-9D4F-2D73EE933AE1}
|
||||
{1AE7B305-E24D-48A3-A732-91DAAACA39D6} = {F92904AA-DC7A-4FD7-9807-3C5583C26D98}
|
||||
{A28CE618-9D99-491A-8DCF-23D4A19E7750} = {C683E36F-A75F-4620-9D4F-2D73EE933AE1}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {351D76E9-FE02-4C30-A464-7B29AFC64BC7}
|
||||
|
|
|
@ -29,4 +29,13 @@
|
|||
The system will be able to execute these operations in multiple ways. This is just the first one and all of them are handled by the NetworkResurrector.Api. For example, if the user wants to shutdown a clean Windows machine, he can use the agent and configure the API to call it, but in case of a proxmox machine, the API can be configured to execute a http request directly to the OS with the shutdown action (without the need for the agent).
|
||||
</Content>
|
||||
</Note>
|
||||
<Note>
|
||||
<Version>1.0.7</Version>
|
||||
<Content>
|
||||
Code cleanup and refactoring
|
||||
• Preparing to make the project open source on my Gitea instance.
|
||||
• Removed secrets from source code and from git history
|
||||
• Exposing two new methods "/ping" and "/version" in a new controller "/system".
|
||||
</Content>
|
||||
</Note>
|
||||
</ReleaseNotes>
|
22
buildx.sh
22
buildx.sh
|
@ -1,22 +0,0 @@
|
|||
#!/bin/bash
|
||||
echo "Welcome!"
|
||||
|
||||
#version="1.0.6"
|
||||
#platform="linux/amd64,linux/arm64"
|
||||
version="1.0.6-arm64"
|
||||
platform="linux/arm64"
|
||||
localRegistryPass="*********"
|
||||
|
||||
echo "Login to alpine-nexus registry."
|
||||
docker login --username=admin --password=$localRegistryPass alpine-nexus:8500
|
||||
|
||||
echo "Create docker image with version $version for platform $platform"
|
||||
docker buildx build \
|
||||
--build-arg APP_VERSION=$version \
|
||||
--platform $platform \
|
||||
--output=type=image,push=true,registry.insecure=true \
|
||||
--push \
|
||||
--tag alpine-nexus:8500/network-resurrector/network-resurrector-api:$version \
|
||||
-f "src/api/NetworkResurrector.Api/Docker/amd64/Dockerfile" .
|
||||
|
||||
echo "Done!"
|
|
@ -10,7 +10,7 @@
|
|||
<AutoMapperExtensionsPackageVersion>8.1.1</AutoMapperExtensionsPackageVersion>
|
||||
<MediatRPackageVersion>6.0.0</MediatRPackageVersion>
|
||||
<EntityFrameworkCorePackageVersion>5.0.12</EntityFrameworkCorePackageVersion>
|
||||
<NDBExtensionsSwaggerPackageVersion>1.0.2</NDBExtensionsSwaggerPackageVersion>
|
||||
<NDBExtensionsSwaggerPackageVersion>1.0.4</NDBExtensionsSwaggerPackageVersion>
|
||||
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion>
|
||||
<NDBSecurityAuthenticationPackageVersion>1.0.7</NDBSecurityAuthenticationPackageVersion>
|
||||
<NDBDatabaseMigrationPackageVersion>1.1.3</NDBDatabaseMigrationPackageVersion>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
echo "Welcome!"
|
||||
|
||||
version="1.0.7"
|
||||
platform="linux/amd64,linux/arm64"
|
||||
localRegistryPass="***********"
|
||||
databaseConnection="Server=#########;Database=#########;uid=#########;Password=#########;MultipleActiveResultSets=true"
|
||||
identityServerBaseAddress="http://<hostname>:<port>/"
|
||||
networkResurrectorServerBaseAddress="http://<hostname>:<port>/"
|
||||
|
||||
echo "Login to alpine-nexus registry."
|
||||
docker login --username=admin --password=$localRegistryPass alpine-nexus:8500
|
||||
|
||||
echo "Create docker image with version $version for platform $platform"
|
||||
docker buildx build \
|
||||
--build-arg APP_VERSION=$version \
|
||||
--build-arg DATABASE_CONNECTION=$databaseConnection \
|
||||
--build-arg IDENTITY_SERVER_BASE_ADDRESS=$identityServerBaseAddress \
|
||||
--build-arg NETWORK_RESURRECTOR_SERVER_BASE_ADDRESS=$networkResurrectorServerBaseAddress \
|
||||
--platform $platform \
|
||||
--output=type=image,push=true,registry.insecure=true \
|
||||
--push \
|
||||
--tag alpine-nexus:8500/network-resurrector/network-resurrector-api:$version \
|
||||
-f "src/api/NetworkResurrector.Api/Docker/amd64/Dockerfile" .
|
||||
|
||||
echo "Done!"
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/sh
|
||||
echo "Welcome!"
|
||||
|
||||
version="1.0.3"
|
||||
oldver="1.0.2"
|
||||
version="1.0.7"
|
||||
oldver="1.0.6"
|
||||
|
||||
echo "Pull docker image network-resurrector-api:$version from registry."
|
||||
docker pull alpine-nexus:8500/network-resurrector/network-resurrector-api:$version
|
|
@ -0,0 +1,47 @@
|
|||
using MediatR;
|
||||
using NDB.Application.DataContracts;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetworkResurrector.Api.Application.Queries
|
||||
{
|
||||
public class GetSystemVersion
|
||||
{
|
||||
public class Query : Query<Model>
|
||||
{
|
||||
public Query()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public record Model(string Version, DateTime LastUpdateDate);
|
||||
|
||||
public class QueryHandler : IRequestHandler<Query, Model>
|
||||
{
|
||||
public QueryHandler()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
|
||||
{
|
||||
var version = Environment.GetEnvironmentVariable("APP_VERSION");
|
||||
var appDate = Environment.GetEnvironmentVariable("APP_DATE");
|
||||
|
||||
if (string.IsNullOrEmpty(version))
|
||||
version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||
|
||||
if (!DateTime.TryParse(appDate, out var lastUpdateDate))
|
||||
{
|
||||
var location = Assembly.GetExecutingAssembly().Location;
|
||||
lastUpdateDate = File.GetLastWriteTime(location);
|
||||
}
|
||||
|
||||
var result = new Model(version, lastUpdateDate);
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NetworkResurrector.Api.Application.Queries;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IdentityServer.Api.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("system")]
|
||||
public class SystemController : ControllerBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public SystemController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("ping")]
|
||||
public IActionResult Ping()
|
||||
{
|
||||
return Ok($"Ping success. System datetime: {DateTime.Now}");
|
||||
}
|
||||
|
||||
[HttpGet("version")]
|
||||
public async Task<IActionResult> GetSystemVersion([FromRoute] GetSystemVersion.Query query)
|
||||
{
|
||||
var result = await _mediator.Send(query);
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,14 +27,17 @@ WORKDIR /app
|
|||
COPY --from=publish /app/publish .
|
||||
|
||||
ENV urls="http://*:80"
|
||||
ENV ConnectionStrings__DatabaseConnection="*********"
|
||||
ENV IdentityServer__BaseAddress="*********"
|
||||
ENV NetworkResurrectorServer__BaseAddress="*********"
|
||||
ENV TZ=Europe/Bucharest
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
ARG APP_VERSION=0.0.0.0
|
||||
ENV APP_VERSION=${APP_VERSION}
|
||||
ARG DATABASE_CONNECTION=""
|
||||
ENV ConnectionStrings__DatabaseConnection=${DATABASE_CONNECTION}
|
||||
ARG IDENTITY_SERVER_BASE_ADDRESS=""
|
||||
ENV IdentityServer__BaseAddress=${IDENTITY_SERVER_BASE_ADDRESS}
|
||||
ARG NETWORK_RESURRECTOR_SERVER_BASE_ADDRESS=""
|
||||
ENV NetworkResurrectorServer__BaseAddress=${NETWORK_RESURRECTOR_SERVER_BASE_ADDRESS}
|
||||
|
||||
#Workaround to lower the TLS level in container for old sql server version
|
||||
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue