Incorporate changes for version 1.1.0
This commit is contained in:
@@ -3,18 +3,46 @@
|
||||
|
||||
source /etc/openkiosk.conf
|
||||
|
||||
function set_commands() {
|
||||
source /etc/openkiosk.conf
|
||||
if [[ $TGT_URL == "test" ]]
|
||||
then
|
||||
# Enter test mode
|
||||
APP_CMD="xterm"
|
||||
ALIVE_STRING="xterm"
|
||||
KILL_CMD="pkill xterm"
|
||||
CLEANUP_CMD="sleep 1"
|
||||
debuglog "Entering test mode"
|
||||
elif echo "$TGT_URL" | grep -q '\.pdf$'
|
||||
then
|
||||
# The URL is a pdf file
|
||||
APP_CMD="viewpdf.sh $TGT_URL"
|
||||
ALIVE_STRING="xpdf"
|
||||
KILL_CMD="pkill xpdf"
|
||||
CLEANUP_CMD="kiosk_cleanup.sh"
|
||||
debuglog "URL is a pdf file. Command is $PDF_APP_CMD"
|
||||
else
|
||||
# Assume the URL returns HTML
|
||||
APP_CMD="viewhtml.sh $TGT_URL"
|
||||
ALIVE_STRING="chromium"
|
||||
KILL_CMD="pkill chromium"
|
||||
CLEANUP_CMD="kiosk_cleanup.sh"
|
||||
debuglog "URL is an HTML file. Command is $HTML_APP_CMD"
|
||||
fi
|
||||
}
|
||||
|
||||
function check_conf() {
|
||||
debuglog "Checking configuration file for changes."
|
||||
new_conf_md5=`md5sum /etc/openkiosk.conf|cut -d " " -f1`
|
||||
debuglog "New config file checksum: $new_conf_md5"
|
||||
curr_conf_md5=`cat /home/customer/curr_conf_md5.txt`
|
||||
curr_conf_md5=`cat /dev/shm/curr_conf_md5.txt`
|
||||
debuglog "Current config file checksum: $curr_conf_md5"
|
||||
diff <(echo $new_conf_md5) <(echo $curr_conf_md5) >/dev/null 2>&1
|
||||
if [ "$?" -eq "1" ]
|
||||
then
|
||||
debuglog "Config file has changed!"
|
||||
echo $new_conf_md5 > /home/customer/curr_conf_md5.txt
|
||||
debuglog "Killing browser"
|
||||
echo $new_conf_md5 > /dev/shm/curr_conf_md5.txt
|
||||
debuglog "Killing application"
|
||||
$KILL_CMD
|
||||
$CLEANUP_CMD
|
||||
return 1
|
||||
@@ -25,16 +53,29 @@ function check_conf() {
|
||||
|
||||
function check_url() {
|
||||
debuglog "Checking URL for changes"
|
||||
new_url_md5=`wget -q -o /dev/null -O - $TGT_URL|md5sum|cut -d " " -f1`
|
||||
if [[ $TGT_URL == "test" ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
if echo "$TGT_URL"|grep -q '^http'
|
||||
then
|
||||
new_url_md5=`wget -q -o /dev/null -O - $TGT_URL|md5sum|cut -d " " -f1`
|
||||
elif echo "$TGT_URL"|grep -q '^file'
|
||||
then
|
||||
filepath=$(echo "$TGT_URL"|cut -d":" -f2-)
|
||||
new_url_md5=`md5sum $filepath|cut -d " " -f1`
|
||||
else
|
||||
new_url_md5=""
|
||||
fi
|
||||
debuglog "New URL checksum: $new_url_md5"
|
||||
curr_url_md5=`cat /home/customer/curr_url_md5.txt`
|
||||
curr_url_md5=`cat /dev/shm/curr_url_md5.txt`
|
||||
debuglog "Current URL checksum: $curr_url_md5"
|
||||
diff <(echo $new_url_md5) <(echo $curr_url_md5) >/dev/null 2>&1
|
||||
if [ "$?" -eq "1" ]
|
||||
then
|
||||
debuglog "URL has changed!"
|
||||
echo $new_url_md5>/home/customer/curr_url_md5.txt
|
||||
debuglog "Killing browser"
|
||||
echo $new_url_md5>/dev/shm/curr_url_md5.txt
|
||||
debuglog "Killing application"
|
||||
$KILL_CMD
|
||||
$CLEANUP_CMD
|
||||
return 1
|
||||
@@ -46,11 +87,11 @@ function check_url() {
|
||||
function debuglog() {
|
||||
if [ "$DEBUG" -eq "1" ]
|
||||
then
|
||||
if [ ! -e "/home/customer/startkiosk.log" ]
|
||||
if [ ! -e "/home/kioskuser/startkiosk.log" ]
|
||||
then
|
||||
echo "startkiosk log started : "`date +%Y-%m-%d %H:%M:%S` > /home/customer/startkiosk.log
|
||||
echo "startkiosk log started : "`date +%Y-%m-%d %H:%M:%S` > /home/kioskuser/startkiosk.log
|
||||
fi
|
||||
echo `date +%H:%M:%S` "$1">>/home/customer/startkiosk.log
|
||||
echo `date +%H:%M:%S` "$1">>/home/kioskuser/startkiosk.log
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -68,24 +109,38 @@ function set_blank_params() {
|
||||
|
||||
function set_rot_params() {
|
||||
output_name=`xrandr --listactivemonitors|grep 0:|rev|cut -d " " -f1|rev`
|
||||
xrandr --output $output_name --rotate "normal"
|
||||
sleep 1
|
||||
xrandr --output $output_name --rotate $ROTATION
|
||||
}
|
||||
|
||||
set_commands
|
||||
openbox-session &
|
||||
sleep 1
|
||||
set_blank_params
|
||||
$KILL_CMD
|
||||
$CLEANUP_CMD
|
||||
pkill xpdf
|
||||
pkill chromium
|
||||
pkill xterm
|
||||
kiosk_cleanup.sh
|
||||
|
||||
# start application
|
||||
$APP_CMD &
|
||||
|
||||
$APP_CMD &
|
||||
sleep 3
|
||||
|
||||
new_url_md5=`wget -q -o /dev/null -O - $TGT_URL|md5sum|cut -d " " -f1`
|
||||
echo $new_url_md5>/home/customer/curr_url_md5.txt
|
||||
if echo "$TGT_URL"|grep -q '^http'
|
||||
then
|
||||
new_url_md5=`wget -q -o /dev/null -O - $TGT_URL|md5sum|cut -d " " -f1`
|
||||
elif echo "$TGT_URL"|grep -q '^file'
|
||||
then
|
||||
filepath=$(echo "$TGT_URL"|cut -d":" -f2-)
|
||||
new_url_md5=`md5sum $filepath|cut -d " " -f1`
|
||||
else
|
||||
new_url_md5=""
|
||||
fi
|
||||
echo $new_url_md5>/dev/shm/curr_url_md5.txt
|
||||
new_conf_md5=`md5sum /etc/openkiosk.conf|cut -d " " -f1`
|
||||
echo $new_conf_md5 > /home/customer/curr_conf_md5.txt
|
||||
echo $new_conf_md5 > /dev/shm/curr_conf_md5.txt
|
||||
|
||||
while true
|
||||
do
|
||||
@@ -98,7 +153,7 @@ source /etc/openkiosk.conf
|
||||
if ! pgrep $ALIVE_STRING
|
||||
then
|
||||
# relaunch application if it terminates
|
||||
debuglog "Restarting browser"
|
||||
debuglog "Restarting with command $APP_CMD"
|
||||
$APP_CMD &
|
||||
fi
|
||||
|
||||
@@ -106,11 +161,21 @@ if [ "$POLL_INTERVAL" -eq "0" ]
|
||||
then
|
||||
sleep 1
|
||||
debuglog "Polling not enabled"
|
||||
if ! check_conf; then set_blank_params;set_rot_params;fi
|
||||
if ! check_conf
|
||||
then
|
||||
set_blank_params
|
||||
set_rot_params
|
||||
set_commands
|
||||
fi
|
||||
else
|
||||
sleep $POLL_INTERVAL
|
||||
debuglog "Polling enabled"
|
||||
if ! check_conf; then set_blank_params;set_rot_params;fi
|
||||
if ! check_conf
|
||||
then
|
||||
set_blank_params
|
||||
set_rot_params
|
||||
set_commands
|
||||
fi
|
||||
check_url
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user