cleanups
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
#!/bin/bash
|
||||
# kiosk_startkiosk
|
||||
|
||||
source /etc/openkiosk.conf
|
||||
if [[ "$EUID" == "0" || $(who|cut -d" " -f1) == "kioskuser" ]]
|
||||
then
|
||||
conf_file="/etc/openkiosk.conf"
|
||||
run_type="standalone"
|
||||
else
|
||||
if [[ ! -e "$HOME/.config/openkiosk/openkiosk.conf" ]]
|
||||
then
|
||||
mkdir -p $HOME/.config/openkiosk
|
||||
cp /etc/openkiosk.conf $HOME/.config/openkiosk/
|
||||
fi
|
||||
conf_file="$HOME/.config/openkiosk/openkiosk.conf"
|
||||
run_type="workstation"
|
||||
fi
|
||||
if [[ ! -e "$conf_file" ]]
|
||||
then
|
||||
echo "Couldn't find config file. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source $conf_file
|
||||
|
||||
|
||||
function set_commands() {
|
||||
source /etc/openkiosk.conf
|
||||
source $conf_file
|
||||
if [[ $TGT_URL == "test" ]]
|
||||
then
|
||||
# Enter test mode
|
||||
@@ -16,29 +36,29 @@ function set_commands() {
|
||||
elif echo "$TGT_URL" | grep -q '\.pdf$'
|
||||
then
|
||||
# The URL is a pdf file
|
||||
APP_CMD="viewpdf.sh $TGT_URL"
|
||||
APP_CMD="kiosk_viewpdf $TGT_URL"
|
||||
ALIVE_STRING="xpdf"
|
||||
KILL_CMD="pkill xpdf"
|
||||
CLEANUP_CMD="kiosk_cleanup.sh"
|
||||
CLEANUP_CMD="kiosk_cleanup"
|
||||
debuglog "URL is a pdf file. Command is $PDF_APP_CMD"
|
||||
else
|
||||
# Assume the URL returns HTML
|
||||
APP_CMD="viewhtml.sh $TGT_URL"
|
||||
APP_CMD="kiosk_viewhtml $TGT_URL"
|
||||
ALIVE_STRING="chromium"
|
||||
KILL_CMD="pkill chromium"
|
||||
CLEANUP_CMD="kiosk_cleanup.sh"
|
||||
CLEANUP_CMD="kiosk_cleanup"
|
||||
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`
|
||||
new_conf_md5=$(md5sum $conf_file|cut -d " " -f1)
|
||||
debuglog "New config file checksum: $new_conf_md5"
|
||||
curr_conf_md5=`cat /dev/shm/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" ]
|
||||
if [[ "$?" == "1" ]]
|
||||
then
|
||||
debuglog "Config file has changed!"
|
||||
echo $new_conf_md5 > /dev/shm/curr_conf_md5.txt
|
||||
@@ -59,19 +79,19 @@ function check_url() {
|
||||
fi
|
||||
if echo "$TGT_URL"|grep -q '^http'
|
||||
then
|
||||
new_url_md5=`wget -q -o /dev/null -O - $TGT_URL|md5sum|cut -d " " -f1`
|
||||
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`
|
||||
new_url_md5=$(md5sum $filepath|cut -d " " -f1)
|
||||
else
|
||||
new_url_md5=""
|
||||
fi
|
||||
debuglog "New URL checksum: $new_url_md5"
|
||||
curr_url_md5=`cat /dev/shm/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" ]
|
||||
if [[ "$?" == "1" ]]
|
||||
then
|
||||
debuglog "URL has changed!"
|
||||
echo $new_url_md5>/dev/shm/curr_url_md5.txt
|
||||
@@ -85,18 +105,24 @@ function check_url() {
|
||||
}
|
||||
|
||||
function debuglog() {
|
||||
if [ "$DEBUG" -eq "1" ]
|
||||
if [[ "$DEBUG" == "1" ]]
|
||||
then
|
||||
if [ ! -e "/home/kioskuser/startkiosk.log" ]
|
||||
if [[ "$run_type" == "standalone" ]]
|
||||
then
|
||||
echo "startkiosk log started : "`date +%Y-%m-%d %H:%M:%S` > /home/kioskuser/startkiosk.log
|
||||
logfile_path="/var/log/startkiosk.log"
|
||||
else
|
||||
logfile_path="$HOME/startkiosk.log"
|
||||
fi
|
||||
echo `date +%H:%M:%S` "$1">>/home/kioskuser/startkiosk.log
|
||||
if [[ ! -e "$logfile_path" ]]
|
||||
then
|
||||
echo "startkiosk log started : "$(date +%Y-%m-%d %H:%M:%S) > $logfile_path
|
||||
fi
|
||||
echo $(date +%H:%M:%S) "$1">>$logfile_path
|
||||
fi
|
||||
}
|
||||
|
||||
function set_blank_params() {
|
||||
if [ "$INHIBIT_BLANK" -eq "1" ]
|
||||
if [[ "$INHIBIT_BLANK" == "1" ]]
|
||||
then
|
||||
xset s off
|
||||
xset -dpms
|
||||
@@ -108,20 +134,23 @@ function set_blank_params() {
|
||||
}
|
||||
|
||||
function set_rot_params() {
|
||||
output_name=`xrandr --listactivemonitors|grep 0:|rev|cut -d " " -f1|rev`
|
||||
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 &
|
||||
if [[ "$run_type" == "standalone" ]]
|
||||
then
|
||||
openbox-session &
|
||||
fi
|
||||
sleep 1
|
||||
set_blank_params
|
||||
pkill xpdf
|
||||
pkill chromium
|
||||
pkill xterm
|
||||
kiosk_cleanup.sh
|
||||
kiosk_cleanup
|
||||
|
||||
# start application
|
||||
|
||||
@@ -130,16 +159,16 @@ sleep 3
|
||||
|
||||
if echo "$TGT_URL"|grep -q '^http'
|
||||
then
|
||||
new_url_md5=`wget -q -o /dev/null -O - $TGT_URL|md5sum|cut -d " " -f1`
|
||||
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`
|
||||
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`
|
||||
new_conf_md5=$(md5sum $conf_file|cut -d " " -f1)
|
||||
echo $new_conf_md5 > /dev/shm/curr_conf_md5.txt
|
||||
|
||||
while true
|
||||
@@ -148,7 +177,7 @@ do
|
||||
debuglog "Monitoring for URL and config file changes..."
|
||||
# Pull in changes in the configuration file
|
||||
debuglog "Reading config file"
|
||||
source /etc/openkiosk.conf
|
||||
source $conf_file
|
||||
|
||||
if ! pgrep $ALIVE_STRING
|
||||
then
|
||||
@@ -157,7 +186,7 @@ then
|
||||
$APP_CMD &
|
||||
fi
|
||||
|
||||
if [ "$POLL_INTERVAL" -eq "0" ]
|
||||
if [[ "$POLL_INTERVAL" == "0" ]]
|
||||
then
|
||||
sleep 1
|
||||
debuglog "Polling not enabled"
|
||||
|
||||
Reference in New Issue
Block a user