-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
99 lines (88 loc) · 3.23 KB
/
Copy pathsetup.sh
File metadata and controls
99 lines (88 loc) · 3.23 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# FetPost first-time setup for Linux and macOS.
# Equivalent to setup.cmd on Windows.
set -e
cd "$(dirname "$0")"
ROOT="$(pwd)"
echo "=== FetPost setup ==="
echo
# ---- Node.js 20.6+ ----
if ! command -v node >/dev/null 2>&1; then
echo "ERROR: Node.js not found. Install Node.js 20.6 or later from https://nodejs.org/"
exit 1
fi
NODE_VER="$(node --version)"
NODE_MAJOR="$(node -e 'process.stdout.write(process.versions.node.split(".")[0])')"
echo "Found Node.js $NODE_VER"
if [ "$NODE_MAJOR" -lt 20 ]; then
echo "ERROR: Node.js 20.6 or later is required (found $NODE_VER)."
exit 1
fi
# ---- Chrome / Chromium ----
case "$(uname)" in
Darwin)
if [ ! -x "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
echo "WARNING: Google Chrome not found at /Applications/Google Chrome.app."
echo "FetLife automation requires Chrome — install from https://www.google.com/chrome/"
fi
;;
Linux)
if ! command -v google-chrome >/dev/null && ! command -v google-chrome-stable >/dev/null \
&& ! command -v chromium-browser >/dev/null && ! command -v chromium >/dev/null; then
echo "WARNING: No Chrome / Chromium found in PATH."
echo "Install one before continuing — e.g. 'sudo apt install google-chrome-stable'"
fi
;;
esac
# ---- npm install ----
echo
echo "Installing dependencies in fetlife-poster..."
( cd "$ROOT/fetlife-poster" && npm install --silent )
echo "Installing dependencies in nexuspost-ui..."
( cd "$ROOT/nexuspost-ui" && npm install --silent )
# ---- Playwright Chrome ----
echo
echo "Configuring Playwright to use the system Chrome browser..."
( cd "$ROOT/fetlife-poster" && npx --yes playwright install chrome )
# ---- chmod the cookie-refresh helper so the UI can spawn it ----
chmod +x "$ROOT/fetlife-poster/start-cookies.sh" 2>/dev/null || true
# ---- Secrets + UI password ----
cd "$ROOT"
if [ -f .env ]; then
echo
echo ".env already exists. Keeping existing secrets and password."
echo "Delete .env and re-run setup.sh to regenerate."
else
echo
printf 'Choose a password for the FetPost UI: '
stty -echo 2>/dev/null
IFS= read -r UI_PWD
stty echo 2>/dev/null
echo
if [ -z "$UI_PWD" ]; then
echo "ERROR: Password is required."
exit 1
fi
FETPOST_UI_PWD="$UI_PWD" node -e "
const c=require('crypto'),f=require('fs');
f.writeFileSync('.env',
'# FetPost configuration. Generated by setup. Do not share.\n' +
'FL_SERVICE_SECRET=' + c.randomBytes(32).toString('hex') + '\n' +
'FL_MACHINE_SECRET=' + c.randomBytes(32).toString('hex') + '\n' +
'UI_PASSWORD=' + process.env.FETPOST_UI_PWD + '\n');
"
chmod 600 .env # secrets, restrict to owner
echo "Wrote .env with auto-generated secrets and your UI password (mode 0600)."
fi
# Make launch scripts executable
chmod +x "$ROOT/start.sh" "$ROOT/stop.sh" 2>/dev/null || true
echo
echo "=== Setup complete! ==="
echo
echo "Next:"
echo " 1. Run ./start.sh to launch FetPost."
echo " 2. Open http://127.0.0.1:4000 and log in with the password you just set."
echo " 3. Click \"Accounts\" in the sidebar, add a FetLife account."
echo " 4. Use \"Refresh cookies\" to log into FetLife once for that account."
echo " 5. You're ready to schedule and cross-post events."
echo