Added GPIO Shutdown install and user Input for GPIO Startup and SystemD Services

This commit is contained in:
Tim
2024-08-12 11:33:23 +02:00
parent 24fb277d57
commit a9216370a7
+36 -4
View File
@@ -8,10 +8,24 @@ NOCOLOR='\033[0m'
echo -e "${GREEN}======== Starte Installation =========${NOCOLOR}"
echo -e "${CYAN_BACK} Would you like to enable the System D service for atomatic start of video planback?"
read USERSELECT -p "(Y/N)"
echo -e "${NOCOLOR}"
read -p "Do you want to add a SystemD Servide for Autostart [y|n]" INPUT
SYSD=1
case $INPUT in
y|Y) SYSD=0 ;;
n|N) SYSD=1 ;;
*) echo "SystemD Service will not be Added...." ;;
esac
INPUT=""
read -p "Do you want to add GPIO Power Controle [y|n]" INPUT
GPPower=1
case $INPUT in
y|Y) GPPower=0 ;;
n|N) GPPower=1 ;;
*) echo "GPIO Power controll will not be Addaded.........." ;;
esac
CURRENT_USER=$(whoami)
@@ -52,6 +66,15 @@ cd ..
echo -e "${GREEN}======== Erestele Systemd Service ========${NOCOLOR}"
AUTOLOGIN_SERVICE_CONTENT="[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $CURRENT_USER --noclear tty1 linux
"
# Erstelle die Autologin-Service-Datei
echo "Erstelle die Autologin-Service-Datei unter /etc/systemd/system/getty@tty1.service.d/override.conf..."
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d/
SERVICE_CONTENT="[Unit]
Description=Video Control Script
After=network.target
@@ -68,6 +91,9 @@ User=$CURRENT_USER
WantedBy=multi-user.target
"
echo "$AUTOLOGIN_SERVICE_CONTENT" | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf > /dev/null
# Erstelle der PiVideo Service-Datei
echo "$SERVICE_CONTENT" | sudo tee /etc/systemd/system/$SERVICE_NAME > /dev/null
@@ -75,7 +101,7 @@ echo "$SERVICE_CONTENT" | sudo tee /etc/systemd/system/$SERVICE_NAME > /dev/null
echo -e "${GREEN}======== Lade Dienste neu ========${NOCOLOR}"
sudo systemctl daemon-reload
if ["$USRSELECT" == "Y" ] || ["$USERSELECT" == "y"]
if [ $SYSD -eq 0 ]
then
USERSELECT=""
# Aktiviere den Service, damit er beim Booten gestartet wird
@@ -93,6 +119,12 @@ else
echo -e "${CYAN_BACK} Did not start Service, to start use \"sudo systemctl start pivideo.service\" ${NOCOLOR}"
fi
if [ $GPPower -eq 0]
then
echo "dtoverlay=gpio-shutdown,gpio-pin=3" | sudo tee /boot/config.txt > /dev/null
else
fi
echo -e "${GREEN}=========================================================${NOCOLOR}"
echo -e "${GREEN}======== Das Script wurde Erfolgreich Ausgeführt ========${NOCOLOR}"