blob: 580150bed5c7c093b92859c47c17a2812443a950 (
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
|
#!/usr/bin/env bash
# Check if credentials are set
# If not fail with exit code 1
if [[ -z "${PORTAL_USER}" ]]; then
printf "Error: No portal username set, set the PORTAL_USER env var\n"
exit 1
fi
if [[ -z "${PORTAL_PASS}" ]]; then
printf "Error: No portal username set, set the PORTAL_PASS env var\n"
exit 1
fi
# Start the preliminary systemd units
systemctl start php-fpm
systemctl start httpd
systemctl start crond
# Start the daemon in the background and get the PID
vpn-daemon &
pid_daemon=$!
# Wait a bit
sleep 5
# Apply the vpn configuration
vpn-maint-apply-changes
# Add the user with the env variables
sudo -u apache vpn-user-portal-account --add "${PORTAL_USER}" --password "${PORTAL_PASS}"
# Wait for the daemon to finish
wait $pid_daemon
|