This commit is contained in:
Jeffrey Paul 2018-10-10 04:35:31 -07:00
parent a1a66e185e
commit 55f7084482
Signed by: sneak
GPG Key ID: 052443F4DF2A55C2
6 changed files with 89 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
.DS_Store .DS_Store
*.pyc *.pyc
.terraform/
terraform.tfstate
terraform.tfstate.backup

View File

@ -0,0 +1,12 @@
#!/bin/bash
# sneak@nostromo-2:~$ ipfs name resolve /ipns/dist.ipfs.io/ipget/v0.3.0/ipget_v0.3.0_linux-amd64.tar.gz
# /ipfs/QmUDECZXueqXdcBEu3SLf8J19QfubhksdrDZeh1exCVMDz/ipget/v0.3.0/ipget_v0.3.0_linux-amd64.tar.gz
# sneak@nostromo-2:~$ ipfs resolve /ipfs/QmUDECZXueqXdcBEu3SLf8J19QfubhksdrDZeh1exCVMDz/ipget/v0.3.0/ipget_v0.3.0_linux-amd64.tar.gz
# /ipfs/QmQcKL42JqZtWKjbcCys27iaAKybRcchSFWaD9sF8LEUKL
apt update
apt -y install golang
go get -d github.com/ipfs/ipget
cd $HOME/go/src/github.com/ipfs/ipget
make install

View File

@ -44,7 +44,6 @@ cleanup:
clean: cleanup clean: cleanup
@echo $(PREFIX) $@ $(SUFFIX) @echo $(PREFIX) $@ $(SUFFIX)
@-rm -rf ~/.tmp/* @-rm -rf ~/.tmp/*
@-rm -rf ~/Library/Caches/*
@-rm -rf ~/.Trash/* @-rm -rf ~/.Trash/*
@-rm -rf $(JUNKFILES) @-rm -rf $(JUNKFILES)

21
misc/do-mirror-deploy.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
apt update
apt upgrade -y
apt install -y docker.io byobu
byobu-enable
mkdir -p /var/lib/ubuntumirror /var/lib/ipfs
docker rmi -f sneak/ipfs-ubuntu-mirror:latest
docker run -d \
-p 4001:4001 \
-p 4002:4002/udp \
-p 5001:5001 \
-p 8080:8080 \
-p 8081:8081 \
-v /var/lib/ubuntumirror:/var/lib/ubuntumirror \
-v /var/lib/ipfs:/var/lib/ipfs \
--env UBUNTU_MIRROR_SOURCE=nyc1.mirrors.digitalocean.com \
sneak/ipfs-ubuntu-mirror:latest

44
tf/ipfs-mirror.tf Normal file
View File

@ -0,0 +1,44 @@
variable "do_token" {}
variable "pub_key" {}
variable "pvt_key" {}
variable "ssh_fingerprint" {}
provider "digitalocean" {
token = "${var.do_token}"
}
resource "digitalocean_droplet" "ipfs-ubuntu-mirror" {
image = "ubuntu-18-04-x64"
name = "ipfs-ubuntu-mirror"
region = "nyc1"
size = "s-6vcpu-16gb"
ipv6 = true
monitoring = true
ssh_keys = [
"${var.ssh_fingerprint}"
]
connection {
user = "root"
type = "ssh"
private_key = "${file(var.pvt_key)}"
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"while PID=$(pidof -s apt-get); do tail --pid=$PID -f /dev/null; done",
"cat /etc/apt/sources.list",
"add-apt-repository universe",
"add-apt-repository multiverse",
"export PATH=$PATH:/usr/bin:/usr/local/bin",
"export GOPATH=$HOME/go",
"export DEBIAN_FRONTEND=noninteractive",
"apt update && apt install -y golang docker.io",
"go get -d github.com/ipfs/ipget",
"cd $HOME/go/src/github.com/ipfs/ipget",
"make install",
"docker run -p 4001:4001 -p 4002:4002/udp -p 5001:5001 -p 8080:8080 -p 8081:8081 -v /var/lib/ubuntumirror:/var/lib/ubuntumirror -v /var/lib/ipfs:/var/lib/ipfs -d sneak/ipfs-ubuntu-mirror"
]
}
}

9
tf/setup.sh Normal file
View File

@ -0,0 +1,9 @@
export DIGITALOCEAN_TOKEN="$(cat ~/Documents/sync/secrets/apis/digitalocean/terraform.apikey.txt)"
terraform apply \
-var "do_token=${DIGITALOCEAN_TOKEN}" \
-var "pub_key=$HOME/Documents/sync/secrets/ssh/terraform-bootstrap.pub" \
-var "pvt_key=$HOME/Documents/sync/secrets/ssh/terraform-bootstrap" \
-var "ssh_fingerprint=a2:74:1f:87:0b:09:91:ed:f4:a6:b2:8f:c7:9d:f5:95"