This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
forked from kylemanna/docker-bitcoind
-
Notifications
You must be signed in to change notification settings - Fork 55
/
bootstrap-host.sh
executable file
·69 lines (52 loc) · 2.08 KB
/
bootstrap-host.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
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
#!/bin/bash
#
# Configure broken host machine to run correctly
#
set -ex
DASH_IMAGE=${DASH_IMAGE:-dashpay/dashd}
distro=$1
shift
memtotal=$(grep ^MemTotal /proc/meminfo | awk '{print int($2/1024) }')
#
# Only do swap hack if needed
#
if [ $memtotal -lt 2048 -a $(swapon -s | wc -l) -lt 2 ]; then
fallocate -l 2048M /swap || dd if=/dev/zero of=/swap bs=1M count=2048
mkswap /swap
grep -q "^/swap" /etc/fstab || echo "/swap swap swap defaults 0 0" >> /etc/fstab
swapon -a
fi
free -m
if [ "$distro" = "trusty" -o "$distro" = "ubuntu:14.04" ]; then
curl https://get.docker.io/gpg | apt-key add -
echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
# Handle other parallel cloud init scripts that may lock the package database
# TODO: Add timeout
while ! apt-get update; do sleep 10; done
while ! apt-get install -y lxc-docker; do sleep 10; done
fi
if [ "$distro" = "bionic" -o "$distro" = "ubuntu:18.04" ]; then
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Handle other parallel cloud init scripts that may lock the package database
# TODO: Add timeout
while ! apt-get update; do sleep 10; done
while ! apt-get install -y docker-ce; do sleep 10; done
fi
# Always clean-up, but fail successfully
docker kill dashd-node 2>/dev/null || true
docker rm dashd-node 2>/dev/null || true
stop docker-dashd 2>/dev/null || true
# Always pull remote images to avoid caching issues
if [ -z "${DASH_IMAGE##*/*}" ]; then
docker pull $DASH_IMAGE
fi
# Initialize the data container
docker volume create --name=dashd-data
docker run -v dashd-data:/dash --rm $DASH_IMAGE dash_init
# Start dashd via systemd and docker
curl https://raw.githubusercontent.com/dashpay/docker-dashd/master/init/docker-dashd.service > /lib/systemd/system/docker-dashd.service
systemctl start docker-dashd
set +ex
echo "Resulting dash.conf:"
docker run -v dashd-data:/dash --rm $DASH_IMAGE cat /dash/.dashcore/dash.conf