Skip to content

Commit d7ecb6f

Browse files
committed
Update nginx-watch.sh
1 parent 38d4e02 commit d7ecb6f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

nginx-watch.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
# USAGE: sh nginx-watch.sh
1111

1212
# Set NGINX directory
13-
dir=`dirname $0`
13+
# tar command already has the leading /
14+
dir='etc/nginx'
1415

1516
# Get initial checksum values
16-
checksum_initial=`tar -cf - $dir | md5sum | awk '{print $1}'`
17+
checksum_initial=$(tar --strip-components=2 -C / -cf - $dir | md5sum | awk '{print $1}')
1718
checksum_now=$checksum_initial
1819

1920
# Start nginx
@@ -24,7 +25,7 @@ nginx
2425
# the nginx configuration is tested and reloaded on success
2526
while true
2627
do
27-
checksum_now=`tar -cf - $dir | md5sum | awk '{print $1}'`
28+
checksum_now=$(tar --strip-components=2 -C / -cf - $dir | md5sum | awk '{print $1}')
2829

2930
if [ $checksum_initial != $checksum_now ]; then
3031
echo '[ NGINX ] A configuration file changed. Reloading...'

0 commit comments

Comments
 (0)