blob: 9bed162f661b7970bb9c4043320fabf54f0c7c34 (
plain) (
blame)
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
|
#!/bin/sh
# mollysocket allows sending push notifications to Molly (Signal clone)
# via UnifiedPush.
: ${mollysocket_repo='https://github.com/mollyim/mollysocket'}
: ${mollysocket_branch='1.6.0'}
: ${mollysocket_vapid_key='changeme'}
mollysocket_username=mollysocket
mollysocket_uid=794
mollysocket_home=/usr/local/mollysocket
mollysocket_repo_dir="${mollysocket_home}/mollysocket.git"
mollysocket_db_dir=/var/db/mollysocket
mollysocket_conf_file=/usr/local/etc/mollysocket.conf
# Install required packages.
pkg install -y \
git-lite \
rust \
sqlite3
# Add local mollysocket user.
add_user \
-u "$mollysocket_uid" \
-c "Mollysocket User" \
-d "$mollysocket_home" \
-s /usr/sbin/nologin \
"$mollysocket_username"
# Create persistent ZFS dataset for mollysocket's sqlite db.
create_dataset -o "mountpoint=${mollysocket_db_dir}" "${state_dataset}/mollysocket"
# Set permissions on the mollysocket db directory.
install_directory -m 0770 -o "$mollysocket_username" -g "$mollysocket_username" "$mollysocket_db_dir"
# Create mollysocket home directory.
install_directory -o "$mollysocket_username" -g "$mollysocket_username" -m 0775 "$mollysocket_home"
# Clone mollysocket git repo.
[ -d "${mollysocket_repo_dir}" ] || su -m "$mollysocket_username" -c \
"git clone ${mollysocket_repo} ${mollysocket_repo_dir}"
# Update mollysocket git repo.
su -m "$mollysocket_username" -c "git -C ${mollysocket_repo_dir} fetch"
su -m "$mollysocket_username" -c "git -C ${mollysocket_repo_dir} switch --detach ${mollysocket_branch}"
# Build mollysocket.
( cd "$mollysocket_repo_dir"
su -m "$mollysocket_username" -c "HOME=${mollysocket_home} RUSTFLAGS=-L/usr/local/lib cargo build --release"
)
# Copy mollysocket rc.d script.
install_file -m 0555 /usr/local/etc/rc.d/mollysocket
# Copy mollysocket config file.
install_template -m 0640 -g "$mollysocket_username" "$mollysocket_conf_file"
# Enable and start mollysocket.
sysrc -v mollysocket_enable=YES
service mollysocket restart
|