Last active
April 25, 2020 13:37
-
-
Save elreydetoda/6bcd64b8fbd3d737653b12563f478a1d to your computer and use it in GitHub Desktop.
installing all things for ubuntu script
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
#!/usr/bin/env bash | |
set -exuo pipefail | |
################################################## | |
### Variables | |
## apt | |
apt_repos=( | |
'ppa:kgilmer/regolith-stable' # https://blog.elreydetoda.site/minimal-i3-gaps-install-ubuntu/ | |
'ppa:linuxuprising/shutter' # awesome screenshotting software | |
'ppa:erigas/cpupower-gui' | |
) | |
unsupported_ppas_2020=( | |
'regolith' | |
'shutter' | |
'cpupower' | |
) | |
apt_pkgs=( | |
'i3-gaps' # preferred working desktop | |
'rxvt-unicode-256color' # preferred terminal (because of customizations I have) | |
'remmina-plugin-spice' # used for libvirt stuff | |
'remmina-plugin-nx' # used for nomachine stuff | |
'nmap' # because pentesting & sysadmining... | |
'curl' # super useful for scripts | |
'feh' # for changing backgrounds | |
'build-essential' # for building tools | |
'autoconf' # for building tools | |
'glances' # very good sys mon tool | |
'htop' # very good sys mon tool | |
#'shutter' # really good screenshot util ( TODO: doesn't work on 20.04) | |
'shellcheck' # awsome shell-linter | |
'vim-gtk3' # preferred vim because clipboard support | |
'vagrant' # tool for automating vms (I love this tool :D) | |
'cpupower-gui' # tool for adjusting cpu power manually | |
'tmux' | |
'gufw' # gui interface for ufw | |
'virtualbox-qt' | |
'virtualbox-ext-pack' | |
'speedtest-cli' | |
) | |
# command used to generate list on already installed computer | |
# snap list | grep -v classic | cut -d ' ' -f 1 | grep -vP 'gnome|kde|gtk|^core' | tail -n+2 | clipcopy | |
snap_pkgs=( | |
# 'authy' TODO: need to create a beta array | |
'bitwarden' | |
'chromium' | |
'discord' | |
'docker' | |
'doctl' | |
'electronplayer' | |
'gitter-desktop' | |
'irccloud' | |
'irssi' | |
'kteatime' | |
'obs-studio' | |
'onlyoffice-desktopeditors' | |
'postman' | |
'riot-web' | |
'signal-desktop' | |
'simplenote' | |
'spotify' | |
'wire' | |
'zulip' | |
) | |
# command used to generate list on already installed computer | |
# snap list | grep classic | cut -d ' ' -f 1 | grep -vP 'gnome|kde|gtk|mate|boutique$|^core' | tail -n+2 | clipcopy | |
snap_classic_pkgs=( | |
'fwupd' | |
'go' | |
'hub' | |
'multipass' | |
'powershell' | |
'skype' | |
'slack' | |
) | |
## system | |
current_release="$(lsb_release -r | cut -f 2 | tr -d '.')" | |
################################################## | |
## functions | |
# system config changes | |
function sys_changes(){ | |
net_manager | |
} | |
# NetworkManager | |
function net_manager(){ | |
# enable mac address randomization on a per boot cadence | |
sudo tee /etc/NetworkManager/conf.d/30-anon.conf << 'EOF' | |
# https://elrey.casa/info/netman | |
[device-anon] | |
wifi.scan-rand-mac-address=yes | |
[connection-anon] | |
connection.stable-id='${CONNECTION}/${BOOT}' | |
ethernet.cloned-mac-address=stable | |
wifi.cloned-mac-address=stable | |
ipv6.ip6-privacy=2 | |
EOF | |
sudo systemctl restart NetworkManager | |
} | |
# looping over arrays | |
function loop_array(){ | |
for thing in ${2} ; do | |
sudo "${1}" "${thing}" | |
done | |
} | |
function currently_supported(){ | |
case "${current_release}" in | |
2004) | |
un_supported=1 | |
;; | |
esac | |
} | |
function 2004_specific(){ | |
# this is hacking till it is official | |
current_alteration="${1}" | |
extra="${2}" | |
case "${current_alteration[@]}" in | |
apt) | |
comparison_string="$( echo "${unsupported_ppas_2020[@]}" | tr ' ' '|' )" | |
if printf '%s' "${extra}" | grep -P "${comparison_string}" - 1>/dev/null ; then | |
apt_ppa_conv="$(printf '%s' "${extra}" | cut -d ':' -f 2 | sed 's,/,-ubuntu-,')" | |
apt_source_file="/etc/apt/sources.list.d/${apt_ppa_conv}-$(lsb_release -c | cut -f 2).list" | |
# swapping focal to eoan (they are close enough :D) and don't hate me... | |
sudo sed -i.save 's/focal/eoan/g' "${apt_source_file}" | |
sudo mv "${apt_source_file}" "$(printf '%s' "${apt_source_file}" | sed 's/focal/eoan/g')" | |
else | |
return 0 | |
fi | |
esac | |
} | |
function enable_src_repos(){ | |
sed 's/^# deb-src/deb-src/' /etc/apt/sources.list | grep deb-src | sudo tee /etc/apt/sources.list.d/sources-src.list | |
} | |
################################################## | |
function main(){ | |
currently_supported | |
# installing all extra repos | |
for repo in "${apt_repos[@]}" ; do | |
if [[ -n "${un_supported}" ]] ; then | |
sudo add-apt-repository -ny "${repo}" | |
eval "${current_release}_specific" 'apt' "${repo}" | |
sudo apt update | |
else | |
sudo add-apt-repository -y "${repo}" | |
fi | |
done | |
# installing all apt packages | |
sudo apt install -y "${apt_pkgs[@]}" | |
# installing all snap packages | |
# TODO: handle when all snaps are installed w/if statement | |
sudo snap install "${snap_pkgs[@]}" | |
# installing all classic snap packages | |
for classic_snap in "${snap_classic_pkgs[@]}" ; do | |
sudo snap install "${classic_snap}" --classic | |
done | |
enable_src_repos | |
sys_changes | |
} | |
main "${@}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment