Skip to content

Instantly share code, notes, and snippets.

@caius
Created February 6, 2018 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caius/abb6775a912a1553071da2949cd1b907 to your computer and use it in GitHub Desktop.
Save caius/abb6775a912a1553071da2949cd1b907 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Syncs pkgsrc releases to manta
#
# MIT License - Caius Durling <dev@caius.name>
#
[[ "$TRACE" ]] && set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
set -o noclobber
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly pkgsrc_root="/${MANTA_USER}/public/pkgsrc.chd.cloud"
log() {
if [[ -z ${2:-} ]]; then
level="INFO"
else
level="$1"
shift
fi
echo -e "$(date +%FT%T) $level: $@"
}
log "pkgsync reporting for duty"
if ! which manta-sync > /dev/null 2>&1; then
log "FATAL" "manta-sync required to sync pkgsrc. Please run\n npm install -g manta-sync"
exit 1
fi
cd $DIR/..
for source in $(find . -type d -maxdepth 1 -not -name bin -not -name .)
do
source="$(basename "${source}")"
destination="${pkgsrc_root}/${source}/x86_64/All"
log "Syncing ${source} to ${destination}"
manta-sync $@ "${source}" "${destination}"
log "${source} synced to ${destination}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment