Skip to content

Instantly share code, notes, and snippets.

@uburuntu
Last active January 7, 2024 14:02
Show Gist options
  • Save uburuntu/0166f0c93b5954b48fda7a0e9601e955 to your computer and use it in GitHub Desktop.
Save uburuntu/0166f0c93b5954b48fda7a0e9601e955 to your computer and use it in GitHub Desktop.
New Machine Initialization
#!/bin/bash
# Main packages
sudo apt-get update
sudo apt-get install -y mc nano git curl htop keychain mosh libcurl4-openssl-dev libssl-dev python3.11-dev python3-pip
sudo apt-get install -y libxml2-dev libxslt-dev libtiff-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev
sudo apt-get upgrade
# Install Docker
# https://docs.docker.com/engine/install/ubuntu/
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Post-installation steps
# https://docs.docker.com/engine/install/linux-postinstall/
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
# Start Docker
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
# Set ssh and gpg keys
gpg --import ~/.ssh/key.gpg
# Set Git config
git config --global user.name "uburuntu"
git config --global user.email uburuntu@users.noreply.github.com
git config --global user.signingkey 59E643252F903BE1
git config --global commit.gpgsign true
# Auto updates
sudo apt-get install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
# Disable GUI on boot
# https://askubuntu.com/questions/1056363/how-to-disable-gui-on-boot-in-18-04-bionic-beaver
sudo systemctl set-default multi-user.target
# To start Gnome session
sudo systemctl start gdm3.service
alias dc='docker-compose'
alias dcup='docker-compose up --build -d --force-recreate'
alias gitup='git pull && docker-compose up --build -d --force-recreate'
export GPG_TTY=$(tty)
eval $(keychain --eval github)
# /etc/profile.d/motd.sh OR /etc/update-motd.d/01-custom
# Better start message
# https://github.com/dylanaraps/neofetch/wiki/Installation
printf "\n"
neofetch
# /root/.config/neofetch/config.conf
print_info() {
# info title
# info underline
info "OS" distro
info "Host" model
info "Kernel" kernel
info "CPU" cpu
info "GPU" gpu
# info "Packages" packages
# info "Shell" shell
# info "Resolution" resolution
# info "DE" de
# info "WM" wm
# info "WM Theme" wm_theme
# info "Theme" theme
# info "Icons" icons
# info "Terminal" term
# info "Terminal Font" term_font
info underline
info "CPU Usage" cpu_usage
info "Memory" memory
# info "GPU Driver" gpu_driver # Linux/macOS only
info "Disk" disk
info underline
info "Uptime" uptime
# info "Battery" battery
# info "Font" font
# info "Song" song
# info "Local IP" local_ip
# info "Public IP" public_ip
# info "Users" users
# info "Install Date" install_date
# info "Locale" locale # This only works on glibc systems.
info line_break
# info cols
# info line_break
}
# /usr/bin/neofetch
# Add CPU temp to the output.
sensors=$(sensors)
deg="[${sensors##*:}]"
adduser ramzan
sudo usermod -a -G sudo ramzan
sudo usermod -a -G docker ramzan
# https://support.nordvpn.com/Connectivity/Linux/
sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)
nordvpn login
nordvpn whitelist add port 22
nordvpn whitelist add subnet 172.17.0.0/16
nordvpn set dns 1.1.1.1 8.8.8.8
nordvpn set protocol tcp
nordvpn connect ukraine
nordvpn set autoconnect on ukraine
# Docs: https://notes.enovision.net/linux/changing-dns-with-resolve
# Conf file: /etc/systemd/resolved.conf
# Generated file: /etc/resolv.conf
# $ service systemd-resolved restart
# $ systemd-resolve --status
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=1.1.1.1
FallbackDNS=8.8.8.8
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes
# /etc/ssh/sshd_config
# https://help.ubuntu.ru/wiki/ssh
Protocol 2
Port 2202
PasswordAuthentication no
PubkeyAuthentication yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment