Files
2026-06-26 14:45:42 +03:00

24 lines
733 B
Bash

#!/usr/bin/env bash
#
# bt-set-master - set the deploy-time emergency master password.
#
# Usage (once at first install):
# sudo /opt/buttontask/scripts/bt-set-master 'your-secret'
#
# Writes $BUTTONTASK_ROOT/config/.master (mode 600, buttontask-owned).
# Used by web login and Qt settings password check as a fallback.
set -euo pipefail
ROOT="${BUTTONTASK_ROOT:-/opt/buttontask}"
FILE="$ROOT/config/.master"
[ "$#" -eq 1 ] || { echo "usage: bt-set-master <password>" >&2; exit 2; }
[ -n "$1" ] || { echo "password must not be empty" >&2; exit 1; }
install -d -m 0750 "$ROOT/config"
umask 077
printf '%s' "$1" > "$FILE"
chmod 600 "$FILE"
chown buttontask:buttontask "$FILE" 2>/dev/null || true
echo "master password set: $FILE"