#!/usr/bin/env zsh # # Dinand's install script # # Assumptions: # # this script can be run on a linux mint installation with sudo, apt-get and zsh # # stdout is logged to install.log, stderr is shown in console # thus, look in the console for errors and find debugging info in install.log # # this install script is assumed to be idempotent # all subroutines must ensure their result is idempotent # # Usage: # ./install_script # # Main procedure main() { prepare_log empty_line print_info "Starting installation ..." empty_line empty_line print_info "Error messages should be visible in the console" print_info "Complete logs will be stored seperately in ~/install.log" empty_line print_error "This script is ALMOST (but not entirely) non-interactive." print_error "Please standby to re-enter sudo password. Also, fuck composer." empty_line ensure_sudo aptitude_update drivers gnome install_external_repositories utilities development_tools terminal networking graphical_tools programming_dependencies php_development ruby_development node_development docker_kubernetes aws cleanup empty_line print_success "Installation script succesfully completed!" print_info "You are awesome." empty_line } # # Below here all methods describing software to be installed # aptitude_update() { print_info "Updating aptitude" sudo apt-get update 1>>~/install.log sudo apt-get upgrade -y 1>>~/install.log print_success "Aptitude update complete" } drivers() { aptitude_install \ nvidia-driver-530 } gnome() { aptitude_install \ vanilla-gnome-desktop } install_external_repositories() { install_external_repository \ lens \ https://downloads.k8slens.dev/keys/gpg \ https://downloads.k8slens.dev/apt/debian install_external_repository \ hashicorp \ https://apt.releases.hashicorp.com/gpg \ https://apt.releases.hashicorp.com/ \ jammy install_external_repository \ vscodium \ https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg \ https://download.vscodium.com/debs \ vscodium } utilities() { aptitude_install \ alacarte \ barrier \ blueman \ butt \ dconf-editor \ default-jre \ firefox \ gparted \ gpaste \ gpick \ hunspell-nl \ keepassxc \ libreoffice \ nautilus-nextcloud \ pavucontrol \ rpi-imager \ steam \ totem \ transmission-gtk \ unison \ unison-gtk \ flatpak_install \ com.authy.Authy \ com.discordapp.Discord \ com.slack.Slack \ com.spotify.Client \ org.ferdium.Ferdium \ install_from_seperate_repository thunderbird ppa:mozillateam/thunderbird-next } development_tools() { aptitude_install \ codium \ filezilla \ lens \ mysql-client \ mysql-server \ nomad \ python3 \ sublime-merge \ sublime-text \ flatpak_install \ com.axosoft.GitKraken \ io.dbeaver.DBeaverCommunity \ custom_install https://raw.githubusercontent.com/kamranahmedse/git-standup/master/installer.sh custom_install https://cli-assets.heroku.com/install-ubuntu.sh } networking() { aptitude_install \ net-tools \ openssh-server \ resolvconf \ wireguard \ } terminal() { aptitude_install \ aptitude \ git-flow \ htop \ preload \ tilix \ tree \ tty-clock \ direnv \ dkms \ } graphical_tools() { aptitude_install \ darktable \ ffmpeg \ gimp \ inkscape \ kazam \ krita \ obs-studio \ flatpak_install \ com.ultimaker.cura \ net.sourceforge.Hugin \ org.blender.Blender \ } programming_dependencies() { # libssl is for node # zlib1g-dev is for ruby aptitude_install \ libssl-dev \ zlib1g-dev \ libyaml-dev\ } php_development() { print_info "Installing PHP" add_apt_repository ppa:ondrej/php aptitude_install \ php \ php-bcmath \ php-curl \ php-gd \ php-imagick \ php-intl \ php-mbstring \ php-mysql \ php-sqlite3 \ php-xml \ php-zip \ composer \ { composer global require psy/psysh:@stable } 1>>~/install.log ensure_sudo # Because composer breaks sudo print_success "PHP Installed" } ruby_development() { local RUBY_VERSION="3.2.0" print_info "Preparing ruby development environment ..." { rm -rf ~/.rbenv/ git clone --depth=1 https://github.com/rbenv/rbenv.git ~/.rbenv mkdir -p ~/.rbenv/plugins git clone --depth=1 https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build git clone --depth=1 https://github.com/rbenv/rbenv-vars.git ~/.rbenv/plugins/rbenv-vars export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH" rbenv install "$RUBY_VERSION" rbenv global "$RUBY_VERSION" ruby -v gem install bundler dip gem update gem update --system } 1>>~/install.log print_success "Ruby development environment done!" } node_development() { print_info "Installing latest node ..." { # Install nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash # Install node nvm install node --latest-npm nvm i -g npm # Install npm packages npm install -g \ prettier \ yarn \ } 1>>~/install.log print_success "Installed node, yarn and packages!" } docker_kubernetes() { print_info "Installing docker, kubernetes, kubectl, flux ..." { # # Docker # curl -fsSL https://get.docker.com | sudo sh sudo apt install docker-buildx-plugin # Fix permissions sudo groupadd docker -f sudo usermod -aG docker $USER # # kubectl 1.14 # curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl # # Flux # curl -s https://toolkit.fluxcd.io/install.sh | sudo bash } 1>>~/install.log print_success "Docker, kubernetes installed!" } aws() { print_info "AWS, awscli, ekstcl and aws-iam-authenticator ..." { # awscli curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install rm -rf aws rm awscliv2.zip # eksctl curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp sudo mv /tmp/eksctl /usr/local/bin # aws-iam-authenticator curl -o aws-iam-authenticator https://s3.us-west-2.amazonaws.com/amazon-eks/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator chmod +x ./aws-iam-authenticator sudo mv aws-iam-authenticator /usr/local/bin } 1>>~/install.log print_success "AWS installed!" } cleanup() { print_info "Performing cleanup tasks ..." { # fix flatpak cursors flatpak --user override --filesystem=/home/$USER/.icons/:ro flatpak --user override --filesystem=/usr/share/icons/:ro # Remove known_hosts rm ~/.ssh/known_hosts # increase amount of inotify watchers echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p # trying to fix automatically installed packages sudo apt-get -y --fix-broken install # Cleanup aptitude sudo apt-get autoremove --purge -y sudo apt-get clean -y } 1>>~/install.log print_success "Cleanup complete!" } # # Subroutines for dealing with various tasks below here # # # Aptitude # # Download and install external deb install_external_deb() { print_info "Installing $1 from external location ..." print_info "Downloading from $2 ..." { wget -nv -O "$1".deb $2 sudo dpkg -i "$1".deb sudo apt-get -y --fix-broken install rm "$1".deb } 1>>~/install.log print_success "$1 installed!" } install_from_seperate_repository() { print_info "Installing $1 from $2" add_apt_repository $2 aptitude_install $1 } install_external_repository() { local apt_name="$1" local gpg_url="$2" local apt_url="$3" local release="${4:-stable}" local line="${5:-non-free}" local gpg_name="/usr/share/keyrings/$apt_name-archive-keyring.gpg" { curl -fsSL $gpg_url | gpg --dearmor | \ sudo tee $gpg_name > /dev/null echo "deb [arch=amd64 signed-by=$gpg_name] $apt_url $release $line" | \ sudo tee /etc/apt/sources.list.d/$apt_name.list > /dev/null } 1>>~/install.log } # Add apt repository add_apt_repository() { print_info "Adding repository $1" # Remove the repository first, if it exists sudo add-apt-repository -r -y $1 1>>~/install.log # Now create t sudo add-apt-repository -y $1 1>>~/install.log aptitude_update print_success "Added repository $1" } # Remove aptitude software aptitude_remove() { print_info "Removing the following packages through aptitude ..." print_dump "$@" sudo apt-get remove "$@" -y 1>>~/install.log print_success "Aptitude removal succesful!" } # Install software through aptitude aptitude_install() { print_info "Installing the following packages through aptitude ..." empty_line print_dump "$@" sudo apt-get install "$@" -y 1>>~/install.log print_success "Aptitude install succesful!" empty_line } custom_install() { print_info "Installing custom sh from $@ ..." empty_line curl -L $@ | sudo sh print_success "Custom install finished!" empty_line } # install flatpak software flatpak_install() { print_info "Installing the following packages through flatpak ..." empty_line print_dump "$@" sudo flatpak install flathub "$@" --noninteractive >>~/install.log print_success "Flatpak install succesful!" empty_line } # # Printing messages # # Used to print messages print_info() { echo -e "\e[43m\e[30m$@\e[0m" log $@ } print_success() { echo -e "\e[42m\e[30m$@\e[0m" log $@ } print_error() { echo -e "\e[41m$@\e[0m" log $@ } print_dump() { echo $@ log $@ } empty_line() { echo "" log "" } log() { echo "$@" >> ~/install.log } # # Misc # # Make sure we have root rights ensure_sudo() { print_info "Asking for root permission ..." if ! sudo true; then print_error "Failed to attain root" exit 1 else print_success "Attained root" fi } prepare_log() { print_info "Creating logfile 'install.log'" rm ~/install.log touch ~/install.log } # Entrypoint to main function main "$@"