Skip to content

Instantly share code, notes, and snippets.

@upperstream
Last active February 11, 2018 16:17
Show Gist options
  • Save upperstream/9f95fb708531dab39aaa8b8b22de4a22 to your computer and use it in GitHub Desktop.
Save upperstream/9f95fb708531dab39aaa8b8b22de4a22 to your computer and use it in GitHub Desktop.
Vagrant shell provisioner script to optimise package repository list
#!/bin/sh
case `uname` in
Darwin)
sudo -H -u vagrant ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || sudo -H -u vagrant brew update --force
;;
FreeBSD)
pkg update
;;
Linux)
if uname -r | grep -F tinycore > /dev/null; then
:
else
name=`cat /etc/*release | grep -F "NAME="`
case $name in
*Alpine*)
cp /etc/apk/repositories /etc/apk/repositories.bak
sed 's=http://.*/alpine=http://dl-cdn.alpinelinux.org/alpine=' /etc/apk/repositories.bak > /etc/apk/repositories
apk update
;;
*Arch*)
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
grep '^[^#]' /etc/pacman.d/mirrorlist.bak | rankmirrors -n 6 - > /etc/pacman.d/mirrorlist
;;
*CensOS*)
yum updateinfo
;;
*Debian*)
cp /etc/apt/sources.list /etc/apt/sources.list.bak
sed 's=http://http.us.debian.org/=http://cdn.debian.net/=' /etc/apt/sources.list.bak > /etc/apt/sources.list
apt-get update
;;
*Devuan*)
apt-get update
;;
*Ubuntu*)
cp /etc/apt/sources.list /etc/apt/sources.list.bak
sed 's=http://.*/ubuntu=mirror://mirrors.ubuntu.com/mirrors.txt=' /etc/apt/sources.list.bak > /etc/apt/sources.list
while ! apt-get update; do
sleep 15
done
;;
esac
fi
;;
NetBSD)
echo "PKG_PATH=http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/`uname -m`/`uname -r | cut -f '1 2' -d.`/All" > /etc/pkg_install.conf
;;
OpenBSD)
echo "https://cloudflare.cdn.openbsd.org/pub/OpenBSD" > /etc/installurl
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment