|
#!/bin/bash |
|
|
|
# Unix shell script for installing minimal packages in a Debian-based Unix system |
|
# Run it as `sudo --preserve-env bash script_name.sh` to preserve the variables |
|
# important comment mnemonics used in this script |
|
# HACK: -> Temporary code to force inflexible functionality, or simply a test change, or workaround a known problem. |
|
# FIXME: -> Areas of problematic or ugly code needing refactoring or cleanup. |
|
# TODO: -> to-do taks |
|
# CAVEAT: -> Implementation details/gotchas/warning that stand out as non-intuitive. |
|
# NOTE: -> notes |
|
|
|
############################################## PRE-INSTALL SETTINGS ############################################## |
|
|
|
apt update |
|
apt upgrade -y |
|
### that is the first part of the configuration, which will set $SHELL, fonts, and symlinks. Once finish, you should reboot your machine. ### |
|
if [[ ! $SHELL =~ zsh ]]; then |
|
## install zsh ### |
|
apt install -y zsh |
|
echo -e "\n\nPlease, provide your password to switch to zsh" |
|
sudo -u $SUDO_USER chsh -s /usr/bin/zsh |
|
sudo -u $SUDO_USER mkdir -p $HOME/.local/state/zsh # create path to zsh hist |
|
|
|
### install Meslo patched Nerd-fonts into ~/.local/share/fonts/ ### |
|
for name in {Regular,Italic,Bold,Bold-Italic}; do |
|
[[ ! -f "$HOME/.local/share/fonts/MesloLGMDZNerdFont-${name/-/}.ttf" ]] && wget --directory-prefix="$HOME/.local/share/fonts" "https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Meslo/M-DZ/${name}/MesloLGMDZNerdFont-${name/-/}.ttf" |
|
done |
|
|
|
### configuring the synlinks ### |
|
apt install -y stow # a symlink farm manager |
|
apt install -y git |
|
sudo -u $SUDO_USER mkdir $HOME/git |
|
(cd $HOME/git;sudo -u $SUDO_USER git clone https://github.com/tapyu/dotfiles) # clone dotfiles |
|
rm -f $HOME/.profile # ensure there is no .profile in $HOME |
|
(cd $HOME/git/dotfiles; sudo -u $SUDO_USER stow --verbose=1 --target=${HOME} */) # carry out the symlink manager |
|
|
|
### removing useless and default directories ### |
|
rm -rf $HOME/{Documents,Music,Public,Templates,.bash_history,.bash_logout,.bashrc,.lesshst,.wget-hsts} |
|
|
|
echo -e "\n\nThe first part of the configuration has been done. You must reboot your system so that the config takes effect. Then, rerun this script again to finish the second and last step." |
|
exit 0 |
|
fi |
|
|
|
############################################## INSTALL ############################################## |
|
|
|
### apt ### |
|
|
|
## basic tools |
|
apt install -y apt-transport-https curl |
|
apt install -y apt-file # search for a package that provides a specific file |
|
apt install -y ttf-mscorefonts-installer # Microsoft True Type Core Fonts for the Web including: Andale Mono, Arial Black, Arial (Bold, Italic, Bold Italic), Comic Sans MS (Bold), Courier New (Bold, Italic, Bold Italic), Georgia (Bold, Italic, Bold Italic), Impact, Times New Roman (Bold, Italic, Bold Italic), Trebuchet (Bold, Italic, Bold Italic), Verdana (Bold, Italic, Bold Italic), Webdings |
|
apt install -y libyaml-tiny-perl libfile-homedir-perl # HACK: fix latexindent error (see https://stackoverflow.com/a/77425816/23333162) |
|
apt install -y moreutils # This is a growing collection of the Unix tools that nobody thought to write long ago, when Unix was young -> `combine`, `pee`, `sponge`, ... |
|
apt install -y xdotool # X11 automation tool |
|
apt install -y rar unrar |
|
apt install -y tree |
|
|
|
## programming-language related |
|
# rust |
|
sudo -u $SUDO_USER CARGO_HOME=$CARGO_HOME RUSTUP_HOME=$RUSTUP_HOME bash -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)" -y # rust (see https://www.rust-lang.org/tools/install) |
|
source "${XDG_DATA_HOME}/cargo/env" |
|
# lua |
|
apt install -y lua5.4 luarocks # Install the Lua programming language and its package manager (LuaRocks). CAVEAT: This approach doesn't seem too consistent, 1: `lua5.4` pkg version will become absolete and there is no apprent way to install the latest lua version as there is no `lua` pkg in the `apt` command; 2- the `luarocks` pkg is compatible with `lua` of versions from 5.1 to 5.4, you must assure that `luarocks` you are using is compatible with the your `lua` version. See: https://www.reddit.com/r/lua/comments/1agh999/is_there_rustuplike_for_installing_and_managing/ https://luarocks.org/#quick-start https://www.lua.org/download.html |
|
# C/C++ |
|
apt install -y cmake |
|
apt install -y clang-format # C/C++ formatter |
|
sudo -u $SUDO_USER pip install gprof2dot # converts profiling output to a dot graph |
|
( # valgrind: A memory profiler that can detect memory leaks, memory corruption, and other memory-related issues. |
|
git clone https://sourceware.org/git/valgrind.git /tmp/valgrind |
|
cd /tmp/valgrind |
|
./autogen.sh |
|
./configure |
|
make # TODO: see if it isn't already in Ubuntu packages |
|
) # NOTE: https://valgrind.org/downloads/repository.html |
|
# python |
|
apt install -y python-is-python3 # a mere symlink to /usr/bin/python |
|
# others |
|
apt install -y cloc # count line of code (cloc): git utils to analyze the number lines in a repo (also see the online version: https://codetabs.com/count-loc/count-loc-online.html) |
|
|
|
## command line tools |
|
apt install -y ripgrep |
|
apt install -y pdfgrep |
|
apt install -y screenkey |
|
apt install -y fzf # fuzzy finder |
|
apt install -y rename # rename 's/search/replace/g' CLI command |
|
apt install -y xtrlock # keyboard locker (unlock it with the computer password) |
|
|
|
# git related |
|
apt install -y rclone # for the first try, you must run `rclone config reconnect books:` |
|
apt install -y zoxide # faster way to navigate your filesystem |
|
|
|
# GUI |
|
apt install -y telegram-desktop |
|
apt install -y gnome-tweaks |
|
apt install -y gnome-clocks # timer, alarms, and stopwatch |
|
apt install -y gnome-shell-extensions |
|
apt install -y diodon # GTK+ clipboad manager |
|
apt install -y obs-studio |
|
apt install -y nnn # terminal file explorer |
|
|
|
### packages without pkg managers ### |
|
# helix |
|
# NOTE: https://docs.helix-editor.com/install.html#ubuntu |
|
add-apt-repository ppa:maveonair/helix-editor |
|
apt update |
|
apt install -y helix |
|
# Wez's Terminal emulator |
|
# NOTE: https://wezfurlong.org/wezterm/install/linux.html#installing-on-ubuntu |
|
curl -fsSL https://apt.fury.io/wez/gpg.key | gpg --yes --dearmor -o /usr/share/keyrings/wezterm-fury.gpg |
|
echo 'deb [signed-by=/usr/share/keyrings/wezterm-fury.gpg] https://apt.fury.io/wez/ * *' | tee /etc/apt/sources.list.d/wezterm.list |
|
apt install -y wezterm-nightly |
|
# jq: Command-line JSON processor |
|
sudo -u $SUDO_USER curl --fail --location https://github.com/jqlang/jq/releases/latest/download/jq-linux-amd64 --output $HOME/.local/bin/jq |
|
sudo -u $SUDO_USER chmod u+x $HOME/.local/bin/jq |
|
# xml2json |
|
( |
|
git clone https://github.com/Cheedoong/xml2json /tmp |
|
cd /tmp/xml2json |
|
make |
|
mv xml2json $HOME/.local/bin |
|
) |
|
# LaTeX |
|
# TeX Live is available for Ubuntu and is in the Universe repository. This will install a basic subset of TeX Live's functionality. To install the complete TeX Live distribution, install texlive-full. Installing TeX Live directly does not interfere with Ubuntu, and ensures that you have the latest releases of all TeX and LaTeX packages. The downside is that you periodically have to update your installation manually, using the TeX Live Package Manager. |
|
#apt install -y texlive-full # latex from ubuntu |
|
# NOTE: https://www.tug.org/texlive/quickinstall.html |
|
(cd /tmp ; \ |
|
wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz ; \ |
|
zcat < install-tl-unx.tar.gz | tar xf - ; \ |
|
cd install-tl-*/ ; \ |
|
perl ./install-tl --no-interaction) |
|
chown -R $SUDO_USER:$SUDO_USER /usr/local/texlive/ # change ownership to user |
|
|
|
### deb-get packages ### |
|
apt install -y curl lsb-release wget # deb-get dependencies (see https://github.com/wimpysworld/deb-get#install) |
|
sudo -u $SUDO_USER curl -sL https://raw.githubusercontent.com/wimpysworld/deb-get/main/deb-get | sudo -E bash -s install deb-get |
|
sudo -u $SUDO_USER deb-get install docker-ce |
|
sudo -u $SUDO_USER deb-get install code |
|
sudo -u $SUDO_USER deb-get install sublime-text |
|
sudo -u $SUDO_USER deb-get install gh # github-cli |
|
sudo -u $SUDO_USER deb-get install master-pdf-editor-5 |
|
sudo -u $SUDO_USER deb-get install brave-browser # TODO: see if itsn't already available in apt |
|
sudo -u $SUDO_USER deb-get install discord |
|
sudo -u $SUDO_USER deb-get install nodejs # node.js: JavaScript runtime built on the V8 JavaScript engine, which is the same engine that powers the Google Chrome browser; npm: stands for "Node Package Manager." It is the default package manager for Node.js;npx: a package runner tool that comes with npm. It allows you to execute Node.js packages directly without having to install them globally or locally. |
|
sudo -u $SUDO_USER deb-get install zotero |
|
sudo -u $SUDO_USER deb-get install protonvpn # NOTE: if it fails, see https://github.com/wimpysworld/deb-get/issues/975 |
|
|
|
### GNU radio ### |
|
# NOTE: https://github.com/gnuradio/gnuradio |
|
sudo -u $SUDO_USER pip install QDarkStyle qtpy pytest-qt pyautogui # dependencies |
|
apt install gnuradio # install GNU radio |
|
|
|
### Python packages ### |
|
# TODO: change from pip to pipx |
|
apt install -y python3-pip # pip package |
|
sudo -u $SUDO_USER pip install poetry # poetry, a python packaging and dependency management |
|
sudo -u $SUDO_USER pip install howdoi # instant coding answers via the command line |
|
sudo -u $SUDO_USER pip install ruff # extremely fast Python linter and code formatter, written in Rust. Ruff can be used to replace Flake8 (plus dozens of plugins), Black, isort, pydocstyle, pyupgrade, autoflake, and more, all while executing tens or hundreds of times faster than any individual tool |
|
sudo -u $SUDO_USER pip install hydra # Stop Hard Coding in a Data Science Project, Use Config Files Instead |
|
sudo -u $SUDO_USER pip install cookiecutter # Structure a Data Science Project for Maintainability |
|
sudo -u $SUDO_USER pip install octave_kernel # octave kernel for Jupyter Notebook in VS code |
|
|
|
### npm packages ### |
|
npm install -g tldr |
|
npm install -g bash-language-server |
|
npm install -g how2 |
|
npm install -g safe-rm |
|
|
|
### cargo crates ### |
|
apt-get install -y pkg-config libssl-dev # HACK: fix "failed to compile cargo-update" (see https://github.com/sfackler/rust-openssl/issues/855) |
|
sudo -u $SUDO_USER cargo install cargo-update # a 3th party crate to upgrade all crates (see https://stackoverflow.com/questions/34484361/does-cargo-install-have-an-equivalent-update-command) |
|
sudo -u $SUDO_USER cargo install lsd # the next gen ls command |
|
sudo -u $SUDO_USER cargo install bat # a cat clone with wings |
|
sudo -u $SUDO_USER cargo install --locked typst-cli # the next LaTeX replacement (latest release) |
|
sudo -u $SUDO_USER cargo install just # # the next Makefile replacement |
|
sudo -u $SUDO_USER cargo install git-delta # a syntax-highlighting pager for git, diff, and grep output |
|
sudo -u $SUDO_USER cargo install --locked navi |
|
sudo -u $SUDO_USER cargo install juliaup # Julia installer and version multiplexer |
|
|
|
############################################## POST-INSTALL SETTINGS ############################################## |
|
|
|
### disable security setting for Ghostscript ### |
|
# some `gs` commands aren't possible to be executed due to security restrictions. |
|
# this command fix it |
|
init_range=$(awk '/disable ghostscript format types/ { print NR }' /etc/ImageMagick-?/policy.xml) |
|
end_range=$(awk '/<\/policymap>/ { print NR-1 }' /etc/ImageMagick-?/policy.xml) |
|
sed -i "$init_range,${end_range}d" /etc/ImageMagick-?/policy.xml |
|
|
|
### zotero settings ### |
|
# create new place to ~/Zotero |
|
sudo -u $SUDO_USER mkdir -p $HOME/.local/share/zotero |
|
# better biber LaTeX |
|
wget --directory-prefix=/tmp $(curl -s https://api.github.com/repos/retorquere/zotero-better-bibtex/releases/latest | grep browser_download_url | cut -d '"' -f 4) # TODO: use my script command `install-from-gh` instead |
|
|
|
### login to Docker hub ### |
|
# NOTE: it is assumed that only the root user is intended to access the Docker deamon |
|
# NOTE: https://github.com/docker/docker-credential-helpers/issues/140 |
|
curl -o /usr/bin/docker-credential-pass -LO $(curl -s https://api.github.com/repos/docker/docker-credential-helpers/releases/latest | grep browser_download_url | grep docker-credential-pass | grep linux-amd64 | cut -d '"' -f 4) # TODO: use my script command `install-from-gh` instead |
|
chmod a+x /usr/bin/docker-credential-pass # TODO: do I need it? |
|
gpg --generate-key # create a key to encrypt the Docker access token |
|
pass init $(gpg -k | awk 'NR==4 { print $1 }') # use this gpg public key to encrypt the access token |
|
echo 'Use your access token as password' |
|
docker login --username tapyu |
|
|
|
### NVIDIA settings for GPU-accelerated Tesorflow applications in docker containers ### |
|
# NOTE: https://www.tensorflow.org/install/docker |
|
if [[ -n $(lspci | grep -io 'nvidia') ]]; then |
|
# NVIDIA Container Toolkit |
|
# NOTE: https://github.com/NVIDIA/nvidia-container-toolkit |
|
# NOTE: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html |
|
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ |
|
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ |
|
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ |
|
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \ |
|
&& \ |
|
sudo apt-get update |
|
apt-get install -y nvidia-container-toolkit |
|
|
|
# configure docker |
|
nvidia-ctk runtime configure --runtime=docker |
|
systemctl restart docker # restart docker deamon |
|
# configure containerd |
|
# NOTE: Docker Engine uses containerd for managing the container lifecycle (see https://docs.docker.com/engine/alternative-runtimes/#what-runtimes-can-i-use) |
|
nvidia-ctk runtime configure --runtime=containerd |
|
systemctl restart containerd # restart containerd deamon |
|
# NOTE: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/sample-workload.html |
|
# sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi # sample workload |
|
# NOTE: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#nvidia-open-gpu-kernel-modules |
|
fi |
|
|
|
### add latex-input keyboard ### |
|
# NOTE: https://github.com/clarkgrubb/latex-input#installation-3 |
|
apt install im-config ibus-table ibus-table-latex |
|
sudo -u $SUDO_USER im-config |
|
git clone https://github.com/clarkgrubb/latex-input /tmp/latex-input |
|
(cd /tmp/latex-input; ./ibus-install.sh) |
|
|
|
# TODOS |
|
# zotero: |
|
# 1. run zotero and sync |
|
# 2. manually install the better biber LaTeX located at `/tmp/zotero-better-bibtex-*` |
|
# 3. run `sed -i "s|$HOME/Zotero|$HOME/.local/share/zotero|g" $HOME/.zotero/zotero/*.default/prefs.js && rm -rf $HOME/Zotero` to change ~/Zotero/ to $XDG_DATA_HOME/zotero |
|
# 4. fix https://tex.stackexchange.com/questions/678945/handling-family-and-given-within-the-author-field/679060#679060 |
|
# 5. export refs to /home/tapyu/.cache/zotero/refs.bib |
|
# rclone |
|
# 1. rclone config reconnect books: |