From 85ce4dc4623a63f88c216fa5d1afd1a341d1b50d Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 5 Mar 2019 19:20:04 +0800 Subject: [PATCH] rsyncd --- plugins/rsyncd/ico.png | Bin 0 -> 235 bytes plugins/rsyncd/index.html | 20 +++++ plugins/rsyncd/index.py | 159 ++++++++++++++++++++++++++++++++++++ plugins/rsyncd/info.json | 15 ++++ plugins/rsyncd/install.sh | 33 ++++++++ plugins/rsyncd/js/rsyncd.js | 12 +++ 6 files changed, 239 insertions(+) create mode 100644 plugins/rsyncd/ico.png create mode 100755 plugins/rsyncd/index.html create mode 100755 plugins/rsyncd/index.py create mode 100755 plugins/rsyncd/info.json create mode 100755 plugins/rsyncd/install.sh create mode 100755 plugins/rsyncd/js/rsyncd.js diff --git a/plugins/rsyncd/ico.png b/plugins/rsyncd/ico.png new file mode 100644 index 0000000000000000000000000000000000000000..8dd3748bd2b066317f94150a7d9d3e94c8b2ce31 GIT binary patch literal 235 zcmVceHIE>Sd~&<7TRt5zL!bg&&PiHj6;66)Wf+>`x&OG$d6Z%dx+SRm_4 zCX)y%;6~OG+czL2${~oPCV~;a<%b|zHBo#Mj(ztX|NA67RI>4z%n6Qaz!7ERYi3xM zWmy&ga~j!$6LD~sKA9CV1@ty literal 0 HcmV?d00001 diff --git a/plugins/rsyncd/index.html b/plugins/rsyncd/index.html new file mode 100755 index 000000000..87149a87c --- /dev/null +++ b/plugins/rsyncd/index.html @@ -0,0 +1,20 @@ +
+
+
+

服务

+

自启动

+

配置修改

+

日志

+

说明

+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py new file mode 100755 index 000000000..5f06966ec --- /dev/null +++ b/plugins/rsyncd/index.py @@ -0,0 +1,159 @@ +# coding: utf-8 + +import time +import random +import os +import json +import re +import sys + +sys.path.append(os.getcwd() + "/class/core") +import public + +app_debug = False +if public.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'rsyncd' + + +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 checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, public.returnJson(True, 'ok')) + + +def status(): + data = public.execShell( + "ps -ef|grep smbd |grep -v grep | grep -v python | awk '{print $2}'") + if data[0] == '': + return 'stop' + return 'start' + + +def start(): + if public.isAppleSystem(): + return "Apple Computer does not support" + + data = public.execShell('systemctl start smb') + if data[1] == '': + return 'ok' + return 'fail' + + +def stop(): + if public.isAppleSystem(): + return "Apple Computer does not support" + data = public.execShell('systemctl stop smb') + if data[1] == '': + return 'ok' + return 'fail' + + +def restart(): + if public.isAppleSystem(): + return "Apple Computer does not support" + data = public.execShell('systemctl restart smb') + if data[1] == '': + return 'ok' + return 'fail' + + +def reload(): + if public.isAppleSystem(): + return "Apple Computer does not support" + + data = public.execShell('systemctl reload smb') + if data[1] == '': + return 'ok' + return 'fail' + + +def initdStatus(): + if public.isAppleSystem(): + return "Apple Computer does not support" + initd_bin = getInitDFile() + if os.path.exists(initd_bin): + return 'ok' + return 'fail' + + +def initdInstall(): + if public.isAppleSystem(): + 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 public.isAppleSystem(): + return "Apple Computer does not support" + + initd_bin = getInitDFile() + os.remove(initd_bin) + return 'ok' + + +def smbConf(): + return '/etc/samba/smb.conf' + +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() + elif func == 'initd_status': + print initdStatus() + elif func == 'initd_install': + print initdInstall() + elif func == 'initd_uninstall': + print initdUinstall() + elif func == 'conf': + print smbConf() + else: + print 'error' diff --git a/plugins/rsyncd/info.json b/plugins/rsyncd/info.json new file mode 100755 index 000000000..fa957ae07 --- /dev/null +++ b/plugins/rsyncd/info.json @@ -0,0 +1,15 @@ +{ + "id":3, + "title":"rsyncd", + "tip":"soft", + "name":"rsyncd", + "type":"软件", + "ps":"rsyncd同步助手", + "versions":"1.0", + "shell":"install.sh", + "checks":"server/rsyncd", + "author":"midoks", + "home":"https://rsync.samba.org/", + "date":"2019-03-05", + "pid":"4" +} \ No newline at end of file diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh new file mode 100755 index 000000000..8a74165f7 --- /dev/null +++ b/plugins/rsyncd/install.sh @@ -0,0 +1,33 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` + +install_tmp=${rootPath}/tmp/bt_install.pl +Install_rsyncd() +{ + echo '正在安装脚本文件...' > $install_tmp + mkdir -p $serverPath/rsyncd + echo '1.0' > $serverPath/rsyncd/version.pl + echo '安装完成' > $install_tmp + +} + +Uninstall_rsyncd() +{ + rm -rf $serverPath/rsyncd + echo "卸载完成" > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_rsyncd +else + Uninstall_rsyncd +fi diff --git a/plugins/rsyncd/js/rsyncd.js b/plugins/rsyncd/js/rsyncd.js new file mode 100755 index 000000000..fda380f8e --- /dev/null +++ b/plugins/rsyncd/js/rsyncd.js @@ -0,0 +1,12 @@ + + +function smbRead(){ + var readme = '
    '; + readme += '
  • mac上连接`cmd+k`
  • '; + readme += '
  • 不产生.DS_Store文件: defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  • '; + readme += '
  • windows上连接例子: \\192.168.1.194
  • '; + + readme += '
'; + + $('.soft-man-con').html(readme); +} \ No newline at end of file