From 217af2d001d72d4a5f670661054c15d2d4cb8fe7 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Mon, 1 Oct 2018 14:01:32 -0700 Subject: [PATCH] initial --- Dockerfile | 21 +++++++++++++++++++ ipfsd.run | 8 ++++++++ sync.run | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 Dockerfile create mode 100644 ipfsd.run create mode 100644 sync.run diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b0b223e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM phusion/baseimage:0.11 +MAINTAINER Jeffrey Paul + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt update +# upgrading packages against advice of phusion +RUN apt upgrade -y + +RUN apt install -y golang git build-essential + +RUN go get -u github.com/ipfs/ipfs-update +RUN /root/go/bin/ipfs-update install latest +RUN rm -rf /root/go + +RUN adduser --system --group ipfs +RUN mkdir /etc/service/sync /etc/service/ipfsd +ADD ./sync.run /etc/service/sync/run +ADD ./ipfsd.run /etc/service/ipfsd/run +RUN chmod +x /etc/service/*/run + diff --git a/ipfsd.run b/ipfsd.run new file mode 100644 index 0000000..9968360 --- /dev/null +++ b/ipfsd.run @@ -0,0 +1,8 @@ +#!/bin/bash + +export IPFS="/usr/local/bin/ipfs" +export HOME="/home/ipfs" + +cd $HOME + +exec chpst -u ipfs $IPFS daemon diff --git a/sync.run b/sync.run new file mode 100644 index 0000000..6e74dc7 --- /dev/null +++ b/sync.run @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Copyright (C) 2018 JaquerEspeis +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Make a full sync of an Ubuntu mirror. +# This currently requires more than 1TB of storage space and takes a long time. + +chpst -u ipfs /bin/bash << '__EOF__' + +export IPFS=/usr/local/bin/ipfs +export HOME=/home/ipfs +export MIRRORDIR=/mirror +export IPFS_FD_MAX=4096 +mkdir -p "$MIRRORDIR" + +$IPFS config --json Experimental.FilestoreEnabled true + +# Two stage sync of the main Ubuntu mirror. +# More info and options in https://wiki.ubuntu.com/Mirrors/Scripts. +echo "Synchronizing with the main Ubuntu mirror, stage 1." +rsync --recursive --times --links --safe-links --hard-links --stats \ + --exclude "Packages*" --exclude "Sources*" --exclude "Release*" \ + --exclude "InRelease" \ + rsync://archive.ubuntu.com/ubuntu "$MIRRORDIR" + +echo "Adding the mirror files to IPFS." +hash="$($IPFS add --progress --local --nocopy --fscache --quieter --recursive "$MIRRORDIR" | tail -n1)" +echo "Published IPFS hash ${hash}." + +echo "Synchronizing with the main Ubuntu mirror, stage 2." +rsync --recursive --times --links --safe-links --hard-links --stats \ + --delete --delete-after \ + rsync://archive.ubuntu.com/ubuntu \ + "$HOME/mirror" + +# Publish the files on IPFS. +# This uses the experimental filestore: +# https://github.com/ipfs/go-ipfs/issues/3397#issuecomment-284337564 +echo "Adding the mirror files to IPFS." +hash="$($IPFS add --progress --local --nocopy --fscache --quieter --recursive "$MIRRORDIR" | tail -n1)" +echo "Published IPFS hash ${hash}." + +echo "Updating IPNS." +ipns="$($IPFS name publish "${hash}" | cut -d ' ' -f 3 | tr -d ':')" +echo "IPFS Mirror synchronized." +echo "Add the address 'ipfs:/ipns/${ipns}' to your '/etc/apt/sources.list'." +echo "For example, add 'deb ipfs:/ipns/${ipns} xenial main' if you are in Ubuntu 16.04, and you want to use IPFS to get updates from the main archive." +__EOF__