-
-
Save smvorwerk/a3937275b77524d3a013f424cc6e9555 to your computer and use it in GitHub Desktop.
Bootstrap script for a new NVIDIA Jetson Nano
This file contains hidden or 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
#!/bin/bash | |
set -e | |
export DEBIAN_FRONTEND=noninteractive | |
if [[ $UID != 0 ]]; then | |
echo "Please run this script with sudo:" | |
echo "sudo $0 $*" | |
exit 1 | |
fi | |
nv_user=$(who am i | awk '{print $1}') | |
nv_home=/home/$nv_user | |
# disable camera daemon | |
systemctl stop nvargus-daemon | |
systemctl disable nvargus-daemon | |
# disable wifi and 3g/4g/5g modem | |
systemctl stop ModemManager | |
systemctl disable ModemManager | |
# disable error crash reporting daemon | |
systemctl stop whoopsie | |
systemctl disable whoopsie | |
# disable tts service | |
systemctl stop speech-dispatcher | |
systemctl disable speech-dispatcher | |
apt-get update -y | |
apt-get upgrade -y | |
# install sysadmin tools | |
apt-get install -y htop iotop | |
# install debugging and profiling tools | |
apt-get install -y strace valgrind ltrace | |
# install searching and filesystem tools | |
apt-get install -y ncdu tree silversearcher-ag | |
# install editor | |
apt-get install -y nano | |
# install networking tools | |
apt-get install -y curl nginx nmap | |
# disable it by default (keeping things light) | |
systemctl stop nginx | |
systemctl disable nginx | |
# install python3 | |
apt-get install -y python3-pip python3-venv | |
# install zsh | |
apt-get install -y zsh | |
chsh -s $(which zsh) $nv_user | |
# install oh-my-zsh | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
echo "PROMPT='%n@%m:%1~%# '" >$nv_home/.oh-my-zsh/custom/themes/superminimal.zsh-theme | |
# LS colors | |
## CREATE BACKUPS FOR .zshrc | |
echo " | |
# LS COLORS | |
export LSCOLORS=\"gxfxcxdxbxeggeabagacah\" | |
export LS_COLORS=\"di=36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=36;44:su=30;41:sg=30;46:tw=30;42:ow=30;47\" | |
zstyle ':completion:*:default' list-colors \$\{(s.:.)LS_COLORS\} | |
# EDITOR | |
export EDITOR='nano' | |
# ADD CUDA TO PATH | |
PATH=\${PATH}:/usr/local/cuda/bin | |
" >>$nv_home/.zshrc | |
echo " | |
# EDITOR | |
export EDITOR=nano | |
# ADD CUDA TO PATH | |
PATH=\${PATH}:/usr/local/cuda/bin | |
" >>$nv_home/.bashrc | |
# disable compfix for root | |
sed -i '/# Path to your oh-my-zsh installation/i \ | |
ZSH_DISABLE_COMPFIX=true' $nv_home/.zshrc | |
# enable minimal theme | |
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="superminimal"/g' $nv_home/.zshrc | |
# change avahi-daemon to run even with .local conflicts | |
# sed -i 's/AVAHI_DAEMON_DETECT_LOCAL=1/AVAHI_DAEMON_DETECT_LOCAL=0/g' /etc/default/avahi-daemon | |
# silent login | |
touch $nv_home/.hushlogin | |
## CREATE BACKUPS for login and sshd | |
sed -i '/ pam_motd\.so /s/^/#/' /etc/pam.d/login | |
sed -i '/ pam_motd\.so /s/^/#/' /etc/pam.d/sshd | |
# store initial jetson_clocks config | |
jetson_clocks --store | |
# uninstall libreoffice | |
apt-get --purge autoremove -y '^libreoffice-.*' | |
# uninstall thunderbird | |
apt-get --purge autoremove -y '^thunderbird.*' | |
# uninstall chromium | |
apt-get --purge autoremove -y '^chromium.*' | |
# uninstall transmission | |
apt-get --purge autoremove -y '^transmission.*' | |
# uninstall docker | |
systemctl stop docker | |
systemctl stop containerd | |
apt-get --purge autoremove -y \ | |
docker \ | |
docker.io \ | |
nvidia-docker2 | |
rm -rf /var/lib/docker /etc/docker | |
rm /etc/apparmor.d/docker | |
groupdel docker | |
rm -rf /var/run/docker.sock | |
# TODO: also `rm -rf /var/run/docker` | |
# adding nameservers | |
cat /etc/resolv.conf | |
## CREATE BACKUPS OF /etc/resolvconf/resolv.conf.d/head | |
echo " | |
nameserver 127.0.0.1 | |
nameserver 1.1.1.1 | |
nameserver 1.0.0.1" >>/etc/resolvconf/resolv.conf.d/head | |
# update resolvconf file | |
resolvconf -u | |
# use multi-user.target | |
systemctl get-default | |
systemctl set-default multi-user.target | |
# disable docs | |
sed -e '/\/usr\/share\/doc/ s/^#*/#/' -i /etc/dpkg/dpkg.cfg.d/include-docs | |
# enable manpages | |
sed -e '/\/usr\/share\/man/ s/^#*/#/' -i /etc/dpkg/dpkg.cfg.d/excludes | |
# add manpages | |
apt-get install -y man-db manpages | |
# ensure debian is in non-interactive mode | |
export DEBIAN_FRONTEND=noninteractive | |
dpkg -S /usr/share/man/ | sed 's|, |\n|g;s|: [^:]*$||' | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment