Adding a Startup and Shutdown Script for PCIe-NPL54
Last updated
Last updated
#!/bin/bash
LOG=/var/log/npl54-stopscript.log
/usr/bin/date +"%Y-%m-%d %H:%M:%S" >> $LOG
echo "System is booting up" >> $LOG
echo "" >> $LOG#!/bin/bash
LOCKFILE="/tmp/npl54script.lock"
# Check if the lock file exists
if [ -e "$LOCKFILE" ]; then
echo "Another instance of the script is already running. Exiting."
exit 0
fi
# Create a lock file
touch "$LOCKFILE"
LOG=/var/log/npl54-stopscript.log
/usr/bin/date +"%Y-%m-%d %H:%M:%S" >> $LOG
echo "System is shutting down" >> $LOG
echo "" >> $LOG
# Add some script
#
sudo /usr/bin/pkill -SIGINT NPL54Capture
sudo rm -f $LOCKFILE
[Unit]
Description=NPL54 start and shutdown script
Before=shutdown.target reboot.target halt.target network.target umount.target
[Service]
Type=oneshot
Restart=no
RemainAfterExit=true
ExecStart=/usr/local/bin/npl54-start.sh
ExecStop=/usr/local/bin/npl54-shutdown.sh
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
# Install
sudo touch /var/log/npl54-stopscript.log
sudo chmod +x /usr/local/bin/npl54-start.sh
sudo chmod +x /usr/local/bin/npl54-shutdown.sh
sudo systemctl disable npl54-start-stop-script.service
sudo systemctl daemon-reload
sudo systemctl enable npl54-start-stop-script.service --now
# Check Status
sudo systemctl status npl54-start-stop-script.service
sudo systemctl list-units --type=service
# Check Log
journalctl -u npl54-start-stop-script.service -f
## For development process: To remove xxx.service
# sudo systemctl disable xxx.service
# sudo rm /etc/systemd/system/xxx.service
# sudo systemctl daemon-reload