mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
feat: Remove laucnher and fix deb
This commit is contained in:
parent
7b0c33cfc7
commit
eb2b6e3693
@ -1,12 +0,0 @@
|
||||
//go:build !linux
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func Launcher() {
|
||||
log.Fatalln("launcher is not for your platform", runtime.GOOS)
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var local_qt_theme bool
|
||||
|
||||
func Launcher() {
|
||||
log.Println("Running as launcher")
|
||||
wd, _ := filepath.Abs(".")
|
||||
|
||||
_debug := flag.Bool("debug", false, "Debug mode")
|
||||
flag.Parse()
|
||||
|
||||
cmd := exec.Command("./nekoray", flag.Args()...)
|
||||
|
||||
system_ld_env := os.Getenv("LD_LIBRARY_PATH")
|
||||
ld_env := "LD_LIBRARY_PATH="
|
||||
if len(system_ld_env) != 0 {
|
||||
ld_env += system_ld_env + ":"
|
||||
}
|
||||
ld_env += "/lib:/usr/lib:/lib64:/usr/lib/x86_64:/usr/local/Qt:/opt/Qt:"
|
||||
ld_env += filepath.Join(wd, "./usr/lib")
|
||||
|
||||
qt_plugin_env := "QT_PLUGIN_PATH="
|
||||
qt_plugin_env += filepath.Join(wd, "./usr/plugins")
|
||||
|
||||
// Qt 5.12 abi is usually compatible with system Qt 5.15
|
||||
// But use package Qt 5.12 by default.
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, "NKR_FROM_LAUNCHER=1")
|
||||
cmd.Env = append(cmd.Env, ld_env, qt_plugin_env)
|
||||
log.Println(ld_env, qt_plugin_env, cmd)
|
||||
|
||||
if *_debug {
|
||||
cmd.Env = append(cmd.Env, "QT_DEBUG_PLUGINS=1")
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
} else {
|
||||
cmd.Start()
|
||||
}
|
||||
}
|
||||
@ -40,16 +40,9 @@ func main() {
|
||||
// 1. update files
|
||||
Updater()
|
||||
// 2. start
|
||||
if os.Getenv("NKR_FROM_LAUNCHER") == "1" {
|
||||
Launcher()
|
||||
} else {
|
||||
exec.Command("./nekoray").Start()
|
||||
}
|
||||
exec.Command("./nekoray").Start()
|
||||
}
|
||||
return
|
||||
} else if strings.HasPrefix(strings.ToLower(exe), "launcher") {
|
||||
Launcher()
|
||||
return
|
||||
}
|
||||
log.Fatalf("wrong name")
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ export CGO_ENABLED=0
|
||||
#### Go: updater ####
|
||||
pushd go/cmd/updater
|
||||
[ "$GOOS" == "darwin" ] || go build -o $DEST -trimpath -ldflags "-w -s"
|
||||
[ "$GOOS" == "linux" ] && mv $DEST/updater $DEST/launcher || true
|
||||
popd
|
||||
|
||||
#### Go: nekobox_core ####
|
||||
|
||||
@ -23,15 +23,13 @@ cat >/usr/share/applications/nekoray.desktop<<-END
|
||||
[Desktop Entry]
|
||||
Name=nekoray
|
||||
Comment=Qt based cross-platform GUI proxy configuration manager (backend: sing-box)
|
||||
Exec=sudo /opt/nekoray/launcher
|
||||
Exec=sh -c "PATH=/opt/nekoray:\$PATH /opt/nekoray/nekoray -appdata"
|
||||
Icon=/opt/nekoray/nekobox.png
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Network;Application;
|
||||
END
|
||||
|
||||
setcap cap_sys_admin=ep /opt/nekoray/launcher
|
||||
|
||||
update-desktop-database
|
||||
EOF
|
||||
|
||||
|
||||
@ -402,11 +402,7 @@ namespace NekoGui {
|
||||
|
||||
QString FindNekorayRealPath() {
|
||||
QString fn;
|
||||
#ifdef Q_OS_LINUX
|
||||
fn = QApplication::applicationDirPath() + "/launcher";
|
||||
#else
|
||||
fn = QApplication::applicationFilePath();
|
||||
#endif
|
||||
auto fi = QFileInfo(fn);
|
||||
if (fi.isSymLink()) return fi.symLinkTarget();
|
||||
return fn;
|
||||
|
||||
@ -74,11 +74,6 @@ int main(int argc, char* argv[]) {
|
||||
if (QFile::exists("updater.old")) {
|
||||
QFile::remove("updater.old");
|
||||
}
|
||||
#ifndef Q_OS_WIN
|
||||
if (!QFile::exists("updater")) {
|
||||
QFile::link("launcher", "updater");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Flags
|
||||
NekoGui::dataStore->argv = QApplication::arguments();
|
||||
|
||||
@ -170,16 +170,10 @@ void AutoRun_SetEnabled(bool enable) {
|
||||
QString desktopFileLocation = userAutoStartPath + appName + QLatin1String(".desktop");
|
||||
QStringList appCmdList;
|
||||
|
||||
// nekoray: launcher
|
||||
if (qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1") {
|
||||
appCmdList << QApplication::applicationDirPath() + "/launcher"
|
||||
<< "--";
|
||||
if (QProcessEnvironment::systemEnvironment().contains("APPIMAGE")) {
|
||||
appCmdList << QProcessEnvironment::systemEnvironment().value("APPIMAGE");
|
||||
} else {
|
||||
if (QProcessEnvironment::systemEnvironment().contains("APPIMAGE")) {
|
||||
appCmdList << QProcessEnvironment::systemEnvironment().value("APPIMAGE");
|
||||
} else {
|
||||
appCmdList << QApplication::applicationFilePath();
|
||||
}
|
||||
appCmdList << QApplication::applicationFilePath();
|
||||
}
|
||||
|
||||
appCmdList << "-tray";
|
||||
|
||||
@ -696,9 +696,7 @@ void MainWindow::on_menu_exit_triggered() {
|
||||
arguments.removeAll("-flag_restart_tun_on");
|
||||
arguments.removeAll("-flag_reorder");
|
||||
}
|
||||
auto isLauncher = qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1";
|
||||
if (isLauncher) arguments.prepend("--");
|
||||
auto program = isLauncher ? "./launcher" : QApplication::applicationFilePath();
|
||||
auto program = QApplication::applicationFilePath();
|
||||
|
||||
if (exit_reason == 3 || exit_reason == 4) {
|
||||
if (exit_reason == 3) arguments << "-flag_restart_tun_on";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user