Summary Files Commits Branches @commit @diff @stats
path: root / tools / watch-move-to-www.sh
blob: db120b8288aa67b57f05efb1beb893713dd47256 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

if ! type "inotifywait" > /dev/null; then
	echo "You'll need to install inotify-tools!"
fi

if [ "$EUID" -ne 0 ]; then
	echo "Please run as root!"
	exit
fi

DEFAULT_DIR="/var/www/devrix-job-board/"

if [ ! -d "$DEFAULT_DIR" ]; then
	mkdir $DEFAULT_DIR
	chown www-data:www-data $DEFAULT_DIR
fi

inotifywait -m ../src/ -r -e attrib -e create -e move -e delete |
	while read dir action file; do
		echo "[`date +"%Y-%m-%d %T"`] Updated folder"
		cp -R ../src/. $DEFAULT_DIR
		chown -R www-data:www-data $DEFAULT_DIR*
	done