#!/bin/bash
# LCD4LINUX-Script
#
# V 0.04
# Changelog:
# V 0.02 Diverse Bugs
# V 0.03 PID - Bug gefixed
# V 0.04 Befehl Status hinzugefügt
#
# © Al-x83, IPC-PEBKAC
#
#
# LCD4LINUX-Start
start_lcd4linux () {
sleep 5
echo "LCD4linux gestartet"
lcd4linux -q
}
# LCD4LINUX-Stop
stop_lcd4linux () {
pkill lcd4linux
sleep 5
PID="$(pgrep -x lcd4linux)"
if [[ ! -n $PID ]] ; then
echo "LCD4linux beendet"
else
pkill -9 lcd4linux
echo "LCD4linux gekillt"
fi
}
# Befehlsparameter
case "$1" in
start)
PID="$(pgrep -x lcd4linux)"
if [[ ! -z $PID ]] ; then
echo "LCD4linux ist bereits gestartet"
else
start_lcd4linux
pgrep -x lcd4linux > /tmp/.lcd4linux.pid
PID="$(pgrep -F /tmp/.lcd4linux.pid)"
echo "LCD4Linux mit PID $PID gestartet"
fi
rm /tmp/.lcd4linux.pid
;;
stop)
PID="$(pgrep -x lcd4linux)"
if [[ ! -z $PID ]] ; then
stop_lcd4linux
else
echo "LCD4linux ist bereits beendet"
fi
;;
restart)
echo "LCD4linux restart"
stop_lcd4linux
sleep 3
start_lcd4linux
;;
status)
PID="$(pgrep -x lcd4linux)"
if [[ ! -z $PID ]] ; then
pgrep -x lcd4linux > /tmp/.lcd4linux.pid
PID="$(pgrep -F /tmp/.lcd4linux.pid)"
echo "LCD4linux ist bereits mit PID $PID gestartet"
rm /tmp/.lcd4linux.pid
else
echo "LCD4Linux ist inaktiv"
fi
;;
*)
clear
echo "==============================================================================="
echo ""
echo -n "Befehlsliste: LCD4linux"
echo ""
echo ""
echo "Start, Stop, Restart, Status start | stop | restart | status"
echo ""
echo "==============================================================================="
echo ""
;; esac
exit 0