-
Notifications
You must be signed in to change notification settings - Fork 682
/
dev-deps
executable file
·77 lines (58 loc) · 2.43 KB
/
dev-deps
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
#!/bin/bash
export DISPLAY=:1
function run_xvfb() {
setsid Xvfb :1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset >& /tmp/xvfb.out || cat /tmp/xvfb.out
}
function run_redis() {
setsid redis-server >& /tmp/redis.out || cat /tmp/redis.out
}
function run_x11vnc() {
setsid x11vnc -display :1 -autoport 5901 -shared >& /tmp/x11vnc.out || cat /tmp/x11vnc.out
}
function urandom() {
sudo rm /dev/random
sudo ln -s /dev/urandom /dev/random
}
function append_to_exit() {
local existing
existing="$(trap | sed -n "/EXIT\$/s/^trap -- '\(.*\)' EXIT/\1/p")"
trap "${existing:-true} ; $1" EXIT
}
function maybe_create_config_py() {
if ! test -f config.py ; then
append_to_exit "rm config.py"
make test-config
fi
}
function run_sass() {
sass --stop-on-error sass:static/css --style compressed "$@"
}
function reset_demo() {
# Set up gpg keys directory structure.
sudo mkdir -p /var/lib/securedrop/{store,keys,tmp}
sudo chown -R "$(id -u)" /var/lib/securedrop
cp ./tests/files/test_journalist_key.pub /var/lib/securedrop/keys
gpg2 --homedir /var/lib/securedrop/keys --import /var/lib/securedrop/keys/test_journalist_key.pub >& /tmp/gpg.out || cat /tmp/gpg.out
# Create gpg-agent.conf
echo allow-loopback-pinentry > /var/lib/securedrop/keys/gpg-agent.conf
# Kill gpg-agent(s) if they exist so it picks up the new config on restart.
pkill -f gpg-agent || true
# Note that we should avoid `gpgconf --kill gpg-agent` since the pkill command will
# handle killing multiple gpg-agent processes if they exist (this is what we want).
# Set permissions on gpg-related directories/files.
sudo chown -R "$(id -gn)" /var/lib/securedrop/keys
chmod 700 /var/lib/securedrop/keys
chmod 600 /var/lib/securedrop/keys/*
# If the following directories exist, make sure they have the proper permissions.
chmod -f 700 /var/lib/securedrop/keys/private-keys-v1.d || true
chmod -f 700 /var/lib/securedrop/keys/openpgp-revocs.d || true
# Generate translated strings
./i18n_tool.py translate-messages --compile
# remove previously uploaded custom logos
rm -f /var/www/securedrop/static/i/custom_logo.png
# create an empty database
sqlite3 /var/lib/securedrop/db.sqlite .databases &> /dev/null
./manage.py reset
gpg2 --homedir /var/lib/securedrop/keys --import /var/lib/securedrop/keys/test_journalist_key.pub
./create-dev-data.py
}