fix permissions, capitalize variable names
This commit is contained in:
parent
de37e36676
commit
b177ded516
19
sync.run
19
sync.run
@ -24,20 +24,20 @@ export IPFS_PATH=/var/lib/ipfs
|
|||||||
|
|
||||||
if [[ ! -d $MIRROR_DIR ]]; then
|
if [[ ! -d $MIRROR_DIR ]]; then
|
||||||
mkdir -p $MIRROR_DIR
|
mkdir -p $MIRROR_DIR
|
||||||
chown ipfs:ipfs $MIRROR_DIR
|
|
||||||
fi
|
fi
|
||||||
|
chown ipfs:ipfs $MIRROR_DIR
|
||||||
|
|
||||||
export GNUPGHOME=/etc/debmirror/gnupg
|
export GNUPGHOME=/etc/debmirror/gnupg
|
||||||
|
|
||||||
if [[ ! -d $GNUPGHOME ]]; then
|
if [[ ! -d $GNUPGHOME ]]; then
|
||||||
mkdir -p $GNUPGHOME
|
mkdir -p $GNUPGHOME
|
||||||
chown ipfs:ipfs $GNUPGHOME
|
|
||||||
fi
|
fi
|
||||||
|
chown ipfs:ipfs $GNUPGHOME
|
||||||
|
|
||||||
chpst -u ipfs /bin/bash << '__EOF__'
|
chpst -u ipfs /bin/bash << '__EOF__'
|
||||||
|
|
||||||
export IPFS=/usr/local/bin/ipfs
|
export IPFS=/usr/local/bin/ipfs
|
||||||
export HOME=/home/ipfs
|
export HOME=/var/lib/ipfs
|
||||||
export IPFS_FD_MAX=4096
|
export IPFS_FD_MAX=4096
|
||||||
|
|
||||||
gpg --no-default-keyring --keyring $GNUPGHOME/trustedkeys.kbx --import \
|
gpg --no-default-keyring --keyring $GNUPGHOME/trustedkeys.kbx --import \
|
||||||
@ -47,6 +47,8 @@ $IPFS config --json Experimental.FilestoreEnabled true
|
|||||||
|
|
||||||
echo "Synchronizing with the main Ubuntu mirror."
|
echo "Synchronizing with the main Ubuntu mirror."
|
||||||
|
|
||||||
|
set -x # error out if the sync fails
|
||||||
|
|
||||||
debmirror \
|
debmirror \
|
||||||
--keyring $GNUPGHOME/trustedkeys.kbx \
|
--keyring $GNUPGHOME/trustedkeys.kbx \
|
||||||
-a ${MIRROR_ARCHITECTURES:-amd64} \
|
-a ${MIRROR_ARCHITECTURES:-amd64} \
|
||||||
@ -60,19 +62,20 @@ debmirror \
|
|||||||
--method=http \
|
--method=http \
|
||||||
$MIRROR_DIR
|
$MIRROR_DIR
|
||||||
|
|
||||||
|
set +x # resume ignoring errors
|
||||||
# Publish the files on IPFS.
|
# Publish the files on IPFS.
|
||||||
# This uses the experimental filestore:
|
# This uses the experimental filestore:
|
||||||
# https://github.com/ipfs/go-ipfs/issues/3397#issuecomment-284337564
|
# https://github.com/ipfs/go-ipfs/issues/3397#issuecomment-284337564
|
||||||
|
|
||||||
echo "Adding the mirror files to IPFS."
|
echo "Adding the mirror files to IPFS."
|
||||||
hash="$($IPFS add --progress --local --nocopy --fscache --quieter --recursive "$MIRROR_DIR" | tail -n1)"
|
HASH="$($IPFS add --progress --local --nocopy --fscache --quieter --recursive "$MIRROR_DIR" | tail -n1)"
|
||||||
echo "Published IPFS hash ${hash}."
|
echo "Published (added/pinned) /ipfs/${HASH}."
|
||||||
|
|
||||||
echo "Updating IPNS."
|
echo "Updating IPNS."
|
||||||
ipns="$($IPFS name publish "${hash}" | cut -d ' ' -f 3 | tr -d ':')"
|
IPNS="$($IPFS name publish "${HASH}" | cut -d ' ' -f 3 | tr -d ':')"
|
||||||
echo "IPFS Mirror synchronized."
|
echo "IPFS Mirror synchronized."
|
||||||
echo "Add the address 'ipfs:/ipns/${ipns}' to your '/etc/apt/sources.list'."
|
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."
|
echo "For example, add 'deb ipfs:/ipns/${IPNS} xenial main'"
|
||||||
__EOF__
|
__EOF__
|
||||||
|
|
||||||
sleep 3600 # wait 1h before syncing again
|
sleep 3600 # wait 1h before syncing again
|
||||||
|
Loading…
Reference in New Issue
Block a user