Skip to content

Instantly share code, notes, and snippets.

@raphaelbruno
Last active May 13, 2024 17:10
Show Gist options
  • Save raphaelbruno/d12fdf1b86335d2d2500e22f16b3d5b6 to your computer and use it in GitHub Desktop.
Save raphaelbruno/d12fdf1b86335d2d2500e22f16b3d5b6 to your computer and use it in GitHub Desktop.
Postinstall
#!/bin/bash
# ###########################################################
# Functions
# ###########################################################
RED=`tput setaf 1`
GREEN=`tput setaf 2`
YELLOW=`tput setaf 3`
BLUE=`tput setaf 4`
NOCOLOR=`tput sgr0`
printcenter(){
local x
local y
text="$*"
x=$(( ($(tput cols) - ${#text}) / 2))
echo -ne "\E[6n";read -sdR y; y=$(echo -ne "${y#*[}" | cut -d';' -f1)
echo -ne "\033[${y};${x}f$*"
echo
}
printtopic(){
LINE_CHAR=${3:-―}
printf ${2:-$NOCOLOR}
eval printf %.0s$LINE_CHAR '{1..'"${COLUMNS:-$(tput cols)}"\}; echo
printcenter $1
eval printf %.0s$LINE_CHAR '{1..'"${COLUMNS:-$(tput cols)}"\}; echo
printf $NOCOLOR
}
printheader(){
printtopic "$1" ${2:-$NOCOLOR} █
}
printheader "Let me do the hard work and go get some ☕" $BLUE
echo "Setup multiple keyboard layout and cedilla (for international keyboards)? (y/n)" && read CONFIRM_KEYBOARD
echo "Activate AMDGPU and Vulkan support (for systems with systemd-boot)? (y/n)" && read CONFIRM_AMDGPU
echo "Change Icons to papirus icon theme? (y/n)" && read CONFIRM_ICONS
echo "Remove Flatpak support? (y/n)" && read CONFIRM_REMOVE_FLATPAK
echo "Remove LibreOffice and install ONLYOFFICE? (y/n)" && read CONFIRM_ONLYOFFICE
echo "Remove Mozilla Firefox and install Google Chrome? (y/n)" && read CONFIRM_CHROME
echo "Install some cool games? (y/n)" && read CONFIRM_GAMES
sudo echo
# ###########################################################
# Directories
# ###########################################################
printtopic "Creating temporary DIR..."
DIR=~/.tmp
DIR_DEB=$DIR/deb
DIR_ICONS=~/.icons
DIR_RETROARCH=~/.config/retroarch
DIR_FONTS=/usr/share/fonts/truetype
# Temporary Folder
rm -rf $DIR
mkdir -p $DIR
mkdir -p $DIR_DEB
mkdir -p $DIR_ICONS
mkdir -p $DIR_RETROARCH
sudo mkdir -p $DIR_FONTS/firacode-nerd
# ###########################################################
# Settings
# ###########################################################
printtopic "Setting up some stuffs..."
rm ~/.local/share/keyrings/login.keyring
if [ $CONFIRM_KEYBOARD == "y" ] || [ $CONFIRM_KEYBOARD == "Y" ]; then
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+alt-intl')]"
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+alt-intl'), ('xkb', 'br')]"
echo "GTK_IM_MODULE=cedilla" | sudo tee -a ~/.profile
echo "QT_IM_MODULE=cedilla" | sudo tee -a ~/.profile
sudo sh -c "sed -e 's@modifier_map Mod3 { Scroll_Lock };@# modifier_map Mod3 { Scroll_Lock };@g' /usr/share/X11/xkb/symbols/br > /usr/share/X11/xkb/symbols/br.tmp"
sudo mv /usr/share/X11/xkb/symbols/br.tmp /usr/share/X11/xkb/symbols/br
fi
if [ $CONFIRM_AMDGPU == "y" ] || [ $CONFIRM_AMDGPU == "Y" ]; then
sudo kernelstub -a "radeon.si_support=0 radeon.cik_support=0 amdgpu.si_support=1 amdgpu.cik_support=1"
fi
# Gnome Improvements
gsettings set org.gnome.shell.extensions.dash-to-dock show-trash true
gsettings set org.gnome.shell.window-switcher current-workspace-only false
gsettings set org.gnome.desktop.wm.keybindings switch-applications "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-windows "['<Super>Tab', '<Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-windows-backward "['<Shift><Super>Tab', '<Shift><Alt>Tab']"
# ###########################################################
# Fonts an Icons
# ###########################################################
printtopic "Downloading fonts..."
# Fonts
wget -O $DIR/firacode.zip https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip
unzip $DIR/firacode.zip -d $DIR/firacode
sudo cp $DIR/firacode/*.ttf $DIR_FONTS/firacode-nerd
sudo fc-cache -f -v
# Icons
if [ $CONFIRM_ICONS == "y" ] || [ $CONFIRM_ICONS == "Y" ]; then
printtopic "Installing Papirus Icon Theme..."
sudo add-apt-repository -y ppa:papirus/papirus
sudo apt-get update
sudo apt-get install -y papirus-icon-theme papirus-folders
gsettings set org.gnome.desktop.interface icon-theme 'Papirus-Dark'
papirus-folders -C darkcyan --theme Papirus-Dark
fi
# ###########################################################
# Update
# ###########################################################
printtopic "Updating the system..."
sudo apt update
sudo apt full-upgrade -y
# ###########################################################
# Remove Applications
# ###########################################################
printtopic "Removing unused applications..."
if [ $CONFIRM_CHROME == "y" ] || [ $CONFIRM_CHROME == "Y" ]; then
sudo apt remove -y --purge firefox
fi
if [ $CONFIRM_ONLYOFFICE == "y" ] || [ $CONFIRM_ONLYOFFICE == "Y" ]; then
sudo apt remove -y --purge "libreoffice*"
fi
if [ $CONFIRM_REMOVE_FLATPAK == "y" ] || [ $CONFIRM_REMOVE_FLATPAK == "Y" ]; then
printtopic "Removing Flatpak support..."
flatpak uninstall --unused
sudo apt remove -y --autoremove flatpak
sudo apt purge -y flatpak
sudo rm -r $HOME/.local/share/flatpak/
fi
sudo apt clean -y
sudo apt autoremove -y
# ###########################################################
# Dependencies
# ###########################################################
printtopic "Installing some dependencies..."
sudo apt install -y git ca-certificates curl gnupg lsb-release
sudo apt install -y ubuntu-restricted-extras
sudo apt install -y gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good libavcodec-extra gstreamer1.0-libav chromium-codecs-ffmpeg-extra libdvd-pkg
sudo dpkg-reconfigure libdvd-pkg
# ###########################################################
# Some Mandatory Applications
# ###########################################################
printtopic "Installing mandatory applications..."
sudo add-apt-repository -y ppa:umang/indicator-stickynotes
sudo apt update
sudo apt install -y zsh evolution cheese menulibre htop neofetch gparted cpu-x mangohud gamemode vulkan-tools dconf-editor jstest-gtk indicator-stickynotes
sudo apt install -y gnome-maps gnome-characters gnome-tweaks
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
sed -e 's@ZSH_THEME="robbyrussell"@ZSH_THEME="powerlevel10k/powerlevel10k"@g' -e 's@plugins=(git)@plugins=(git zsh-autosuggestions zsh-syntax-highlighting)@g' ~/.zshrc > ~/.zshrc.tmp
mv -f ~/.zshrc.tmp ~/.zshrc
# ###########################################################
# ONLYOFFICE
# ###########################################################
if [ $CONFIRM_ONLYOFFICE == "y" ] || [ $CONFIRM_ONLYOFFICE == "Y" ]; then
printtopic "Installing Office..."
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
gpg --no-default-keyring --keyring gnupg-ring:/tmp/onlyoffice.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
chmod 644 /tmp/onlyoffice.gpg
sudo chown root:root /tmp/onlyoffice.gpg
sudo mv /tmp/onlyoffice.gpg /etc/apt/trusted.gpg.d/
echo 'deb https://download.onlyoffice.com/repo/debian squeeze main' | sudo tee -a /etc/apt/sources.list.d/onlyoffice.list
sudo apt update
sudo apt install -y onlyoffice-desktopeditors
fi
# ###########################################################
# Applications Needs Download
# ###########################################################
printtopic "Installing applications needs download..."
if [ $CONFIRM_CHROME == "y" ] || [ $CONFIRM_CHROME == "Y" ]; then
wget -O $DIR_DEB/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
fi
wget -O $DIR_DEB/dbeaver.deb https://dbeaver.io/files/dbeaver-ce_latest_amd64.deb
wget -O $DIR_DEB/stl-thumb.deb https://github.com/unlimitedbacon/stl-thumb/releases/download/v0.5.0/stl-thumb_0.5.0_amd64.deb
sudo apt install -y $DIR_DEB/*
# ###########################################################
# Development Applications
# ###########################################################
printtopic "Installing development applications 💻..."
sudo apt install -y code
bash -c "$(wget -qO- https://raw.githubusercontent.com/harry-cpp/code-nautilus/master/install.sh)"
mkdir -p ~/.config/Code/User
if [ -f "settings.json" ]; then
mv settings.json ~/.config/Code/User
fi
if [ -f "keybindings.json" ]; then
mv keybindings.json ~/.config/Code/User
fi
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] 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 update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER
echo "deb [trusted=yes arch=amd64] https://download.konghq.com/insomnia-ubuntu/ default all" | sudo tee -a /etc/apt/sources.list.d/insomnia.list
sudo apt update
sudo apt install -y insomnia
sudo apt install -y nodejs npm
sudo npm install -g n
sudo n stable
sudo npm install -g npm
sudo npm install -g yarn
# ###########################################################
# Graphic Applications
# ###########################################################
printtopic "Installing graphic applications 💅..."
sudo add-apt-repository -y ppa:freecad-maintainers/freecad-stable
sudo apt-get update
sudo apt install -y blender freecad drawing f3d
(cd $DIR && git clone https://github.com/raphaelbruno/freecad-preferences && cd freecad-preferences && git submodule update --init --recursive && ./preferences.sh install)
# #################################################
# L3110
# #################################################
printtopic "Installing the printer 🖨️..."
if [ -f "l3110.zip" ]; then
unzip l3110.zip -d $DIR/l3110
sudo apt install -y $DIR/l3110/*.deb
(cd $DIR/l3110/epsonscan2 && chmod +x install.sh && ./install.sh)
fi
# #################################################
# Games
# #################################################
if [ $CONFIRM_GAMES == "y" ] || [ $CONFIRM_GAMES == "Y" ]; then
sudo apt install -y gnome-2048 gnome-mines gnome-chess aisleriot
sudo apt install -y minetest
sudo add-apt-repository -y ppa:libretro/stable
sudo apt-get update
sudo apt-get install -y retroarch
if [ -f "retroarch.zip" ]; then
unzip retroarch.zip -d $DIR/retroarch
mv $DIR/retroarch/* $DIR_RETROARCH
fi
fi
# ###########################################################
# Last Update
# ###########################################################
printtopic "Finishing..."
sudo apt update
sudo apt full-upgrade -y
# ###########################################################
# Remove Temporary Folder
# ###########################################################
printtopic "Cleaning up..."
rm ~/.bash_history
rm -rf $DIR
# ###########################################################
# END
# ###########################################################
echo "Reboot now? (y/n)" && read CONFIRM_REBOOT
if [ $CONFIRM_REBOOT == "y" ] || [ $CONFIRM_REBOOT == "Y" ]; then
sudo reboot
fi
printheader "Installation finished! 🍺" $GREEN
[
{
"key": "shift+alt+down",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+up",
"command": "editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+'",
"command": "workbench.action.terminal.toggleTerminal",
"when": "terminal.active"
},
{
"key": "ctrl+shift+i",
"command": "editor.debug.action.selectionToWatch"
}
]
{
"editor.tabSize": 2,
"workbench.colorTheme": "Default Dark+",
"editor.fontFamily": "'FiraCode Nerd Font', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
"editor.fontLigatures": true,
"workbench.iconTheme": "material-icon-theme",
"material-icon-theme.activeIconPack": "nest",
"code-runner.clearPreviousOutput": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"git.enableSmartCommit": true,
"workbench.colorCustomizations": {
"terminal.ansiBlack": "#354741",
"terminal.ansiBrightBlue": "#4fc9db",
"terminal.ansiBlue": "#1B7C8A",
"terminal.ansiGreen": "#28C142",
"terminal.ansiYellow": "#E8D46F"
},
"code-runner.executorMap": {
"javascript": "node",
"python": "python3",
"perl": "perl",
"rust": "cargo run",
"go": "go run",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment