change dirs
This commit is contained in:
parent
2c63df3b7f
commit
4ef62b87db
|
@ -6,12 +6,12 @@ based on sync_mirror.sh from JáquerEspeis
|
|||
|
||||
or
|
||||
|
||||
(image uses /mirror /and /home/ipfs/.ipfs)
|
||||
(image uses /var/lib/ubuntumirror and /var/lib/ipfs)
|
||||
|
||||
```
|
||||
docker run \
|
||||
-v /host/dir/path/to/mirror:/mirror \
|
||||
-v /host/dir/path/to/ipfsrepo:/home/ipfs/.ipfs \
|
||||
-v /host/dir/path/to/mirror:/var/lib/ubuntumirror \
|
||||
-v /host/dir/path/to/ipfsrepo:/var/lib/ipfs \
|
||||
-d sneak/ipfs-ubuntu-mirror
|
||||
```
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ sleep 1 # prevent cpu spike on looping
|
|||
|
||||
export IPFS="/usr/local/bin/ipfs"
|
||||
export HOME="/home/ipfs"
|
||||
|
||||
chown ipfs:ipfs $HOME
|
||||
|
||||
cd $HOME
|
||||
|
||||
if [[ ! -d $HOME/.ipfs ]]; then
|
||||
export IPFS_DIR=/var/lib/ipfs
|
||||
|
||||
if [[ ! -d $IPFS_DIR ]]; then
|
||||
mkdir -p $IPFS_DIR
|
||||
chown ipfs:ipfs $IPFS_DIR
|
||||
chpst -u ipfs $IPFS init
|
||||
fi
|
||||
|
||||
|
|
30
sync.run
30
sync.run
|
@ -19,15 +19,20 @@
|
|||
|
||||
sleep 1 # prevent cpu spike on looping
|
||||
|
||||
chown ipfs:ipfs /mirror
|
||||
export MIRROR_DIR=/var/lib/ubuntumirror
|
||||
export IPFS_DIR=/var/lib/ipfs
|
||||
|
||||
|
||||
if [[ ! -d $MIRROR_DIR ]]; then
|
||||
mkdir -p $MIRROR_DIR
|
||||
chown ipfs:ipfs $MIRROR_DIR
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
|
@ -37,23 +42,30 @@ 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" -v \
|
||||
rsync://archive.ubuntu.com/ubuntu "$MIRRORDIR"
|
||||
rsync://archive.ubuntu.com/ubuntu "$MIRROR_DIR"
|
||||
|
||||
echo "Adding the mirror files to IPFS."
|
||||
hash="$($IPFS add --progress --local --nocopy --fscache --quieter --recursive "$MIRRORDIR" | tail -n1)"
|
||||
hash="$(
|
||||
$IPFS add --progress --local --nocopy --fscache --quieter
|
||||
--recursive "$MIRROR_DIR" | tail -n1)"
|
||||
echo "Published IPFS hash ${hash}."
|
||||
|
||||
echo "Updating IPNS."
|
||||
ipns="$($IPFS name publish "${hash}" | cut -d ' ' -f 3 | tr -d ':')"
|
||||
|
||||
# FIXME(sneak) use debmirror to improve this in the future
|
||||
echo "Synchronizing with the main Ubuntu mirror, stage 2."
|
||||
rsync --recursive --times --links --safe-links --hard-links --stats \
|
||||
rsync --recursive --times --links --safe-links --hard-links --stats \
|
||||
--delete --delete-after -v \
|
||||
rsync://archive.ubuntu.com/ubuntu \
|
||||
"$HOME/mirror"
|
||||
"$MIRROR_DIR"
|
||||
|
||||
# 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)"
|
||||
hash="$($IPFS add --progress --local --nocopy --fscache --quieter
|
||||
--recursive "$MIRROR_DIR" | tail -n1)"
|
||||
echo "Published IPFS hash ${hash}."
|
||||
|
||||
echo "Updating IPNS."
|
||||
|
@ -61,6 +73,6 @@ 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__
|
||||
|
||||
sleep 3600 # wait 1h before syncing again
|
||||
__EOF__
|
||||
|
|
Loading…
Reference in New Issue