This commit is contained in:
2025-08-28 17:33:19 +08:00
parent 77729f0328
commit c6c0378dc6
3 changed files with 14 additions and 12 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ plugins {
} }
group = "xyz.thewhitedog9487" group = "xyz.thewhitedog9487"
version = "0.5.1" version = "0.5.2"
java { java {
toolchain { toolchain {
@@ -23,7 +23,7 @@ class OpenAPIConfiguration {
.contact(new Contact() .contact(new Contact()
.name("TheWhiteDog9487") .name("TheWhiteDog9487")
.url("https://www.github.com/TheWhiteDog9487/WebAPI")) .url("https://www.github.com/TheWhiteDog9487/WebAPI"))
.version("0.5.1") .version("0.5.2")
.license(new License() .license(new License()
.name("WTFPL") .name("WTFPL")
.url("https://spdx.org/licenses/WTFPL")) ) .url("https://spdx.org/licenses/WTFPL")) )
@@ -5,10 +5,11 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
@@ -35,10 +36,13 @@ class SystemdInstallerManager implements CommandLineRunner {
"""; """;
@Autowired ObjectProvider<GatewayDiscordClient> DiscordClientProvider; @Autowired ObjectProvider<GatewayDiscordClient> DiscordClientProvider;
ApplicationHome AppHome = new ApplicationHome( SystemdInstallerManager.class );
String CurrentOS = System.getProperty("os.name"); String CurrentOS = System.getProperty("os.name");
String CurrentUser = System.getProperty("user.name"); String CurrentUser = System.getProperty("user.name");
Path CurrentExecutableFilePath = GetExecutblePath(); Path CurrentExecutableFilePath = GetExecutblePath();
Path WorkingDirectory = CurrentExecutableFilePath.getParent(); Path WorkingDirectory = AppHome
.getDir()
.toPath();
Path ServiceFileDirectory = Path.of("/etc/systemd/system/"); Path ServiceFileDirectory = Path.of("/etc/systemd/system/");
Path ServiceFileName = Path.of("WebAPI.service"); Path ServiceFileName = Path.of("WebAPI.service");
String SoftLinkFileName = "Current"; String SoftLinkFileName = "Current";
@@ -73,20 +77,18 @@ class SystemdInstallerManager implements CommandLineRunner {
log.debug("ExecutablePath: {}", ExecutablePath); log.debug("ExecutablePath: {}", ExecutablePath);
return Path.of((String) ExecutablePath); } return Path.of((String) ExecutablePath); }
else{ else{
log.debug("IsImageCode is false");
// 没有错误但是获取Jar包位置的代码在catch里面扔一个异常出去以进入catch分支 // 没有错误但是获取Jar包位置的代码在catch里面扔一个异常出去以进入catch分支
// 这个主要是针对使用GraalVM的JVM而不是Native Image的情况 // 这个主要是针对使用GraalVM的JVM而不是Native Image的情况
throw new RuntimeException("Not Image Code"); } throw new RuntimeException("Not Image Code"); }
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException | } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException |
RuntimeException e) { RuntimeException e) {
try { try {
return Path.of(SystemdInstallerManager.class return AppHome
.getProtectionDomain() .getSource()
.getCodeSource() .toPath()
.getLocation() .toRealPath();
.toURI()); } catch (IOException ex) {
} catch (URISyntaxException ex) { throw new RuntimeException(ex); } } }
throw new RuntimeException(ex);}}}
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {