This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
certbot-haproxy/provisioning_server.sh

155 lines
4.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash -x
2016-08-01 18:01:29 +02:00
set -ev
echo "$PROJECT_TZ" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
export DEBIAN_FRONTEND="noninteractive"
2016-08-01 18:01:29 +02:00
# Install go 1.5
if [ ! -f go1.5.linux-amd64.tar.gz ]; then
wget -q https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
fi
2016-08-01 18:01:29 +02:00
tar -C /usr/local -xzf go1.5.linux-amd64.tar.gz
2016-08-02 16:11:40 +02:00
# Set GOROOT and GOPATH so that GO knows where it is and where it can install
# deps
if ! grep -Fxq "export GOROOT=/usr/local/go" ~/.variables; then
echo "export GOROOT=/usr/local/go" >> ~/.variables
2016-08-01 18:01:29 +02:00
fi
2016-08-02 16:11:40 +02:00
if ! grep -Fxq "export GOPATH=/gopath" ~/.variables; then
echo "export GOPATH=/gopath" >> ~/.variables
2016-08-01 18:01:29 +02:00
fi
if ! grep -Fxq "export GO15VENDOREXPERIMENT=1" ~/.variables; then
echo "export GO15VENDOREXPERIMENT=1" >> ~/.variables
2016-08-02 16:11:40 +02:00
fi
# Add go to PATH variable
2016-08-03 17:35:42 +02:00
if ! grep -Fxq "export PATH=\$PATH:\$GOPATH/bin:\$GOROOT/bin" ~/.variables; then
echo "export PATH=\$PATH:\$GOPATH/bin:\$GOROOT/bin" >> ~/.variables
2016-08-01 18:01:29 +02:00
fi
2016-08-02 16:11:40 +02:00
if ! grep -Fxq "source ~/.variables" ~/.bashrc; then
echo "source ~/.variables" >> ~/.bashrc
2016-08-01 18:01:29 +02:00
fi
if ! grep -Fxq "127.0.0.1 boulder boulder-rabbitmq boulder-mysql" /etc/hosts; then
echo '127.0.0.1 boulder boulder-rabbitmq boulder-mysql' >> /etc/hosts
fi
cat <<EOF >> /root/.bashrc
alias ll='ls -lah'
alias la='ls -A'
alias l='ls -CF'
EOF
2016-08-01 18:01:29 +02:00
2016-08-02 16:11:40 +02:00
source ~/.variables
2016-08-01 18:01:29 +02:00
# Add repo for MariaDb
sudo apt-get install -y software-properties-common
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository 'deb [arch=amd64,i386] http://mirror.i3d.net/pub/mariadb/repo/10.1/debian jessie main'
2016-08-01 18:01:29 +02:00
apt-get update
apt-get upgrade -y
2016-08-02 16:11:40 +02:00
apt-get install -y \
2016-08-02 16:11:40 +02:00
sudo htop net-tools tcpdump ufw git curl g++ \
2016-08-01 18:01:29 +02:00
openssl ca-certificates \
python2.7 python-setuptools python-virtualenv \
rabbitmq-server make libltdl-dev mariadb-server nginx-light \
softhsm libsofthsm-dev vim
echo boulder.local > /etc/hostname
hostname -F /etc/hostname
ufw allow ssh
ufw allow http
ufw allow 4000
ufw allow 8000
ufw allow 8001
ufw allow 8002
ufw allow 8003
ufw allow 8004
ufw allow 8005
ufw default deny incoming
ufw --force enable
2016-08-01 18:01:29 +02:00
# Create new go directory for GOPATH
# Paths needed for installing go dependencies
mkdir -p /gopath/bin
mkdir -p /gopath/src
2016-08-01 18:01:29 +02:00
virtualenv /boulder_venv -p /usr/bin/python2
source /boulder_venv/bin/activate
2016-08-02 16:11:40 +02:00
# Install godep
go get github.com/tools/godep
2016-08-03 14:44:42 +02:00
# Goose is needed by the setup script (hope this will be fixed soon)
go get bitbucket.org/liamstask/goose/cmd/goose
2016-08-02 16:11:40 +02:00
# Install boulder into the gopath
go get -d github.com/letsencrypt/boulder/...
2016-08-01 18:01:29 +02:00
2016-08-02 16:11:40 +02:00
# Enter the boulder directory
cd $GOPATH/src/github.com/letsencrypt/boulder
2016-08-01 18:01:29 +02:00
2016-08-02 16:11:40 +02:00
# Install alle dependencies
godep restore
2016-08-01 18:01:29 +02:00
2016-08-02 16:11:40 +02:00
# Remaining setup
2016-08-01 18:01:29 +02:00
./test/setup.sh
# Apply softhsm configuration
./test/make-softhsm.sh
# Add softhsm configuration to .variables
2016-08-03 17:06:37 +02:00
if ! grep -Fxq "export SOFTHSM_CONF=$PWD/test/softhsm.conf" ~/.variables; then
echo "export SOFTHSM_CONF=$PWD/test/softhsm.conf" >> ~/.variables
fi
# Change pkcs to softhsm and IP to 192.168.33.111 and set high thresholds for rate limiting
2016-08-03 14:44:42 +02:00
if grep -Fq "/usr/local/lib/libpkcs11-proxy.so" test/test-ca.key-pkcs11.json; then
pip install simplejson pyyaml
/boulder/hsmpatch.py
fi
2016-08-05 16:06:59 +02:00
cat <<EOF > /etc/nginx/sites-available/wfe
server {
listen 80;
location / {
proxy_pass http://localhost:4000;
proxy_redirect http://localhost:4000/ \$scheme://\$host:80/;
2016-08-05 16:06:59 +02:00
}
}
EOF
ln -fs /etc/nginx/sites-available/wfe /etc/nginx/sites-enabled/wfe
2016-08-05 16:06:59 +02:00
rm -rfv /etc/nginx/sites-enabled/default
systemctl restart nginx
cat <<EOF > /lib/systemd/system/boulder.service
[Unit]
Description=Boulder Server
After=network.target
Wants=mariadb.service,rabbitmq.service
[Service]
Type=simple
2016-08-05 16:06:59 +02:00
KillMode=mixed
RemainAfterExit=no
Restart=always
Environment="GOROOT=/usr/local/go"
Environment="GOPATH=/gopath"
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/gopath/bin:/usr/local/go/bin"
Environment="GO15VENDOREXPERIMENT=1"
Environment="SOFTHSM_CONF=/gopath/src/github.com/letsencrypt/boulder/test/softhsm.conf"
Environment="FAKE_DNS=192.168.33.222"
WorkingDirectory=/gopath/src/github.com/letsencrypt/boulder/
ExecStart=/boulder_venv/bin/python ./start.py
[Install]
WantedBy=multi-user.target
EOF
systemctl enable boulder.service
systemctl start boulder.service
echo "Provisioning completed."