This commit is contained in:
Mr Chen
2019-02-28 16:41:17 +08:00
parent 3365ab9a49
commit ac7fe66734
2 changed files with 4 additions and 91 deletions
-91
View File
@@ -32,16 +32,6 @@ def getInitDFile():
return '/etc/init.d/' + getPluginName()
def getConf():
path = getServerDir() + "/etc/pure-ftpd.conf"
return path
def getInitDTpl():
path = getPluginDir() + "/init.d/pure-ftpd.tpl"
return path
def getArgs():
args = sys.argv[2:]
tmp = {}
@@ -67,48 +57,8 @@ def status():
return 'start'
def contentReplace(content):
service_path = public.getServerDir()
content = content.replace('{$ROOT_PATH}', public.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path)
return content
def initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
# initd replace
if not os.path.exists(file_bin):
content = public.readFile(file_tpl)
content = contentReplace(content)
public.writeFile(file_bin, content)
public.execShell('chmod +x ' + file_bin)
pureSbinConfig = getServerDir() + "/sbin/pure-config.pl"
if not os.path.exists(pureSbinConfig):
pureTplConfig = getPluginDir() + "/init.d/pure-config.pl"
content = public.readFile(pureTplConfig)
content = contentReplace(content)
public.writeFile(pureSbinConfig, content)
public.execShell('chmod +x ' + pureSbinConfig)
pureFtpdConfig = getServerDir() + "/etc/pure-ftpd.conf"
pureFtpdConfigBak = getServerDir() + "/etc/pure-ftpd.bak.conf"
pureFtpdConfigTpl = getPluginDir() + "/conf/pure-ftpd.conf"
if not os.path.exists(pureFtpdConfigBak):
shutil.copyfile(pureFtpdConfig, pureFtpdConfigBak)
content = public.readFile(pureFtpdConfigTpl)
content = contentReplace(content)
public.writeFile(pureFtpdConfig, content)
return file_bin
@@ -144,41 +94,6 @@ def reload():
return data[1]
def initdStatus():
if not app_debug:
os_name = public.getOs()
if os_name == 'darwin':
return "Apple Computer does not support"
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
def initdInstall():
import shutil
if not app_debug:
os_name = public.getOs()
if os_name == 'darwin':
return "Apple Computer does not support"
source_bin = initDreplace()
initd_bin = getInitDFile()
shutil.copyfile(source_bin, initd_bin)
public.execShell('chmod +x ' + initd_bin)
return 'ok'
def initdUinstall():
if not app_debug:
os_name = public.getOs()
if os_name == 'darwin':
return "Apple Computer does not support"
initd_bin = getInitDFile()
os.remove(initd_bin)
return 'ok'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -191,11 +106,5 @@ if __name__ == "__main__":
print restart()
elif func == 'reload':
print reload()
elif func == 'initd_status':
print initdStatus()
elif func == 'initd_install':
print initdInstall()
elif func == 'initd_uninstall':
print initdUinstall()
else:
print 'error'
+4
View File
@@ -19,11 +19,15 @@ Install_l2tp()
mkdir -p $serverPath/l2tp
echo '1.0' > $serverPath/l2tp/version.pl
cp -rf scripts/l2tp.sh $serverPath/l2tp
if [ "Darwin" == "$SYSOS" ];then
echo 'macosx unavailable' > $install_tmp
exit 0
fi
#cp -rf $serverPath/l2tp
echo 'install complete' > $install_tmp
}