Last active
February 11, 2018 16:17
-
-
Save upperstream/9f95fb708531dab39aaa8b8b22de4a22 to your computer and use it in GitHub Desktop.
Vagrant shell provisioner script to optimise package repository list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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