fix(meowpanel): nyai 路径改固件内置 /usr/bin/nyai 优先+卡上旧路径回退(nyai_bin())— 修 /api/apps/*/export 500(nyai 已进固件,卡上 opt/bin 已清)
This commit is contained in:
1 parent
1d2496b38c
commit
366bf6bb5d
2 files changed
+13
-5
No files matched your search
Binary file not shown.
@@ -62,7 +62,8 @@
|
||||
#define LOGS_DIR "/usr/data/mnt/sd_0/MeowOS/logs"
|
||||
#define PERF_SOCK "/usr/data/meow_perf.sock"
|
||||
#define POWER_SOCK "/usr/data/meow_power.sock"
|
||||
#define NYAI_PATH "/usr/data/mnt/sd_0/MeowOS/opt/bin/nyai"
|
||||
#define NYAI_PATH "/usr/bin/nyai" /* 固件内置(权威) */
|
||||
#define NYAI_PATH_CARD "/usr/data/mnt/sd_0/MeowOS/opt/bin/nyai" /* 旧卡上路径(回退) */
|
||||
#define BOOT_DEFAULT_FILE "/data/meow_boot_default"
|
||||
#define VERSION_FILE "/etc/meowos_version"
|
||||
#define HOSTNAME_FILE ""
|
||||
@@ -2477,10 +2478,17 @@ static int multipart_extract_file(const req_t *r, const char *outpath)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *nyai_bin(void)
|
||||
{
|
||||
/* nyai 已进固件(/usr/bin,权威);旧版固件回退卡上 MeowOS/opt/bin */
|
||||
if (!access(NYAI_PATH, X_OK)) return NYAI_PATH;
|
||||
return NYAI_PATH_CARD;
|
||||
}
|
||||
|
||||
static int api_apps_install(int sock, const req_t *r)
|
||||
{
|
||||
if (!tf_present()) return send_err(sock, 503, "NO_CARD", "未识别到 TF 卡");
|
||||
if (!access(NYAI_PATH, X_OK)) { /* ok */ }
|
||||
if (access(nyai_bin(), X_OK) < 0) return send_err(sock, 500, "INTERNAL", "nyai 不可用(固件与卡上均无)");
|
||||
char mpkpath[1024];
|
||||
int ispath = 0;
|
||||
if (strncasecmp(r->content_type, "multipart/form-data", 19) != 0) {
|
||||
@@ -2507,7 +2515,7 @@ static int api_apps_install(int sock, const req_t *r)
|
||||
}
|
||||
if (access(mpkpath, R_OK) < 0) return send_err(sock, 404, "NOT_FOUND", ".mpk 文件不存在");
|
||||
char cmd[1400];
|
||||
snprintf(cmd, sizeof cmd, "PATH=/bin:/sbin:/usr/bin:/usr/sbin '%s' install '%s' 2>&1", NYAI_PATH, mpkpath);
|
||||
snprintf(cmd, sizeof cmd, "PATH=/bin:/sbin:/usr/bin:/usr/sbin '%s' install '%s' 2>&1", nyai_bin(), mpkpath);
|
||||
char out[4096];
|
||||
int code = run_cmd(cmd, out, sizeof out);
|
||||
if (code != 0) return send_err(sock, 422, "UNSUPPORTED", out[0] ? out : "nyai install 失败");
|
||||
@@ -2553,7 +2561,7 @@ static int api_apps_export(int sock, const char *pkg)
|
||||
snprintf(tmp, sizeof tmp, "%s/tmp/%s.mpk", TF_CARD_DIR, pkg);
|
||||
unlink(tmp);
|
||||
char cmd[1400];
|
||||
snprintf(cmd, sizeof cmd, "PATH=/bin:/sbin:/usr/bin:/usr/sbin '%s' export '%s' '%s' 2>&1", NYAI_PATH, pkg, tmp);
|
||||
snprintf(cmd, sizeof cmd, "PATH=/bin:/sbin:/usr/bin:/usr/sbin '%s' export '%s' '%s' 2>&1", nyai_bin(), pkg, tmp);
|
||||
char out[1024];
|
||||
int code = run_cmd(cmd, out, sizeof out);
|
||||
if (code != 0 || access(tmp, R_OK) < 0) return send_err(sock, 500, "INTERNAL", out[0] ? out : "nyai export 失败");
|
||||
@@ -2570,7 +2578,7 @@ static int api_apps_remove(int sock, const char *pkg, const req_t *r)
|
||||
if (r->query[0]) qparam(r->query, "purge", purgebuf, sizeof purgebuf);
|
||||
int use_purge = atoi(purgebuf);
|
||||
char cmd[1400];
|
||||
snprintf(cmd, sizeof cmd, "PATH=/bin:/sbin:/usr/bin:/usr/sbin '%s' remove '%s'%s 2>&1", NYAI_PATH, pkg, use_purge ? " --purge" : "");
|
||||
snprintf(cmd, sizeof cmd, "PATH=/bin:/sbin:/usr/bin:/usr/sbin '%s' remove '%s'%s 2>&1", nyai_bin(), pkg, use_purge ? " --purge" : "");
|
||||
char out[1024];
|
||||
int code = run_cmd(cmd, out, sizeof out);
|
||||
if (code != 0) return send_err(sock, 500, "INTERNAL", out[0] ? out : "nyai remove 失败");
|
||||
|
||||
Reference in new issue
Block a user