This commit is contained in:
2022-11-04 14:08:35 +02:00
parent 1c026e7f49
commit 9014d78a7d
3 changed files with 39 additions and 17 deletions

View File

@@ -8,7 +8,7 @@
<StartupObject /> <StartupObject />
<SignAssembly>False</SignAssembly> <SignAssembly>False</SignAssembly>
<IsPublishable>True</IsPublishable> <IsPublishable>True</IsPublishable>
<AssemblyVersion>1.0.1.1</AssemblyVersion> <AssemblyVersion>1.0.1.0</AssemblyVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@@ -386,23 +387,43 @@ public class Program
break; break;
} }
if (Functions.GetOperatingSystem() == OperatingSystem.WINDOWS) Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("A new version of the bot is available !");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Current version : " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("New version : " + newVersion);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Changelog :");
List<string> changeLog = await ServerCom.ReadTextFromURL("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/VersionData/DiscordBot");
foreach (var item in changeLog)
Utilities.WriteColorText(item);
Console.WriteLine("Do you want to update the bot ? (y/n)");
if (Console.ReadKey().Key == ConsoleKey.Y)
{ {
var url =
$"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0.zip";
Process.Start(".\\Updater\\Updater.exe", if (Functions.GetOperatingSystem() == OperatingSystem.WINDOWS)
$"{newVersion} {url} {Process.GetCurrentProcess().ProcessName}"); {
} var url =
else $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0.zip";
{ Process.Start(".\\Updater\\Updater.exe",
var url = $"{newVersion} {url} {Process.GetCurrentProcess().ProcessName}");
$"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip"; }
Settings.Variables.outputStream.WriteLine("Downloading update ..."); else
await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip"); {
await File.WriteAllTextAsync("Install.sh", var url =
"#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot"); $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip";
Process.Start("Install.sh").WaitForExit(); Settings.Variables.outputStream.WriteLine("Downloading update ...");
Environment.Exit(0); await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip");
await File.WriteAllTextAsync("Install.sh",
"#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot");
Process.Start("Install.sh").WaitForExit();
Environment.Exit(0);
}
} }
} }

View File

@@ -17,6 +17,7 @@ namespace PluginManager.Database
Connection = new SQLiteConnection(ConnectionString); Connection = new SQLiteConnection(ConnectionString);
} }
public async Task Open() public async Task Open()
{ {
await Connection.OpenAsync(); await Connection.OpenAsync();