-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·62 lines (52 loc) · 2.04 KB
/
run
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
#!/usr/bin/env bash
: ${NGINX_RUN_TYPE:='advanced'}
: ${PROCFILE=''}
RANCHER_GEN_TEMPLATES=''
for VAR in $(env)
do
# Loop through all HTTPPWD_X variables and create the users if any
if [ ! -z "$(echo $VAR | grep -E '^HTTPPWD_')" ]; then
VAR_VALUE=$(echo "$VAR" | sed -r "s|HTTPPWD_(.*)=||g")
username=$(echo "$VAR_VALUE" | sed -r "s|:(.*)||g")
password=$(echo "$VAR_VALUE" | sed -r "s|(.*):||g")
# Create password
sh -c "echo -n '${username}:' >> /etc/nginx/.htpasswd"
sh -c "openssl passwd -apr1 ${password} >> /etc/nginx/.htpasswd"
fi
if [ ! -z "$(echo $VAR | grep -E '^RANCHER_GEN_TEMPLATE_')" ]; then
template=$(echo "$VAR" | sed -r "s|RANCHER_GEN_TEMPLATE_(.*)=||g")
RANCHER_GEN_TEMPLATES="$RANCHER_GEN_TEMPLATES --template $template"
fi
done
if [ "$NGINX_RUN_TYPE" = 'advanced' -o "$NGINX_RUN_TYPE" = 'dockren-gen' ]; then
if [ -z PROCFILE ]; then
PROCFILE = 'Procfile.docker-gen'
fi
# unbuffer honcho -f Procfile.docker-gen start
elif [ "$NGINX_RUN_TYPE" = 'rancher-gen' ]; then
echo "Running rancher-gen"
if [ -z "$RANCHER_GEN_TEMPLATES" ]; then
RANCHER_GEN_TEMPLATES="--template /nginxconf/default.tmpl:/etc/nginx/sites-available/default"
fi
export RANCHER_GEN_TEMPLATES=$RANCHER_GEN_TEMPLATES
if [ -z PROCFILE ]; then
PROCFILE = 'Procfile.rancher-gen'
fi
# unbuffer honcho -f Procfile.rancher-gen start
elif [ "$NGINX_RUN_TYPE" = 'kube-gen' ]; then
echo " Running kube-gen"
# Setup kube config file
kubectl config --kubeconfig /.kubeconfig set-cluster k8s --server=$K8S_SERVER_URL
kubectl config --kubeconfig /.kubeconfig set-credentials $K8S_USERNAME --token=$K8S_USER_TOKEN
kubectl config --kubeconfig /.kubeconfig set-context eks --cluster=k8s --user=$K8S_USERNAME
kubectl config --kubeconfig /.kubeconfig use-context eks --user=$K8S_USERNAME
if [ -z PROCFILE ]; then
PROCFILE = 'Procfile.kube-gen'
fi
fi
echo "Using Procfile $PROCFILE"
if [ -z "$PROCFILE" ]; then
unbuffer nginx -g "daemon off;"
else
unbuffer honcho -f $PROCFILE start
fi