config/yadm: reformat bootstrap
This commit is contained in:
parent
0336a7815e
commit
01210a4734
|
@ -1,44 +1,53 @@
|
||||||
## System
|
# Underline
|
||||||
# Enable REISUB and increase watch limit for Intellij & co
|
section() { printf "\n[1m[4m$1[0m\n"; }
|
||||||
|
highlight() { printf "[1m[3m$1[0m\n"; }
|
||||||
|
|
||||||
|
section "System"
|
||||||
|
|
||||||
|
highlight "Enable REISUB and increase watch limit for Intellij & co"
|
||||||
echo "kernel.sysrq=1" | sudo tee /etc/sysctl.d/60-sysrq.conf
|
echo "kernel.sysrq=1" | sudo tee /etc/sysctl.d/60-sysrq.conf
|
||||||
echo "fs.inotify.max_user_watches=800000" | sudo tee /etc/sysctl.d/60-max-user-watches.conf
|
echo "fs.inotify.max_user_watches=800000" | sudo tee /etc/sysctl.d/60-max-user-watches.conf
|
||||||
sudo sysctl --system
|
sudo sysctl --system
|
||||||
|
|
||||||
# Update sudoers configuration
|
highlight "Default sudoers configuration"
|
||||||
echo "Defaults editor=/usr/bin/nvim" | sudo tee /etc/sudoers.d/editor
|
echo "Defaults editor=/usr/bin/nvim" | sudo tee /etc/sudoers.d/editor
|
||||||
echo "Defaults timestamp_timeout=20" | sudo tee /etc/sudoers.d/timeout
|
echo "Defaults timestamp_timeout=20" | sudo tee /etc/sudoers.d/timeout
|
||||||
# Password-free reboot
|
highlight "password-free reboot"
|
||||||
echo "$USER ALL = NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff" | sudo tee /etc/sudoers.d/shutdown
|
echo "$USER ALL = NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff" | sudo tee /etc/sudoers.d/shutdown
|
||||||
|
|
||||||
|
highlight "Reduce system startup & shutdown timeout"
|
||||||
|
sudo mkdir -p /etc/systemd/system.conf.d /etc/systemd/user.conf.d
|
||||||
|
echo "DefaultTimeoutStartSec=5s
|
||||||
|
DefaultTimeoutStopSec=10s" | sudo tee /etc/systemd/system.conf.d/boot.conf /etc/systemd/user.conf.d/boot.conf
|
||||||
|
|
||||||
|
highlight "Default to current user in tty1,2,3"
|
||||||
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d /etc/systemd/system/getty@tty2.service.d /etc/systemd/system/getty@tty3.service.d
|
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d /etc/systemd/system/getty@tty2.service.d /etc/systemd/system/getty@tty3.service.d
|
||||||
echo "[Service]
|
echo "[Service]
|
||||||
ExecStart=
|
ExecStart=
|
||||||
ExecStart=-/usr/bin/agetty --skip-login --login-options $USER %I" | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf /etc/systemd/system/getty@tty2.service.d/override.conf /etc/systemd/system/getty@tty3.service.d/override.conf
|
ExecStart=-/usr/bin/agetty --skip-login --login-options $USER %I" | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf /etc/systemd/system/getty@tty2.service.d/override.conf /etc/systemd/system/getty@tty3.service.d/override.conf
|
||||||
|
|
||||||
## Hardware
|
## Hardware
|
||||||
printf '\nHardware\n'
|
section 'Hardware'
|
||||||
|
|
||||||
echo 'Stop logind from suspending laptop'
|
highlight 'Stop logind from suspending laptop'
|
||||||
sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/' /etc/systemd/logind.conf
|
sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/' /etc/systemd/logind.conf
|
||||||
|
|
||||||
# Fix Chrysalis for keyboardio - https://github.com/keyboardio/Chrysalis/wiki/Troubleshooting
|
highlight "Fix Chrysalis for keyboardio"
|
||||||
|
# https://github.com/keyboardio/Chrysalis/wiki/Troubleshooting
|
||||||
if test ! -f /etc/udev/rules.d/keyboardio.rules; then
|
if test ! -f /etc/udev/rules.d/keyboardio.rules; then
|
||||||
echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="230[0-3]", SYMLINK+="model01", TAG+="seat", TAG+="uaccess", RUN+="'"$HOME/.local/bin/update-keyboard-layout\"" | sudo tee /etc/udev/rules.d/keyboardio.rules
|
echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="230[0-3]", SYMLINK+="model01", TAG+="seat", TAG+="uaccess", RUN+="'"$HOME/.local/bin/update-keyboard-layout\"" | sudo tee /etc/udev/rules.d/keyboardio.rules
|
||||||
sudo udevadm control -R
|
sudo udevadm control -R
|
||||||
sudo udevadm trigger -v /dev/ttyACM0
|
sudo udevadm trigger -v /dev/ttyACM0
|
||||||
|
|
||||||
#sudo systemctl disable ModemManager
|
#sudo systemctl disable ModemManager
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Software
|
## Software
|
||||||
printf '\nSoftware\n'
|
section "Software"
|
||||||
|
|
||||||
echo 'text/csv; sc-im "%s"; edit=sc-im "%s"; compose=sc-im "%s"; description="CSV Document"; nametemplate=%s.csv' | tee $HOME/.mailcap
|
highlight "Colorize Pacman & enable multilib"
|
||||||
|
|
||||||
# Colorize Pacman & enable multilib
|
|
||||||
test -f /etc/pacman.conf && sudo sed -i 's/#Color/Color/' /etc/pacman.conf && sudo sed -i "$(grep -n "\[multilib\]" /etc/pacman.conf | cut -d':' -f1),+1 s/# *//" /etc/pacman.conf
|
test -f /etc/pacman.conf && sudo sed -i 's/#Color/Color/' /etc/pacman.conf && sudo sed -i "$(grep -n "\[multilib\]" /etc/pacman.conf | cut -d':' -f1),+1 s/# *//" /etc/pacman.conf
|
||||||
|
|
||||||
# Block internet at night & on weekdays in the morning to force focus
|
highlight "Block internet at night & on weekdays in the morning to force focus"
|
||||||
# https://askubuntu.com/a/124512 and https://blog.sleeplessbeastie.eu/2018/06/21/how-to-create-iptables-firewall-using-custom-chains/
|
# https://askubuntu.com/a/124512 and https://blog.sleeplessbeastie.eu/2018/06/21/how-to-create-iptables-firewall-using-custom-chains/
|
||||||
sudo iptables --new-chain chain-times 2>/dev/null || sudo iptables --flush chain-times
|
sudo iptables --new-chain chain-times 2>/dev/null || sudo iptables --flush chain-times
|
||||||
time9=$(date -u -d "$(date -d 09:00)" +%k)
|
time9=$(date -u -d "$(date -d 09:00)" +%k)
|
||||||
|
@ -49,14 +58,15 @@ sudo iptables -L OUTPUT | grep -q "^chain-times" || sudo iptables -A OUTPUT -j c
|
||||||
sudo iptables-save | sudo tee /etc/iptables.rules
|
sudo iptables-save | sudo tee /etc/iptables.rules
|
||||||
echo "@reboot root $(which iptables-restore) < /etc/iptables.rules" | sudo tee /etc/cron.d/iptables-times
|
echo "@reboot root $(which iptables-restore) < /etc/iptables.rules" | sudo tee /etc/cron.d/iptables-times
|
||||||
|
|
||||||
# Workrave
|
highlight "Workrave"
|
||||||
sudo sed -i 's|Exec=workrave|Exec=sh -c "workrave \& sleep 1; dbus-send --session --dest=org.workrave.Workrave --type=method_call /org/workrave/Workrave/Core org.workrave.CoreInterface.SetOperationMode string:normal"|' /usr/share/applications/workrave.desktop
|
sudo sed -i 's|Exec=workrave|Exec=sh -c "workrave \& sleep 1; dbus-send --session --dest=org.workrave.Workrave --type=method_call /org/workrave/Workrave/Core org.workrave.CoreInterface.SetOperationMode string:normal"|' /usr/share/applications/workrave.desktop
|
||||||
ln -sfv /usr/share/applications/workrave.desktop $XDG_CONFIG_HOME/autostart
|
ln -sfv /usr/share/applications/workrave.desktop $XDG_CONFIG_HOME/autostart
|
||||||
echo " 0,20,40 * * * * janek pgrep workrave || XAUTHORITY='$XDG_CACHE_HOME/Xauthority' DISPLAY=:0 /usr/bin/workrave" | sudo tee /etc/cron.d/workrave
|
echo " 0,20,40 * * * * janek pgrep workrave || XAUTHORITY='$XDG_CACHE_HOME/Xauthority' DISPLAY=:0 /usr/bin/workrave" | sudo tee /etc/cron.d/workrave
|
||||||
|
|
||||||
# Cron logging
|
highlight "Cron logging"
|
||||||
echo 'cron.* /var/log/cron.log' | sudo tee /etc/rsyslog.d/60-cron.conf
|
echo 'cron.* /var/log/cron.log' | sudo tee /etc/rsyslog.d/60-cron.conf
|
||||||
sudo service rsyslog restart || sudo systemctl restart rsyslog
|
alias hasService="which service 2>/dev/null"
|
||||||
|
hasService && sudo service rsyslog restart || sudo systemctl restart rsyslog
|
||||||
|
|
||||||
## Finalize
|
highlight "Reload cron"
|
||||||
sudo service cron reload || sudo systemctl reload cronie
|
hasService && sudo service cron reload || sudo systemctl reload cronie
|
||||||
|
|
Loading…
Reference in New Issue