Commit 38e2b9b
2020-05-25 09:13:38
Changed files (3)
.gitattributes
@@ -0,0 +1,1 @@
+* !text !filter !merge !diff
.gitignore
@@ -0,0 +1,1 @@
+wpa_supplicant.conf
mf.sh
@@ -0,0 +1,175 @@
+#!/bin/bash
+set -euxo pipefail
+
+### Set password
+sudo passwd pi
+
+### Apt
+sudo apt update
+sudo apt -y upgrade
+sudo SKIP_WARNING=1 rpi-update
+sudo apt install -y scdaemon pinentry-tty dnsutils mtr-tiny
+
+### Stop unwanted services
+sudo systemctl disable avahi-daemon.service
+sudo systemctl disable bluetooth.service
+
+### Linux console font
+sudo wget -q "https://github.com/powerline/fonts/raw/master/Terminus/PSF/ter-powerline-v14n.psf.gz" -O /usr/share/consolefonts/ter-powerline-v14n.psf.gz
+sudo wget -q "https://github.com/powerline/fonts/raw/master/Terminus/PSF/ter-powerline-v14b.psf.gz" -O /usr/share/consolefonts/ter-powerline-v14b.psf.gz
+
+### Yubikey
+systemctl --user mask --now gpg-agent.service gpg-agent.socket gpg-agent-ssh.socket gpg-agent-extra.socket gpg-agent-browser.socket
+sudo update-alternatives --set pinentry /usr/bin/pinentry-tty
+
+# enable ssh
+sudo systemctl enable ssh
+sudo systemctl start ssh
+
+### Configuration files
+
+###### /etc/host[s|name] ######
+echo mf3 | sudo tee /etc/hostname
+sudo tee << EOF /etc/hosts > /dev/null
+127.0.0.1 localhost
+::1 localhost ip6-localhost ip6-loopback
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
+127.0.1.1 mf3
+EOF
+
+###### /etc/default/keyboard ######
+sudo tee << EOF /etc/default/keyboard > /dev/null
+# managed by mf3.sh
+XKBLAYOUT="us"
+BACKSPACE="guess"
+EOF
+
+###### /etc/default/console-setup ######
+sudo tee << EOF /etc/default/console-setup > /dev/null
+# managed by mf3.sh
+ACTIVE_CONSOLES="/dev/tty[1-6]"
+CHARMAP="UTF-8"
+CODESET="guess"
+FONT='ter-powerline-v14b.psf.gz'
+EOF
+
+###### /home/pi/.gnupg/gpg-agent.conf ########
+mkdir -p /home/pi/.gnupg/
+tee << EOF /home/pi/.gnupg/gpg-agent.conf > /dev/null
+enable-ssh-support
+default-cache-ttl 600
+max-cache-ttl 1200
+pinentry-program /usr/bin/pinentry-tty
+EOF
+
+###### /home/pi/.ssh/authorized_keys ######
+mkdir -p /home/pi/.ssh/
+tee << EOF /home/pi/.ssh/authorized_keys > /dev/null
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDGLlbdAnZXOQp/1ReBj9IqUvjNZBJtuvm4zk0mWKORgqgdAAkiHcb4eY1XWsdtNjNFjKPAD97XlTTcPQuDGJnZ9xV6MsGiyag3aAmrJZBxqWmgDeY8EDo7L7mLwBxO/XHkQc98RIQ0KvmDlKknoABqYcvrzw2GvROOjbKfTrv6FeuoTQqAJBB8iR4WC5NlUvY19lP4AmqZuaya7cEbM6gfK4VuOYjFgvAN3n18Cj8MTTvx5GtFR6n2AKjKeoMgJIN+J6Tl0GZuTNOAK2SqDacNSmOLgNKDkWTmDUHl5zvVLGl4gMU3b8azGsRyOElGHOkjQADj5udCaOjvfDUxK2svwhsAhF/GZiZ2yCQZeAsWiS1otNnsqH+y/dWAHJRQiDIp1ZycXuPySJdRA9RYOfCVASXXzlTGA2+T1vW+kYQyzoXepF2cCIDc3SwSpXUOVEtbvsTVJgJPfs6Uqmy74nbw3nbfedxQmODiDVK1YHLO/lZX6fZODIxjApZLs7S/zSK3a6m22ZP6DJTLtrcwj387wEikk9v9HKSAYuf83V7qghcOAxfPqyLn3k4Wc4P9HcqpYyyMGqrz6JPpfdWMy1LsNVk8D9IGDZEAM1u0hXLsJJocRPkWIF2RX1eToj9tpAq2hWNxQcgoY9xrFMfHpaYV5K/xBU1OIlmtLb0/3Erelw== cardno:000607097811
+EOF
+
+###### /home/pi/.ssh/config ######
+mkdir -p /home/pi/.ssh/
+tee << EOF /home/pi/.ssh/config > /dev/null
+Host tmc
+ Hostname trustme.click
+ User ubuntu
+ AddKeysToAgent yes
+ ForwardAgent true
+EOF
+
+###### /boot/config.txt ######
+sudo tee << EOF /boot/config.txt > /dev/null
+## managed by mf3.sh ##
+
+# boot settings
+boot_delay=0
+disable_splash=1
+
+# video settings
+hdmi_force_hotplug=1 # force hdmi to be 'on' even if it is not plugged in
+hdmi_drive=1 # no sound
+hdmi_group=2
+hdmi_mode=83 # 1600x900
+hdmi_blanking=0 # screen 'off' = black
+framebuffer_width=1600
+framebuffer_height=900
+
+# overclock sdcard
+dtoverlay=sdweak,overclock_50=100
+EOF
+
+###### .bashrc ######
+tee << 'EOF' /home/pi/.bashrc > /dev/null
+# managed by mf3.sh, mostly default bashrc without comments
+case $- in
+ *i*) ;;
+ *) return;;
+esac
+HISTCONTROL=ignoreboth
+shopt -s histappend
+HISTSIZE=1000
+HISTFILESIZE=2000
+shopt -s checkwinsize
+case "${TERM}" in
+ xterm-color|*-256color) color_prompt=yes;;
+esac
+PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ '
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+alias ll='ls -l'
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
+
+# base16 pop for linux term
+echo -en "\e]P0000000" #C00 black
+echo -en "\e]P1EB008A" #C01 darkred
+echo -en "\e]P237B449" #C02 darkgreen
+echo -en "\e]P3F8CA12" #C03 yellow (brown)
+echo -en "\e]P40E5A94" #C04 darkblue
+echo -en "\e]PC0C92F2" #blue (lighter than origina)
+echo -en "\e]P5B31E8D" #C05 darkmagenta
+echo -en "\e]P600AABB" #C06 darkcyan
+echo -en "\e]P7E0E0E0" #C07 lightgrey
+echo -en "\e]P8505050" #C08 darkgrey
+echo -en "\e]P9EB008A" #C09 red
+echo -en "\e]PA37B449" #green
+echo -en "\e]PBF8CA12" #yellow
+echo -en "\e]PDB31E8D" #magenta
+echo -en "\e]PE00AABB" #cyan
+echo -en "\e]PFFFFFFF" #white
+
+# bold/thin console font
+alias thin="setfont /usr/share/consolefonts/ter-powerline-v14n.psf.gz && echo -en \"\e]P7FFFFFF\" && clear && showconsolefont -v"
+alias bold="setfont /usr/share/consolefonts/ter-powerline-v14b.psf.gz && echo -en \"\e]P7E0E0E0\" && clear && showconsolefont -v"
+
+# GPG Yubikey -- github.com/drduh/Yubikey-Guide
+export GPG_TTY="$(tty)"
+export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
+gpgconf --launch gpg-agent
+if [[ $runonce -gt 0 ]];
+then
+ echo "not refreshing gpg"
+else
+ gpg-connect-agent updatestartuptty /bye
+ ssh localhost exit
+ runonce=$((runonce + 1))
+ export runonce
+fi
+ssh-add -l
+EOF
+
+### Reboot
+sudo reboot
+