fix: change command for enable/disable actions

This commit is contained in:
divocat
2025-10-15 13:11:29 +03:00
parent d51ac63c94
commit 46ec79e003
3 changed files with 26 additions and 7 deletions

View File

@@ -4,9 +4,10 @@ import { Podkop } from '../../types';
export async function callBaseMethod<T>(
method: Podkop.AvailableMethods,
args: string[] = [],
command: string = '/usr/bin/podkop',
): Promise<Podkop.MethodResponse<T>> {
const response = await executeShellCommand({
command: '/usr/bin/podkop',
command,
args: [method as string, ...args],
timeout: 10000,
});

View File

@@ -47,8 +47,18 @@ export const PodkopShellMethods = {
restart: async () => callBaseMethod<unknown>(Podkop.AvailableMethods.RESTART),
start: async () => callBaseMethod<unknown>(Podkop.AvailableMethods.START),
stop: async () => callBaseMethod<unknown>(Podkop.AvailableMethods.STOP),
enable: async () => callBaseMethod<unknown>(Podkop.AvailableMethods.ENABLE),
disable: async () => callBaseMethod<unknown>(Podkop.AvailableMethods.DISABLE),
enable: async () =>
callBaseMethod<unknown>(
Podkop.AvailableMethods.ENABLE,
[],
'/etc/init.d/podkop',
),
disable: async () =>
callBaseMethod<unknown>(
Podkop.AvailableMethods.DISABLE,
[],
'/etc/init.d/podkop',
),
globalCheck: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.GLOBAL_CHECK),
showSingBoxConfig: async () =>

View File

@@ -404,9 +404,9 @@ async function getConfigSections() {
}
// src/podkop/methods/shell/callBaseMethod.ts
async function callBaseMethod(method, args = []) {
async function callBaseMethod(method, args = [], command = "/usr/bin/podkop") {
const response = await executeShellCommand({
command: "/usr/bin/podkop",
command,
args: [method, ...args],
timeout: 1e4
});
@@ -496,8 +496,16 @@ var PodkopShellMethods = {
restart: async () => callBaseMethod(Podkop.AvailableMethods.RESTART),
start: async () => callBaseMethod(Podkop.AvailableMethods.START),
stop: async () => callBaseMethod(Podkop.AvailableMethods.STOP),
enable: async () => callBaseMethod(Podkop.AvailableMethods.ENABLE),
disable: async () => callBaseMethod(Podkop.AvailableMethods.DISABLE),
enable: async () => callBaseMethod(
Podkop.AvailableMethods.ENABLE,
[],
"/etc/init.d/podkop"
),
disable: async () => callBaseMethod(
Podkop.AvailableMethods.DISABLE,
[],
"/etc/init.d/podkop"
),
globalCheck: async () => callBaseMethod(Podkop.AvailableMethods.GLOBAL_CHECK),
showSingBoxConfig: async () => callBaseMethod(Podkop.AvailableMethods.SHOW_SING_BOX_CONFIG),
checkLogs: async () => callBaseMethod(Podkop.AvailableMethods.CHECK_LOGS)