SPB Git

Repository Public

node-setup.sh 1.2 KB 20 lines shellscript

1#!/bin/zsh2# One-time preparation of the node that hosts SP Drive (idempotent). Run on the node, from the app directory.3# Creates the database, the data directories, the master key, the antivirus configuration and its first signatures.4set -euo pipefail5export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/postgresql@17/bin:$PATH6DATA=${SPD_DATA_DIR:-$HOME/sp-drive-data}7KEY=${SPD_MASTER_KEY_FILE:-$HOME/.config/sp-drive/master.key}8DB=$DATA/clamav-db9umask 07710mkdir -p "$DATA"/{blobs,tmp,quarantine,work,run,logs} "$DB" "$(dirname "$KEY")" "$HOME/backups/sp-drive"11chmod 700 "$DATA" "$(dirname "$KEY")" "$HOME/backups/sp-drive"12createdb -h 127.0.0.1 sp_drive 2>/dev/null || true13if [[ ! -f "$KEY" ]]; then14  head -c 32 /dev/urandom | xxd -p -c 64 > "$KEY"; chmod 600 "$KEY"15  echo "master key created: $KEY — COPY IT OFF THIS NODE NOW (without it stored files cannot be read)"16fi17for f in clamd freshclam; do sed -e "s#{{DATA}}#$DATA#g" -e "s#{{DB}}#$DB#g" infra/$f.conf.template > "$DATA/run/$f.conf"; done18[[ -f "$DB/main.cvd" || -f "$DB/main.cld" ]] || freshclam --config-file="$DATA/run/freshclam.conf" --user "$(id -un)"19echo "node ready: data $DATA, database sp_drive, signatures $(ls "$DB" | grep -c -E 'c[vl]d$') files"20
Files main
Menu

Theme