mirror of
https://github.com/vvzvlad/vestasync.git
synced 2025-08-21 12:37:53 +03:00
refactoting services and remove upload by timer
This commit is contained in:
7
files/pushgit/pushgit.sh
Normal file
7
files/pushgit/pushgit.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
apt-mark showmanual > /mnt/data/etc/vestasync/packages
|
||||
echo $(hostname) > /mnt/data/etc/vestasync/hostname
|
||||
cd /mnt/data/etc/
|
||||
git add .
|
||||
git commit -m "$(date +"%Y-%m-%d %H:%M:%S %z %Z")"
|
||||
git push -u origin master
|
9
files/pushgit/pushgit_inotify.service
Normal file
9
files/pushgit/pushgit_inotify.service
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Main pushgit
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/pushgit_inotify.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
12
files/pushgit/pushgit_inotify.sh
Normal file
12
files/pushgit/pushgit_inotify.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
export GIT_AUTHOR_NAME="vestasync_wb_$(hostname)"
|
||||
export GIT_COMMITTER_NAME="vestasync_wb_$(hostname)"
|
||||
export LC_TIME=en_GB.UTF-8
|
||||
EXCLUDE_PATTERN='(^|\/)(\.git|packages|hostname|wb-mqtt-mbgate\.conf|resolv\.conf)($|\/)'
|
||||
inotifywait -m -r -e close_write,move,create,delete --exclude "$EXCLUDE_PATTERN" --format '%w%f' /mnt/data/etc | while read FILE
|
||||
do
|
||||
/usr/local/bin/pushgit.sh
|
||||
done
|
||||
|
||||
|
||||
|
12
files/pushgit/pushgit_inotify_special.service
Normal file
12
files/pushgit/pushgit_inotify_special.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Script triggered by file changes in a folder (including subfolders)
|
||||
|
||||
[Service]
|
||||
ExecStartPre=systemctl stop pushgit_inotify.service
|
||||
ExecStart=systemctl start pushgit_inotify.service
|
||||
ExecStop=systemctl stop pushgit_inotify.service
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
9
files/pushgit/pushgit_run_on_start.timer
Normal file
9
files/pushgit/pushgit_run_on_start.timer
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run pushgit.service on start
|
||||
|
||||
[Timer]
|
||||
OnBootSec=180
|
||||
Unit=pushgit_inotify_special.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Reference in New Issue
Block a user