-
Notifications
You must be signed in to change notification settings - Fork 62
/
start-pritunl
executable file
·49 lines (40 loc) · 1.19 KB
/
start-pritunl
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
#!/bin/sh
set -e
[ -d /dev/net ] || mkdir -p /dev/net
[ -c /dev/net/tun ] || mknod /dev/net/tun c 10 200
touch /var/log/pritunl.log
touch /var/run/pritunl.pid
if [ "$1" = "bash" ]; then
exec "$@"
exit $?
fi
# allow changing debug mode
if [ -z "$PRITUNL_DEBUG" ]; then
PRITUNL_DEBUG="false"
fi
# allow changing bind addr
if [ -z "$PRITUNL_BIND_ADDR" ]; then
PRITUNL_BIND_ADDR="0.0.0.0"
fi
## start a local mongodb instance if no mongodb specified through env
if [ -z "$PRITUNL_MONGODB_URI" ]; then
/usr/bin/mongod -f /etc/mongod.conf &
PRITUNL_MONGODB_URI="mongodb://localhost:27017/pritunl"
fi
if [ -z "$PRITUNL_DONT_WRITE_CONFIG" ]; then
cat << EOF > /etc/pritunl.conf
{
"mongodb_uri": "$PRITUNL_MONGODB_URI",
"server_key_path": "/var/lib/pritunl/pritunl.key",
"log_path": "/var/log/pritunl.log",
"static_cache": true,
"server_cert_path": "/var/lib/pritunl/pritunl.crt",
"temp_path": "/tmp/pritunl_%r",
"bind_addr": "$PRITUNL_BIND_ADDR",
"debug": $PRITUNL_DEBUG,
"www_path": "/usr/share/pritunl/www",
"local_address_interface": "auto"
}
EOF
fi
exec /usr/bin/pritunl start -c /etc/pritunl.conf