-
Notifications
You must be signed in to change notification settings - Fork 0
/
uavmixer.sh
executable file
·59 lines (49 loc) · 1.41 KB
/
uavmixer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# Path to log file
LOGFILE="/root/uav_mixer.log"
# Path to PID file
PIDFILE="/var/run/uav_mixer.pid"
case "$1" in
start)
sleep 3
echo "Starting imu&img mixer service..."
uav_mixer -f 100 -r 30 -d /dev/ttyS2 > /dev/null 2>&1 &
#uav_mixer -f 100 -r 30 -d /dev/ttyS2 > "$LOGFILE" 2>&1 &
echo $! > "$PIDFILE"
echo "uav_mixer started with PID $(cat $PIDFILE)"
;;
stop)
echo "Stopping imu&img mixer service..."
if [ -f "$PIDFILE" ]; then
kill "$(cat $PIDFILE)" && rm -f "$PIDFILE"
echo "uav_mixer stopped."
else
echo "uav_mixer is not running."
fi
;;
restart)
if [ -f "$PIDFILE" ]; then
kill "$(cat $PIDFILE)" && rm -f "$PIDFILE"
echo "uav_mixer stopped."
else
echo "uav_mixer is not running."
fi
sleep 3
echo "Restarting imu&img mixer service..."
uav_mixer -f 100 -r 30 -d /dev/ttyS2 > /dev/null 2>&1 &
#uav_mixer -f 100 -r 30 -d /dev/ttyS2 > "$LOGFILE" 2>&1 &
echo $! > "$PIDFILE"
echo "uav_mixer started with PID $(cat $PIDFILE)"
;;
status)
if [ -f /var/run/uav_mixer.pid ]; then
echo "uav_mixer is running with PID $(cat /var/run/uav_mixer.pid)"
else
echo "uav_mixer is not running."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac