mirror of
				https://github.com/vvzvlad/vestasync.git
				synced 2025-11-04 07:17:54 +03:00 
			
		
		
		
	add inotify
This commit is contained in:
		
							
								
								
									
										9
									
								
								files/pushgit_inotify.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								files/pushgit_inotify.service
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=Script triggered by file changes in a folder (including subfolders)
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
ExecStart=/usr/local/bin/pushgit_inotify.sh
 | 
			
		||||
Restart=always
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
							
								
								
									
										12
									
								
								files/pushgit_inotify.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								files/pushgit_inotify.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
EXCLUDE_PATTERN='(^|/)(\.git($|/)|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
 | 
			
		||||
    export GIT_AUTHOR_NAME="vestasync_wb_$(hostname)_inotify"
 | 
			
		||||
    export GIT_COMMITTER_NAME="vestasync_wb_$(hostname)_inotify"
 | 
			
		||||
    cd /mnt/data/etc/
 | 
			
		||||
    git add .
 | 
			
		||||
    git commit -m "$(date)"
 | 
			
		||||
    git push -u origin master
 | 
			
		||||
done
 | 
			
		||||
@ -112,12 +112,20 @@ def create_autogit_systemd(c):
 | 
			
		||||
    c.put("./files/pushgit.sh", pushgit_script_path)
 | 
			
		||||
    c.run(f"chmod +x {pushgit_script_path}")
 | 
			
		||||
 | 
			
		||||
    pushgit_inotify_script_path = "/usr/local/bin/pushgit_inotify.sh"
 | 
			
		||||
    c.put("./files/pushgit.sh", pushgit_inotify_script_path)
 | 
			
		||||
    c.run(f"chmod +x {pushgit_inotify_script_path}")
 | 
			
		||||
 | 
			
		||||
    c.put("./files/pushgit.service", "/etc/systemd/system/pushgit.service")
 | 
			
		||||
    c.put("./files/pushgit.timer", "/etc/systemd/system/pushgit.timer")
 | 
			
		||||
 | 
			
		||||
    c.put("./files/pushgit_inotify.service", "/etc/systemd/system/pushgit_inotify.service")
 | 
			
		||||
 | 
			
		||||
    c.run("systemctl daemon-reload")
 | 
			
		||||
    c.run("systemctl enable pushgit.timer")
 | 
			
		||||
    c.run("systemctl start pushgit.timer")
 | 
			
		||||
    c.run("systemctl enable pushgit_inotify.service")
 | 
			
		||||
    c.run("systemctl start pushgit_inotify.service")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def git_clone(c):
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user