pull/143/head
midoks 3 years ago
parent e839bf4f8a
commit 2c7d17f001
  1. 6
      plugins/rsyncd/conf/lsyncd.conf
  2. 4
      plugins/rsyncd/index.html
  3. 75
      plugins/rsyncd/init.d/lsyncd.service.tpl
  4. 6
      plugins/rsyncd/install.sh
  5. 51
      plugins/rsyncd/js/rsyncd.js

@ -0,0 +1,6 @@
settings {
logfile = "{$SERVER_PATH}/rsyncd/lsyncd.log",
inotifyMode = "CloseWrite",
maxProcesses = 8,
statusFile = "{$SERVER_PATH}/rsyncd/lsyncd.status"
}

@ -3,8 +3,8 @@
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('rsyncd');">服务</p>
<p onclick="pluginInitD('rsyncd');">自启动</p>
<p onclick="rsyncdSend();">发送配置</p>
<p onclick="rsyncdReceive();">接收配置</p>
<p onclick="pluginLogs('rsyncd','','run_log');">日志</p>
<p onclick="rsRead()">说明</p>
</div>
<div class="bt-w-con pd15">
@ -15,7 +15,7 @@
<script type="text/javascript">
resetPluginWinWidth(700);
$.getScript( "/plugins/file?name=rsyncd&f=js/rsyncd.js", function() {
$.getScript("/plugins/file?name=rsyncd&f=js/rsyncd.js", function() {
pluginService('rsyncd');
});
</script>

@ -1,70 +1,9 @@
#!/bin/sh
# chkconfig: 2345 55 25
# description: rsyncd Service
[Unit]
Description=fast remote file copy program daemon
ConditionPathExists={$SERVER_PATH}/rsyncd/rsyncd.conf
### BEGIN INIT INFO
# Provides: rsyncd
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts rsyncd
# Description: starts the rsyncd
### END INIT INFO
ROOT_PATH={$SERVER_PATH}
p_start(){
isStart=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "Starting rsync... \c"
if [ -f /var/run/rsyncd.pid ]; then
rm -rf /var/run/rsyncd.pid
fi
/usr/bin/rsync --daemon --config=/etc/rsyncd.conf
sleep 0.3
isStart=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "\033[31mError: rsyncd service startup failed.\033[0m"
return;
fi
echo -e "\033[32mdone\033[0m"
else
echo "Starting rsyncd(pid $isStart) already running"
fi
}
p_stop(){
echo -e "Stopping rsyncd... \c";
pids=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}')
arr=($pids)
for p in ${arr[@]}
do
kill -9 $p
done
if [ -f /var/run/rsyncd.pid ]; then
rm -rf /var/run/rsyncd.pid
fi
echo -e "\033[32mdone\033[0m"
}
case "$1" in
start)
p_start
;;
stop)
p_stop
;;
restart|reload)
p_stop
sleep 0.3
p_start
;;
*)
echo "Please use start or stop as first argument"
;;
esac
[Service]
ExecStart={$LSYNC_BIN} --config={$SERVER_PATH}/rsyncd/lsyncd.conf --daemon --no-detach
[Install]
WantedBy=multi-user.target

@ -30,8 +30,9 @@ Install_rsyncd()
echo y | pacman -Sy rsync
echo y | pacman -Sy lsyncd
elif [[ "$OSNAME" == "macos" ]]; then
brew install rsync
brew install lsyncd
# brew install rsync
# brew install lsyncd
echo "ok"
else
yum install -y rsync
yum install -y lsyncd
@ -39,6 +40,7 @@ Install_rsyncd()
mkdir -p $serverPath/rsyncd
mkdir -p $serverPath/rsyncd/secrets
mkdir -p $serverPath/rsyncd/send
echo '2.0' > $serverPath/rsyncd/version.pl
echo '安装完成' > $install_tmp

@ -36,8 +36,57 @@ function rsPost(method,args,callback, title){
},'json');
}
///////////////// ----------------- 发送配置 ---------------- //////////////
function rsyncdSend(){
rsPost('rec_list', '', function(data){
var rdata = $.parseJSON(data.data);
if (!rdata.status){
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
return;
}
// console.log(rdata);
var list = rdata.data;
var con = '';
con += '<div style="padding-top:1px;">\
<button class="btn btn-success btn-sm" onclick="rsyncdConf();">创建发送任务</button>\
<button class="btn btn-success btn-sm" onclick="rsyncdLog();">创建本地同步</button>\
<button class="btn btn-success btn-sm" onclick="rsyncdLog();">日志</button>\
</div>';
con += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
con += '<thead><tr>';
con += '<th>服务名</th>';
con += '<th>路径</th>';
con += '<th>备注</th>';
con += '<th>操作(<a class="btlink" onclick="addReceive()">添加</a>)</th>';
con += '</tr></thead>';
con += '<tbody>';
//<a class="btlink" onclick="modReceive(\''+list[i]['name']+'\')">编辑</a>
for (var i = 0; i < list.length; i++) {
con += '<tr>'+
'<td>' + list[i]['name']+'</td>' +
'<td>' + list[i]['path']+'</td>' +
'<td>' + list[i]['comment']+'</td>' +
'<td>\
<a class="btlink" onclick="cmdReceive(\''+list[i]['name']+'\')">命令</a>\
| <a class="btlink" onclick="delReceive(\''+list[i]['name']+'\')">删除</a></td>\
</tr>';
}
con += '</tbody>';
con += '</table></div>';
$(".soft-man-con").html(con);
});
}
///////////////// ----------------- 接收配置 ---------------- //////////////
function rsyncdConf(){
rsPost('conf', {}, function(rdata){
rpath = rdata['data'];
@ -50,7 +99,7 @@ function rsyncdConf(){
}
function rsyncdLog(){
pluginStandAloneLogs("rsyncd","","run_log")
pluginStandAloneLogs("rsyncd","","run_log");
}

Loading…
Cancel
Save