Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/l2tp/index.py

108 lines
1.9 KiB

6 years ago
# coding:utf-8
import sys
import io
import os
import time
import shutil
sys.path.append(os.getcwd() + "/class/core")
import public
app_debug = False
if public.isAppleSystem():
app_debug = True
def getPluginName():
6 years ago
return 'l2tp'
6 years ago
def getPluginDir():
return public.getPluginDir() + '/' + getPluginName()
def getServerDir():
return public.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def status():
6 years ago
cmd = "ps -ef|grep xl2tpd |grep -v grep | grep -v python | awk '{print $2}'"
6 years ago
data = public.execShell(cmd)
if data[0] == '':
return 'stop'
return 'start'
def start():
file = initDreplace()
data = public.execShell(file + ' start')
if data[1] == '':
return 'ok'
return data[1]
def stop():
file = initDreplace()
data = public.execShell(file + ' stop')
if data[1] == '':
return 'ok'
return data[1]
def restart():
6 years ago
return 'ok'
6 years ago
def reload():
6 years ago
return 'ok'
6 years ago
6 years ago
def getUserList():
data = []
return public.getJson(data)
6 years ago
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
6 years ago
elif func == 'user_list':
print getUserList()
elif func == 'add_user':
print addUser()
elif func == 'delete_user':
print ''
6 years ago
else:
print 'error'