-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
35 lines (32 loc) · 1.29 KB
/
start.sh
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
#!/bin/bash
# Create SSL certificates if they don't exist
if [ ! -f /etc/apache2/ssl/server.key ]; then
mkdir -p /etc/apache2/ssl
KEY=/etc/apache2/ssl/server.key
DOMAIN=$(hostname)
export PASSPHRASE=$(head -c 128 /dev/urandom | uuencode - | grep -v "^end" | tr "\n" "d")
SUBJ="
C=UK
ST=England
O=Resin
localityName=Guildford
commonName=$DOMAIN
organizationalUnitName=
emailAddress=
"
openssl genrsa -des3 -out /etc/apache2/ssl/server.key -passout env:PASSPHRASE 2048
openssl req -new -batch -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key $KEY -out /tmp/$DOMAIN.csr -passin env:PASSPHRASE
cp $KEY $KEY.orig
openssl rsa -in $KEY.orig -out $KEY -passin env:PASSPHRASE
openssl x509 -req -days 365 -in /tmp/$DOMAIN.csr -signkey $KEY -out /etc/apache2/ssl/server.crt
fi
# Add our hostname and Docker-allocated IP address into /etc/hosts
# HOSTLINE=$(echo $(ip -f inet addr show eth0 | grep 'inet' | awk '{ print $2 }' | cut -d/ -f1) $(hostname) $(hostname -s))
# echo $HOSTLINE >> /etc/hosts
# Disabled for now until this is resolved (lol): https://github.com/dotcloud/docker/issues/2267
#/usr/bin/mysqld_safe &
#/usr/sbin/apache2ctl -D FOREGROUND
#/usr/sbin/apache2ctl -k start
/usr/bin/supervisord
/bin/bash
#This script is based on start.sh script from https://github.com/comzone/rpi-owncloud/tree/master/resources