mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-21 23:50: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,15 +40,8 @@ func main() {
|
|||||||
// 1. update files
|
// 1. update files
|
||||||
Updater()
|
Updater()
|
||||||
// 2. start
|
// 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
|
return
|
||||||
}
|
}
|
||||||
log.Fatalf("wrong name")
|
log.Fatalf("wrong name")
|
||||||
|
|||||||
@ -26,7 +26,6 @@ export CGO_ENABLED=0
|
|||||||
#### Go: updater ####
|
#### Go: updater ####
|
||||||
pushd go/cmd/updater
|
pushd go/cmd/updater
|
||||||
[ "$GOOS" == "darwin" ] || go build -o $DEST -trimpath -ldflags "-w -s"
|
[ "$GOOS" == "darwin" ] || go build -o $DEST -trimpath -ldflags "-w -s"
|
||||||
[ "$GOOS" == "linux" ] && mv $DEST/updater $DEST/launcher || true
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#### Go: nekobox_core ####
|
#### Go: nekobox_core ####
|
||||||
|
|||||||
@ -23,15 +23,13 @@ cat >/usr/share/applications/nekoray.desktop<<-END
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=nekoray
|
Name=nekoray
|
||||||
Comment=Qt based cross-platform GUI proxy configuration manager (backend: sing-box)
|
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
|
Icon=/opt/nekoray/nekobox.png
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Network;Application;
|
Categories=Network;Application;
|
||||||
END
|
END
|
||||||
|
|
||||||
setcap cap_sys_admin=ep /opt/nekoray/launcher
|
|
||||||
|
|
||||||
update-desktop-database
|
update-desktop-database
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@ -402,11 +402,7 @@ namespace NekoGui {
|
|||||||
|
|
||||||
QString FindNekorayRealPath() {
|
QString FindNekorayRealPath() {
|
||||||
QString fn;
|
QString fn;
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
fn = QApplication::applicationDirPath() + "/launcher";
|
|
||||||
#else
|
|
||||||
fn = QApplication::applicationFilePath();
|
fn = QApplication::applicationFilePath();
|
||||||
#endif
|
|
||||||
auto fi = QFileInfo(fn);
|
auto fi = QFileInfo(fn);
|
||||||
if (fi.isSymLink()) return fi.symLinkTarget();
|
if (fi.isSymLink()) return fi.symLinkTarget();
|
||||||
return fn;
|
return fn;
|
||||||
|
|||||||
@ -74,11 +74,6 @@ int main(int argc, char* argv[]) {
|
|||||||
if (QFile::exists("updater.old")) {
|
if (QFile::exists("updater.old")) {
|
||||||
QFile::remove("updater.old");
|
QFile::remove("updater.old");
|
||||||
}
|
}
|
||||||
#ifndef Q_OS_WIN
|
|
||||||
if (!QFile::exists("updater")) {
|
|
||||||
QFile::link("launcher", "updater");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
NekoGui::dataStore->argv = QApplication::arguments();
|
NekoGui::dataStore->argv = QApplication::arguments();
|
||||||
|
|||||||
@ -170,17 +170,11 @@ void AutoRun_SetEnabled(bool enable) {
|
|||||||
QString desktopFileLocation = userAutoStartPath + appName + QLatin1String(".desktop");
|
QString desktopFileLocation = userAutoStartPath + appName + QLatin1String(".desktop");
|
||||||
QStringList appCmdList;
|
QStringList appCmdList;
|
||||||
|
|
||||||
// nekoray: launcher
|
|
||||||
if (qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1") {
|
|
||||||
appCmdList << QApplication::applicationDirPath() + "/launcher"
|
|
||||||
<< "--";
|
|
||||||
} else {
|
|
||||||
if (QProcessEnvironment::systemEnvironment().contains("APPIMAGE")) {
|
if (QProcessEnvironment::systemEnvironment().contains("APPIMAGE")) {
|
||||||
appCmdList << QProcessEnvironment::systemEnvironment().value("APPIMAGE");
|
appCmdList << QProcessEnvironment::systemEnvironment().value("APPIMAGE");
|
||||||
} else {
|
} else {
|
||||||
appCmdList << QApplication::applicationFilePath();
|
appCmdList << QApplication::applicationFilePath();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
appCmdList << "-tray";
|
appCmdList << "-tray";
|
||||||
|
|
||||||
|
|||||||
@ -696,9 +696,7 @@ void MainWindow::on_menu_exit_triggered() {
|
|||||||
arguments.removeAll("-flag_restart_tun_on");
|
arguments.removeAll("-flag_restart_tun_on");
|
||||||
arguments.removeAll("-flag_reorder");
|
arguments.removeAll("-flag_reorder");
|
||||||
}
|
}
|
||||||
auto isLauncher = qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1";
|
auto program = QApplication::applicationFilePath();
|
||||||
if (isLauncher) arguments.prepend("--");
|
|
||||||
auto program = isLauncher ? "./launcher" : QApplication::applicationFilePath();
|
|
||||||
|
|
||||||
if (exit_reason == 3 || exit_reason == 4) {
|
if (exit_reason == 3 || exit_reason == 4) {
|
||||||
if (exit_reason == 3) arguments << "-flag_restart_tun_on";
|
if (exit_reason == 3) arguments << "-flag_restart_tun_on";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user