blob: 17bb922affeb9c480042bd0ccd5fa70f7e73c82b (
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
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
|
#!/bin/bash
set -ex
HOST='localhost:8080'
ADDR='127.0.0.1'
PORT='8080'
DB=$(mktemp)
STORAGE=$(mktemp -d)
EXPORT="$(mktemp --suffix '.json')"
_kill() {
pid=$(pidof gotosocial) \
|| return # i.e. not running
kill -$1 $pid
}
gotosocial() {
env \
GTS_HOST=$HOST \
GTS_PROTOCOL='http' \
GTS_BIND_ADDRESS=$ADDR \
GTS_PORT=$PORT \
GTS_DB_TYPE='sqlite' \
GTS_DB_ADDRESS=$DB \
GTS_STORAGE_BACKEND='local' \
GTS_STORAGE_LOCAL_BASE_PATH=$STORAGE \
GTS_WEB_ASSET_BASE_DIR='./web/assets' \
GTS_WEB_TEMPLATE_BASE_DIR='./web/template' \
go run ./cmd/gotosocial ${@}
}
# Cleanup instance, database file, export file, storage on exit
trap "_kill 9; rm -f $DB; rm -f $EXPORT; rm -rf $STORAGE" exit
# Iterate list of usernames
for username in scoobert \
shaggy \
daphne \
velma \
fred \
scrappy; do # hahaha
# Create account for each username
gotosocial admin account create \
--username ${username} \
--password 'sh1t_tiEr_Password Zomg123!' \
--email ${username}@example.com
# Confirm each of the accounts
gotosocial admin account confirm \
--username ${username}
done
# Ensure server runs once
gotosocial server start &
# Kill server
sleep 5
_kill 15
sleep 5
# Export current gts database to file
gotosocial admin export --path "$EXPORT" \
|| echo 'failed exporting to file'
# Clear database
rm -f $DB
touch $DB
# Import current gts database from file
gotosocial admin import --path "$EXPORT" \
|| echo 'failed importing from file'
# Ensure server can restart
{ gotosocial server start \
|| echo 'post-import failure'
} &
# Kill server
sleep 5
_kill 15
sleep 5
exit 0
|