#!/bin/bash

log_file_path=/var/log/phddns/phtunnel.log
log_file_size=0

[ -f $log_file_path ] && {
	log_file_size=$(ls -l $log_file_path | awk {'print $5'})
}

if [ $log_file_size -gt 0 ]; then

	echo "HTTP/1.1 200 OK
Cache-Control: max-age=86400
Connection: keep-alive
Content-Type: text/plain;charset=utf-8
Date: Wed, 16 Dec 2020 12:06:05 GMT
Expires: Thu, 17 Dec 2020 12:06:05 GMT
Content-Length: $log_file_size
"
	cat $log_file_path
else
	echo "HTTP/1.1 200 OK
Cache-Control: max-age=86400
Connection: keep-alive
Content-Type: text/plain;charset=utf-8
Date: Wed, 16 Dec 2020 12:06:05 GMT
Expires: Thu, 17 Dec 2020 12:06:05 GMT
Content-Length: 48

<html><title>not found</title><body>log file is not exist</body>"

fi
