mirror of
git://slackware.nl/current.git
synced 2025-01-03 23:03:22 +01:00
59 lines
1,009 B
Text
59 lines
1,009 B
Text
|
#!/bin/sh
|
||
|
# Start/stop/restart the netatalk daemon.
|
||
|
|
||
|
netatalk_start() {
|
||
|
if [ -x /usr/sbin/netatalk ]; then
|
||
|
|
||
|
LINES="$(grep "^[^;]" /etc/netatalk/afp.conf | wc -l)"
|
||
|
if [ "$LINES" -lt "2" ]; then
|
||
|
echo "netatalk is not configured.... exiting."
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
echo "Starting netatalk: /usr/sbin/netatalk"
|
||
|
/usr/sbin/netatalk
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# Stop netatalk
|
||
|
netatalk_stop() {
|
||
|
echo "Stopping netatalk."
|
||
|
/usr/bin/pkill --ns $$ -f "^/usr/sbin/netatalk" 2> /dev/null
|
||
|
}
|
||
|
|
||
|
# Restart netatalk
|
||
|
netatalk_restart() {
|
||
|
netatalk_stop
|
||
|
sleep 1
|
||
|
netatalk_start
|
||
|
}
|
||
|
|
||
|
# Check if netatalk is running
|
||
|
netatalk_status() {
|
||
|
PID="$(/usr/bin/pgrep --ns $$ -f "^/usr/sbin/netatalk" 2> /dev/null)"
|
||
|
if [ $PID ]; then
|
||
|
echo "netatalk is running. PID: $PID"
|
||
|
else
|
||
|
echo "netatalk is stopped."
|
||
|
exit 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
case "$1" in
|
||
|
'start')
|
||
|
netatalk_start
|
||
|
;;
|
||
|
'stop')
|
||
|
netatalk_stop
|
||
|
;;
|
||
|
'restart')
|
||
|
netatalk_restart
|
||
|
;;
|
||
|
'status')
|
||
|
netatalk_status
|
||
|
;;
|
||
|
*)
|
||
|
echo "usage $0 start|stop|restart|status"
|
||
|
esac
|
||
|
|