#!/bin/bash
# Make sure we run as root, restart othervise, keep arguments intact
if [ "$1" == "x47restart" ]; then
shift 1
else
if [ "$(id -u)" != "0" ]; then
exec /sbin/start-stop-daemon -S -c root:root -x "$0" -- x47restart "$@"
fi
fi
export QTDIR=/usr/lib/ezx
export EZX_RES_FONT_PATH=$QTDIR/lib/fonts
MYDIR="$(pwd -P)"
if [ -e /tmp/clocker_autostart -a -d /ezxlocal/download/QTDownLoad/Startup ]; then
rm -f /ezxlocal/download/QTDownLoad/Startup/clocker
echo "#!/bin/sh" > /ezxlocal/download/QTDownLoad/Startup/clocker
echo "cd \"$MYDIR\"" >> /ezxlocal/download/QTDownLoad/Startup/clocker
echo "./main.lin &" >> /ezxlocal/download/QTDownLoad/Startup/clocker
chmod +x /ezxlocal/download/QTDownLoad/Startup/clocker
rm -f /tmp/clocker_autostart
./ledshort.lin
fi
if [ -e /tmp/clocker_noautostart -a -d /ezxlocal/download/QTDownLoad/Startup ]; then
rm -f /ezxlocal/download/QTDownLoad/Startup/clocker
rm -f /tmp/clocker_noautostart
fi
if [ ! -x ./clocker ]; then
chmod +x ./clocker
fi
if [ ! -x ./alertprocess ]; then
chmod +x ./alertprocess
fi
./ledshort.lin
exec "./clocker"