-
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathinit_command.sh
More file actions
125 lines (121 loc) · 4.67 KB
/
init_command.sh
File metadata and controls
125 lines (121 loc) · 4.67 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
118
119
120
121
122
123
124
125
#!/bin/sh
# OpenWISP common module init script
set -e
source utils.sh
init_conf
# Start services
if [ "$MODULE_NAME" = 'dashboard' ]; then
if [ "$OPENWISP_GEOCODING_CHECK" = 'True' ]; then
python manage.py check --deploy --tag geocoding
fi
python services.py database redis
python manage.py migrate --noinput
test -f "$SSH_PRIVATE_KEY_PATH" || ssh-keygen -t ed25519 -f "$SSH_PRIVATE_KEY_PATH" -N ""
python load_init_data.py
python collectstatic.py
start_uwsgi
elif [ "$MODULE_NAME" = 'postfix' ]; then
postfix_config
postfix set-permissions
postfix start
rsyslogd -n
elif [ "$MODULE_NAME" = 'freeradius' ]; then
wait_nginx_services
if [ "$DEBUG_MODE" = 'False' ]; then
source docker-entrypoint.sh
else
source docker-entrypoint.sh -X
fi
elif [ "$MODULE_NAME" = 'openvpn' ]; then
if [[ -z "$VPN_DOMAIN" ]]; then exit; fi
wait_nginx_services
openvpn_preconfig
openvpn_config
openvpn_config_download
crl_download
echo "*/1 * * * * sh /openvpn.sh" | crontab -
(
crontab -l
echo "0 0 * * * sh /revokelist.sh"
) | crontab -
crond
# Schedule send topology script only when
# network topology module is enabled.
if [ "$USE_OPENWISP_TOPOLOGY" == "True" ]; then
init_send_network_topology
fi
# Supervisor is used to start the service because OpenVPN
# needs to restart after crl list is updated or configurations
# are changed. If OpenVPN as the service keeping the
# docker container running, restarting would mean killing
# the container while supervisor helps only to restart the service!
supervisord --nodaemon --configuration supervisord.conf
elif [ "$MODULE_NAME" = 'nginx' ]; then
rm -rf /etc/nginx/conf.d/default.conf
if [ "$NGINX_CUSTOM_FILE" = 'True' ]; then
nginx -g 'daemon off;'
fi
NGINX_EVENTS_BLOCK=$(printf "%b" "${NGINX_EVENTS_BLOCK:-}")
export NGINX_EVENTS_BLOCK
export NGINX_WORKER_RLIMIT_NOFILE="${NGINX_WORKER_RLIMIT_NOFILE:-__UNSET__}"
envsubst </etc/nginx/nginx.template.conf >/etc/nginx/nginx.conf
# Remove incomplete worker_rlimit_nofile directives if env var is unset or empty
sed -i '/__UNSET__/d; /^worker_rlimit_nofile *$/d; /^[[:space:]]*$/d' /etc/nginx/nginx.conf
envsubst_create_config /etc/nginx/openwisp.internal.template.conf internal INTERNAL
if [ "$SSL_CERT_MODE" = 'Yes' ]; then
nginx_prod
elif [ "$SSL_CERT_MODE" = 'SelfSigned' ]; then
nginx_dev
else
envsubst_create_config /etc/nginx/openwisp.template.conf http DOMAIN
fi
nginx -g 'daemon off;'
elif [ "$MODULE_NAME" = 'celery' ]; then
python services.py database redis dashboard
echo "Starting the 'default' celery worker"
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues celery \
-n celery@%h --logfile /opt/openwisp/logs/celery.log \
--pidfile /opt/openwisp/celery.pid --detach \
${OPENWISP_CELERY_COMMAND_FLAGS}
if [ "$USE_OPENWISP_CELERY_NETWORK" = "True" ]; then
echo "Starting the 'network' celery worker"
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues network \
-n network@%h --logfile /opt/openwisp/logs/celery_network.log \
--pidfile /opt/openwisp/celery_network.pid --detach \
${OPENWISP_CELERY_NETWORK_COMMAND_FLAGS}
fi
if [[ "$USE_OPENWISP_FIRMWARE" == "True" && "$USE_OPENWISP_CELERY_FIRMWARE" == "True" ]]; then
echo "Starting the 'firmware_upgrader' celery worker"
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues firmware_upgrader \
-n firmware_upgrader@%h --logfile /opt/openwisp/logs/celery_firmware_upgrader.log \
--pidfile /opt/openwisp/celery_firmware_upgrader.pid --detach \
${OPENWISP_CELERY_FIRMWARE_COMMAND_FLAGS}
fi
sleep 1s
tail -f /opt/openwisp/logs/*
elif [ "$MODULE_NAME" = 'celery_monitoring' ]; then
python services.py database redis dashboard
if [[ "$USE_OPENWISP_MONITORING" == "True" && "$USE_OPENWISP_CELERY_MONITORING" == 'True' ]]; then
echo "Starting the 'monitoring' celery worker"
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues monitoring \
-n monitoring@%h --logfile /opt/openwisp/logs/celery_monitoring.log \
--pidfile /opt/openwisp/celery_monitoring.pid --detach \
${OPENWISP_CELERY_MONITORING_COMMAND_FLAGS}
echo "Starting the 'monitoring_checks' celery worker"
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues monitoring_checks \
-n monitoring_checks@%h --logfile /opt/openwisp/logs/celery_monitoring_checks.log \
--pidfile /opt/openwisp/celery_monitoring_checks.pid --detach \
${OPENWISP_CELERY_MONITORING_CHECKS_COMMAND_FLAGS}
sleep 1s
tail -f /opt/openwisp/logs/*
else
echo "Monitoring queues are not activated, exiting."
fi
elif [ "$MODULE_NAME" = 'celerybeat' ]; then
rm -rf celerybeat.pid
python services.py database redis dashboard
celery -A openwisp beat -l ${DJANGO_LOG_LEVEL}
else
python services.py database redis dashboard
start_uwsgi
fi