From 2ad8d0938ddce02d7c399631cdb1d4659e38a579 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Mon, 12 Feb 2024 17:51:25 +0900 Subject: [PATCH 1/3] Deploy the script to rsync and enable lsyncd. --- .../kazu634/files/home/kazu634/works/rsync.sh | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 cookbooks/kazu634/files/home/kazu634/works/rsync.sh diff --git a/cookbooks/kazu634/files/home/kazu634/works/rsync.sh b/cookbooks/kazu634/files/home/kazu634/works/rsync.sh new file mode 100755 index 0000000..1e79f2a --- /dev/null +++ b/cookbooks/kazu634/files/home/kazu634/works/rsync.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +CONF=/etc/lsyncd/lsyncd.conf.lua + +if [ ! -d mnt/ ]; then + mkdir -p mnt/ + + rsync -arv kazu634@192.168.10.200:/volume1/homes/kazu634/Drive/Shared/project/ mnt/ +fi + +if [ ! -e ${CONF} ]; then + sudo cp ./lsyncd.conf.lua ${CONF} + sudo chown root:root ${CONF} + sudo chmod 644 ${CONF} + + sudo systemctl enable lsyncd.service + sudo systemctl restart lsyncd.service +fi + +exit $? -- 2.40.1 From 8df5e02c18f0d7c52ee6e7f6a6bb5ab18269aea9 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Mon, 12 Feb 2024 18:08:32 +0900 Subject: [PATCH 2/3] Deploy `/etc/lsyncd/lsyncd.conf.lua`. --- .../files/home/kazu634/works/lsyncd.conf.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cookbooks/kazu634/files/home/kazu634/works/lsyncd.conf.lua diff --git a/cookbooks/kazu634/files/home/kazu634/works/lsyncd.conf.lua b/cookbooks/kazu634/files/home/kazu634/works/lsyncd.conf.lua new file mode 100644 index 0000000..7f63d9b --- /dev/null +++ b/cookbooks/kazu634/files/home/kazu634/works/lsyncd.conf.lua @@ -0,0 +1,16 @@ +settings { + logfile = "/var/log/lsyncd/lsyncd.log", + statusFile = "/var/log/lsyncd/lsyncd.status", + statusInterval = 20, + nodaemon = false +} + +sync { + default.rsync, + source = "/home/kazu634/works/mnt/", + target = "kazu634@192.168.10.200:/volume1/homes/kazu634/Drive/Shared/project/", + rsync = { + archive = true, + compress = true + } +} -- 2.40.1 From 9a699f2d5911da98b98560a3c7129165e8c4aee5 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Mon, 12 Feb 2024 17:52:23 +0900 Subject: [PATCH 3/3] Itamae code to deploy the files. --- cookbooks/kazu634/kazu634.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cookbooks/kazu634/kazu634.rb b/cookbooks/kazu634/kazu634.rb index 9f8ea3d..8f6c2e8 100644 --- a/cookbooks/kazu634/kazu634.rb +++ b/cookbooks/kazu634/kazu634.rb @@ -79,3 +79,12 @@ remote_file '/etc/cron.d/remove_tmp' do group 'root' mode '644' end + +# Deploy `~/works/rsync.sh`: +%w( rsync.sh lsyncd.conf.lua ).each do |file| + remote_file "/home/kazu634/works/#{file}" do + owner 'kazu634' + group 'kazu634' + mode '755' + end +end -- 2.40.1