-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjustfile
More file actions
117 lines (93 loc) · 3.2 KB
/
justfile
File metadata and controls
117 lines (93 loc) · 3.2 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
BACKEND_SERVER_DIR := env_var_or_default('BACKEND_SERVER_DIR', "/srv/backend-server")
# run-in-lxd.sh & tests/test require these env vars
export DEBUG := env_var_or_default('DEBUG', "")
export GITHUB_ACTIONS := env_var_or_default('GITHUB_ACTIONS', "false")
set dotenv-load := true
default:
@just --list
[private]
check:
#!/bin/bash
set -euo pipefail
test $PWD = {{ BACKEND_SERVER_DIR }}* || { echo "You must run this from {{ BACKEND_SERVER_DIR }}"; exit 1; }
if test -z $BACKEND
then
echo "BACKEND is not set in .env";
exit 1
fi
if [[ $BACKEND == *"-backend"* ]]; then
echo "Please shorten BACKEND (i.e. 'test' instead of 'test-backend')"
exit 1
fi
if test ! -e backends/$BACKEND
then
echo "Backend 'backends/$BACKEND' does not exist in this repo"
exit 1
fi
# install required system packages
install-packages: check
./scripts/install_packages.sh
# install/update groups & system level configuration
install: check
./scripts/install.sh
# create opensafely user & config
install-opensafely-user: check
./scripts/install_opensafely_user.sh
./scripts/update-config.sh $BACKEND
# report which backend configuration this justfile is using
whereami: check
@echo "Your current backend is: $BACKEND"
# disable a users permissions and ssh access
disable-user user:
./scripts/disable-user.sh {{ user }}
update-users: check
./scripts/update-users.sh $BACKEND
install-jobrunner: check install-opensafely-user install-docker-network
./services/jobrunner/install.sh $BACKEND
install-docker-network:
./services/jobrunner/sbin/jobrunner-network-config.sh
install-airlock: check install-opensafely-user
./services/airlock/install.sh
install-collector: check
./services/collector/install.sh
# install everything for a backend
manage: check
#!/bin/bash
set -euo pipefail
if test -d /srv/jobrunner/environ -a ! -d ~opensafely/config; then
echo "You need to manually run ./scripts/migrate.sh first"
exit 1
fi
{{ just_executable() }} manage-$BACKEND
[private]
manage-test: install-packages install update-users install-jobrunner install-airlock install-collector
[private]
manage-tpp: install-packages install update-users install-jobrunner install-airlock install-collector
test:
echo "Please see `just tests/`"
# upgrade all apt packages
apt-upgrade:
#!/bin/bash
set -euo pipefail
package_to_hold='docker.io'
apt-get update
apt-mark hold "$package_to_hold"
apt-get upgrade -y
apt-get autoremove -y
if apt list --upgradable "$package_to_hold" 2>/dev/null | grep -qF "$package_to_hold"; then
echo
echo " => WARNING <="
echo
echo " The '$package_to_hold' package has an update pending. This usually requires"
echo " a restart of all running Docker containers. To avoid disruption to user"
echo " jobs you should first run a prepare_for_reboot on the controller."
echo
echo " Note that jobs will have to re-run from the start so if there are"
echo " currently jobs which have been running a long time you may wish to delay"
echo " upgrading."
echo
echo " Choose 'n' below to decline the update, or 'Y' to proceed."
echo
apt-mark unhold "$package_to_hold"
apt-get upgrade
fi