mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Added option to use --intranet
to not download or update any files,… (#3350)
* Added option to use `--intranet` to not download or update any files, this can only be done after an initial run. * Dropped some unneeded debug changes that I commited by accident * Added conventional suggestions from Github.com comments --------- Co-authored-by: Jean-Paul van Houten - Bos <jeanpaul.vhouten@koop.overheid.nl>
This commit is contained in:
parent
42bba73ffe
commit
fd90828914
2 changed files with 72 additions and 53 deletions
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
@ -28,9 +28,15 @@ namespace UptimeKuma {
|
||||||
Environment.CurrentDirectory = cwd;
|
Environment.CurrentDirectory = cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isIntranet = args.Contains("--intranet");
|
||||||
|
|
||||||
|
if (isIntranet) {
|
||||||
|
Console.WriteLine("The --intranet argument was provided, so we will not try to access the internet. The first time this application runs you'll need to run it without the --intranet param or copy the result from another machine to the intranet server.");
|
||||||
|
}
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new UptimeKumaApplicationContext());
|
Application.Run(new UptimeKumaApplicationContext(isIntranet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +55,9 @@ namespace UptimeKuma {
|
||||||
|
|
||||||
private RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
|
private RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
|
||||||
|
|
||||||
|
private readonly bool intranetOnly;
|
||||||
|
|
||||||
public UptimeKumaApplicationContext() {
|
public UptimeKumaApplicationContext(bool intranetOnly) {
|
||||||
|
|
||||||
// Single instance only
|
// Single instance only
|
||||||
bool createdNew;
|
bool createdNew;
|
||||||
|
@ -59,6 +66,8 @@ namespace UptimeKuma {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.intranetOnly = intranetOnly;
|
||||||
|
|
||||||
var startingText = "Starting server...";
|
var startingText = "Starting server...";
|
||||||
trayIcon = new NotifyIcon();
|
trayIcon = new NotifyIcon();
|
||||||
trayIcon.Text = startingText;
|
trayIcon.Text = startingText;
|
||||||
|
@ -98,6 +107,10 @@ namespace UptimeKuma {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadFiles() {
|
void DownloadFiles() {
|
||||||
|
if (intranetOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var form = new DownloadForm();
|
var form = new DownloadForm();
|
||||||
form.Closed += Exit;
|
form.Closed += Exit;
|
||||||
form.Show();
|
form.Show();
|
||||||
|
@ -173,7 +186,9 @@ namespace UptimeKuma {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckForUpdate(object sender, EventArgs e) {
|
void CheckForUpdate(object sender, EventArgs e) {
|
||||||
var needUpdate = false;
|
if (intranetOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check version.json exists
|
// Check version.json exists
|
||||||
if (File.Exists("version.json")) {
|
if (File.Exists("version.json")) {
|
||||||
|
@ -204,8 +219,12 @@ namespace UptimeKuma {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisitGitHub(object sender, EventArgs e)
|
void VisitGitHub(object sender, EventArgs e) {
|
||||||
{
|
if (intranetOnly) {
|
||||||
|
MessageBox.Show("You have parsed in --intranet so we will not try to access the internet or visit github.com, please go to https://github.com/louislam/uptime-kuma if you want to visit github.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Process.Start("https://github.com/louislam/uptime-kuma");
|
Process.Start("https://github.com/louislam/uptime-kuma");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="packages\Costura.Fody.5.7.0\build\Costura.Fody.props" Condition="Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" />
|
<Import Project="packages\Costura.Fody.5.7.0\build\Costura.Fody.props" Condition="Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
|
Loading…
Reference in a new issue