summaryrefslogtreecommitdiff
path: root/network/tnfsd/rc.tnfsd
blob: 392856115a494b8f5545ca39bbf5f310579a6660 (plain)
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
#!/bin/sh

# rc.tnfsd, part of SBo tnfsd build, by B. Watson. WTFPL.

# To start tnfsd at boot, make this script executable, then add this code
# to /etc/rc.d/rc.local:
#   [ -x /etc/rc.d/rc.tnfsd ] && /etc/rc.d/rc.tnfsd start

# tnfsd will chroot to $TNFS_ROOT and set its user ID to $TNFS_USER,
# and its group ID to $TNFS_USER's primary group. Since there's no
# other form of access control, make sure the $TNFS_USER can't wrote
# to $TNFS_ROOT, unless you want to allow everyone who can connect
# to write/delete/overwrite everything in $TNFS_ROOT. By default,
# /var/tnfs is owned by root:tnfs-files.

TNFS_USER=tnfsd
TNFS_ROOT=/var/tnfs

# Log gets overwritten on startup (no rotation).
TNFS_LOG=/var/log/tnfsd.log

# If you don't need the log at all. But if tnfsd fails to start, you
# won't see any error messages from it...
#TNFS_LOG=/dev/null

kill_tnfsd() {
  /usr/bin/killall tnfsd && sleep 1
}

start_tnfsd() {
  echo "Starting tnfsd."
  kill_tnfsd &>/dev/null
  /usr/bin/tnfsd "$TNFS_ROOT" -c "$TNFS_USER" >"$TNFS_LOG" </dev/null 2>&1 &
}

stop_tnfsd() {
  echo "Stopping tnfsd."
  kill_tnfsd
}

case "$1" in
  ""|start) start_tnfsd ;;
  stop)     stop_tnfsd  ;;
  restart)  stop_tnfsd ; start_tnfsd ;;
  *) echo "Usage: $0 stop|start|restart" 1&>2; exit 1 ;;
esac

exit 0