前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Syncthing 的简单使用

Syncthing 的简单使用

作者头像
一朵灼灼华
发布2022-08-05 21:16:45
1.1K0
发布2022-08-05 21:16:45
举报

前言

突然发现了一个不错的多端同步软件Syncthing,拿来用用

下载

地址:https://syncthing.net/downloads/ Github:https://github.com/syncthing/syncthing 或者:https://heanny.lanzoui.com/iV1tAplcnri (arm版本)

安装

以下为在树莓派中运行

直接解压 然后给予root权限,

代码语言:javascript
复制
shmod +x syncting

编辑配置文件

代码语言:javascript
复制
vim /root/.config/syncthing/config.xml

address标签修改监听端口和ip folder标签可以修改默认的地址,也可以在操作界面修改

启动。

代码语言:javascript
复制
./syncthing

开机启动

代码语言:javascript
复制
vi /etc/init.d/syncthing

编辑脚本

代码语言:javascript
复制
#!/bin/sh
### BEGIN INIT INFO
# Provides:          Syncthing
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Syncthing
# Description:       Syncthing is for backups
### END INIT INFO

. /lib/lsb/init-functions

DAEMON_NAME = syncthingTest               #随便起个名字
DAEMON_USER = root                        #登入树莓派的用户名,不用加双引号
DAEMON_PATH = /usr/syncthing/syncthing    #你执行程序的路径
DAEMON_OPTS = ""
DAEMON_PWD = "${PWD}"
DAEMON_DESC = $(get_lsb_header_val $0 "Short-Description")
DAEMON_PID = "/var/run/${DAEMON_NAME}.pid"
DAEMON_NICE=  0
DAEMON_LOG = '/var/log/syncthing'         #储存你日志的路径

[ -r "/etc/default/${DAEMON_NAME}" ] && . "/etc/default/${DAEMON_NAME}"

do_start() {
  local result

    pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
    if [ $? -eq 0 ]; then
        log_warning_msg "${DAEMON_NAME} is already started"
        result=0
    else
        log_daemon_msg "Starting ${DAEMON_DESC}" "${DAEMON_NAME}"
        touch "${DAEMON_LOG}"
        chown $DAEMON_USER "${DAEMON_LOG}"
        chmod u+rw "${DAEMON_LOG}"
        if [ -z "${DAEMON_USER}" ]; then
            start-stop-daemon --start --quiet --oknodo --background \
                --nicelevel $DAEMON_NICE \
                --chdir "${DAEMON_PWD}" \
                --pidfile "${DAEMON_PID}" --make-pidfile \
                --exec "${DAEMON_PATH}" -- $DAEMON_OPTS
            result=$?
        else
            start-stop-daemon --start --quiet --oknodo --background \
                --nicelevel $DAEMON_NICE \
                --chdir "${DAEMON_PWD}" \
                --pidfile "${DAEMON_PID}" --make-pidfile \
                --chuid "${DAEMON_USER}" \
                --exec "${DAEMON_PATH}" -- $DAEMON_OPTS
            result=$?
        fi
        log_end_msg $result
    fi
    return $result
}

do_stop() {
    local result

    pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
    if [ $? -ne 0 ]; then
        log_warning_msg "${DAEMON_NAME} is not started"
        result=0
    else
        log_daemon_msg "Stopping ${DAEMON_DESC}" "${DAEMON_NAME}"
        killproc -p "${DAEMON_PID}" "${DAEMON_PATH}"
        result=$?
        log_end_msg $result
        rm "${DAEMON_PID}"
    fi
    return $result
}

do_restart() {
    local result
    do_stop
    result=$?
    if [ $result = 0 ]; then
        do_start
        result=$?
    fi
    return $result
}

do_status() {
    local result
    status_of_proc -p "${DAEMON_PID}" "${DAEMON_PATH}" "${DAEMON_NAME}"
    result=$?
    return $result
}

do_usage() {
    echo $"Usage: $0 {start | stop | restart | status}"
    exit 1
}

case "$1" in
start)   do_start;   exit $? ;;
stop)    do_stop;    exit $? ;;
restart) do_restart; exit $? ;;
status)  do_status;  exit $? ;;
*)       do_usage;   exit  1 ;;
esac

配置

代码语言:javascript
复制
添加权限:chmod +x /etc/init.d/syncthing
添加默认启动:update-rc.d syncthing defaults
开机自动运行:update-rc.d syncthing remove

指令

代码语言:javascript
复制
service syncthing start
service syncthing stop
service syncthing restart
service syncthing status

或者

代码语言:javascript
复制
在syncthing根目录下
#命令执行后,下次开启将自动启动supervisor
systemctl enable syncthing
#下面的命令可以取消开机自启
systemctl disable syncthing

安卓手机同步

安装app

google play 安装界面
google play 安装界面

或者安装Syncthing Fork,据说比楼上好用

使用

配置共享文件夹

另一端就会有提示,邀请加入共享

点击确定后就会开始同步了

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-05-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 下载
  • 安装
    • 安卓手机同步
    • 使用
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档