Created
August 8, 2023 05:43
-
-
Save reubenmiller/00af13f4f64906696ad41388138530aa to your computer and use it in GitHub Desktop.
Check a sysv init system to gather information about if tedge-agent can be run or not
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "------------ System info ------------" | |
uname -a | |
echo "sysvinit version: $(/sbin/init --version)" | |
echo | |
echo "----------- Checking setup -----------" | |
command -V service || echo "FAIL: service does not exist" | |
command -V start-stop-daemon || echo "WARN: start-stop-daemon does not exist, this is used by the service definitions currently" | |
# Checking install folders | |
echo "Checking /etc/init.d folder" | |
ls -l /etc/init.d/ | |
echo "Checking /etc/rc.d/ folder" | |
if [ -d /etc/rc.d ]; then | |
ls -l /etc/rc.d | |
else | |
echo "INFO: /etc/rc.d does not exist" | |
fi | |
# Check if sysvinit is actually running | |
service --status-all || echo "FAIL: service --status-all does not work" | |
# Enable tedge-agent (so it will startup after boot, but it does not startup yet) | |
update-rc.d tedge-agent defaults || echo "FAIL: Could not set defaults of service" | |
update-rc.d tedge-agent enable 2>/dev/null ||: | |
# Start service | |
service tedge-agent start | |
# Check if the process is running (it should return a pid) | |
pgrep -fa tedge-agent || pgrep -f tedge-agent | |
# Check logs | |
tail -f /var/log/tedge-agent.log | |
# Stop service | |
service tedge-agent stop | |
# Check if the process is running (it should NOT return a pid) | |
pgrep -fa tedge-agent || pgrep -f tedge-agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment