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>( export async function callBaseMethod<T>(
method: Podkop.AvailableMethods, method: Podkop.AvailableMethods,
args: string[] = [], args: string[] = [],
command: string = '/usr/bin/podkop',
): Promise<Podkop.MethodResponse<T>> { ): Promise<Podkop.MethodResponse<T>> {
const response = await executeShellCommand({ const response = await executeShellCommand({
command: '/usr/bin/podkop', command,
args: [method as string, ...args], args: [method as string, ...args],
timeout: 10000, timeout: 10000,
}); });

View File

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

View File

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