2018-06-27 06:13:25 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Start/stop/restart the netatalk daemon.
|
2009-08-26 17:00:38 +02:00
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
netatalk_start() {
|
|
|
|
if [ -x /usr/sbin/netatalk ]; then
|
2012-09-26 03:10:42 +02:00
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
LINES="$(grep "^[^;]" /etc/netatalk/afp.conf | wc -l)"
|
|
|
|
if [ "$LINES" -lt "2" ]; then
|
|
|
|
echo "netatalk is not configured.... exiting."
|
|
|
|
exit
|
|
|
|
fi
|
2012-09-26 03:10:42 +02:00
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
echo "Starting netatalk: /usr/sbin/netatalk"
|
|
|
|
/usr/sbin/netatalk
|
|
|
|
fi
|
2009-08-26 17:00:38 +02:00
|
|
|
}
|
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
# Stop netatalk
|
|
|
|
netatalk_stop() {
|
|
|
|
echo "Stopping netatalk."
|
|
|
|
/usr/bin/pkill --ns $$ -f "^/usr/sbin/netatalk" 2> /dev/null
|
|
|
|
}
|
2012-09-26 03:10:42 +02:00
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
# Restart netatalk
|
|
|
|
netatalk_restart() {
|
|
|
|
netatalk_stop
|
|
|
|
sleep 1
|
|
|
|
netatalk_start
|
|
|
|
}
|
2012-09-26 03:10:42 +02:00
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
# Check if netatalk is running
|
|
|
|
netatalk_status() {
|
2018-09-06 08:15:46 +02:00
|
|
|
PID="$(/usr/bin/pgrep --ns $$ -f "^/usr/sbin/netatalk" 2> /dev/null)"
|
2018-06-27 06:13:25 +02:00
|
|
|
if [ $PID ]; then
|
|
|
|
echo "netatalk is running. PID: $PID"
|
|
|
|
else
|
|
|
|
echo "netatalk is stopped."
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-09-26 03:10:42 +02:00
|
|
|
}
|
|
|
|
|
2018-06-27 06:13:25 +02:00
|
|
|
case "$1" in
|
2009-08-26 17:00:38 +02:00
|
|
|
'start')
|
2018-06-27 06:13:25 +02:00
|
|
|
netatalk_start
|
|
|
|
;;
|
2009-08-26 17:00:38 +02:00
|
|
|
'stop')
|
2018-06-27 06:13:25 +02:00
|
|
|
netatalk_stop
|
|
|
|
;;
|
2009-08-26 17:00:38 +02:00
|
|
|
'restart')
|
2018-06-27 06:13:25 +02:00
|
|
|
netatalk_restart
|
|
|
|
;;
|
|
|
|
'status')
|
|
|
|
netatalk_status
|
|
|
|
;;
|
2009-08-26 17:00:38 +02:00
|
|
|
*)
|
2018-06-27 06:13:25 +02:00
|
|
|
echo "usage $0 start|stop|restart|status"
|
2009-08-26 17:00:38 +02:00
|
|
|
esac
|
2018-06-27 06:13:25 +02:00
|
|
|
|