From b177ded5165f98dc5475ef7ec865656ae722f50d Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Tue, 2 Oct 2018 00:19:40 -0700 Subject: [PATCH] fix permissions, capitalize variable names --- sync.run | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sync.run b/sync.run index 531b97f..4f97eed 100644 --- a/sync.run +++ b/sync.run @@ -24,20 +24,20 @@ export IPFS_PATH=/var/lib/ipfs if [[ ! -d $MIRROR_DIR ]]; then mkdir -p $MIRROR_DIR - chown ipfs:ipfs $MIRROR_DIR fi +chown ipfs:ipfs $MIRROR_DIR export GNUPGHOME=/etc/debmirror/gnupg if [[ ! -d $GNUPGHOME ]]; then mkdir -p $GNUPGHOME - chown ipfs:ipfs $GNUPGHOME fi +chown ipfs:ipfs $GNUPGHOME chpst -u ipfs /bin/bash << '__EOF__' export IPFS=/usr/local/bin/ipfs -export HOME=/home/ipfs +export HOME=/var/lib/ipfs export IPFS_FD_MAX=4096 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." +set -x # error out if the sync fails + debmirror \ --keyring $GNUPGHOME/trustedkeys.kbx \ -a ${MIRROR_ARCHITECTURES:-amd64} \ @@ -60,19 +62,20 @@ debmirror \ --method=http \ $MIRROR_DIR +set +x # resume ignoring errors # 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 "$MIRROR_DIR" | tail -n1)" -echo "Published IPFS hash ${hash}." +HASH="$($IPFS add --progress --local --nocopy --fscache --quieter --recursive "$MIRROR_DIR" | tail -n1)" +echo "Published (added/pinned) /ipfs/${HASH}." 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 "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 "Add the address 'ipfs:/ipns/${IPNS}' to your '/etc/apt/sources.list'." +echo "For example, add 'deb ipfs:/ipns/${IPNS} xenial main'" __EOF__ sleep 3600 # wait 1h before syncing again