prov/prov.sh

91 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2021-06-10 23:21:09 +00:00
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
function main() {
RELEASE="$(lsb_release -cs)"
apt update
2021-06-10 23:21:09 +00:00
prov-$RELEASE
}
2021-06-10 23:36:28 +00:00
function install-jq {
if which jq >/dev/null 2>&1 ; then
return
fi
apt install -y jq
}
function install-curl {
if which curl >/dev/null 2>&1 ; then
return
fi
apt install -y curl
}
function detect-mirror-country() {
2021-06-10 23:36:28 +00:00
install-jq
install-curl
curl ipinfo.io | jq -r .country
}
function set-mirror-country() {
MURM="main universe restricted multiverse"
COUNTRY="$(detect-mirror-country)"
URL="http://$COUNTRY.archive.ubuntu.com/ubuntu"
2021-06-10 23:37:23 +00:00
cat > /etc/apt/sources.list.new <<EOF
deb $URL $(lsb_release -cs) $MURM
deb $URL $(lsb_release -cs)-updates $MURM
deb $URL $(lsb_release -cs)-backports $MURM
deb $URL $(lsb_release -cs)-security $MURM
EOF
2021-06-10 23:37:23 +00:00
mv /etc/apt/sources.list.new /etc/apt/sources.list
}
2021-06-10 23:21:09 +00:00
function prov-focal() {
set-mirror-country
2021-06-10 23:21:09 +00:00
PKGS="
2021-06-10 23:30:21 +00:00
bridge-utils
byobu
git
golang-go
magic-wormhole
make
net-tools
nmap
ntp
pbzip2
pv
traceroute
unzip
vim
vlan
wireguard-tools
zip
zsh
zstd
2021-06-10 23:21:09 +00:00
"
apt update && \
apt upgrade -y && \
apt install -y $PKGS && \
apt autoremove -y
2021-06-10 23:30:21 +00:00
install-age
}
function install-age () {
2021-06-10 23:36:28 +00:00
if which age >/dev/null 2>&1 ; then
return
fi
2021-06-10 23:30:21 +00:00
cd /tmp
git clone https://filippo.io/age && cd age
go build -o . filippo.io/age/cmd/...
mv ./age /usr/local/bin
cd -
rm -rf /tmp/age
2021-06-10 23:21:09 +00:00
}
2021-06-10 23:30:21 +00:00
main