Recently Written · git

9p-store

Small disk-backed 9P file server (diod) for a private network

git clone https://github.com/equwal/9p-store

Log | Files | Refs


install.sh (1179 bytes)

1 #!/bin/sh
2 # Install a disk-backed 9P file server (diod) on Debian/Ubuntu.
3 # Usage: LISTEN_ADDR=<private-ip> ./install.sh
4 #   LISTEN_ADDR  private address to serve on (for example a WireGuard address). Required.
5 #   EXPORT_DIR   directory to serve (default /srv/9pstore)
6 #   SQUASH_USER  account that owns every file (default 9pstore)
7 #   PORT         TCP port (default 564)
8 set -eu
9 : "${LISTEN_ADDR:?set LISTEN_ADDR to a private address, never a public one}"
10 EXPORT_DIR=${EXPORT_DIR:-/srv/9pstore}
11 SQUASH_USER=${SQUASH_USER:-9pstore}
12 PORT=${PORT:-564}
13 
14 DEBIAN_FRONTEND=noninteractive apt-get install -y diod
15 systemctl disable --now diod 2>/dev/null || true   # Debian ships a sysv unit; use ours.
16 id "$SQUASH_USER" >/dev/null 2>&1 ||
17   useradd -r -s /usr/sbin/nologin -d "$EXPORT_DIR" "$SQUASH_USER"
18 mkdir -p "$EXPORT_DIR"
19 chown "$SQUASH_USER": "$EXPORT_DIR"
20 chmod 770 "$EXPORT_DIR"
21 
22 sed -e "s|@LISTEN_ADDR@|$LISTEN_ADDR|" -e "s|@EXPORT_DIR@|$EXPORT_DIR|" \
23     -e "s|@SQUASH_USER@|$SQUASH_USER|" -e "s|@PORT@|$PORT|" \
24     "$(dirname "$0")/9pstore.service.in" > /etc/systemd/system/9pstore.service
25 systemctl daemon-reload
26 systemctl enable --now 9pstore
27 ss -ltn "sport = :$PORT"