|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +pushd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null || exit 1 |
| 4 | + |
| 5 | +TIMERS_DIR="../../timers" |
| 6 | + |
| 7 | +source 'questions.sh' |
| 8 | + |
| 9 | + |
| 10 | +echo "systemd tweaks 🔧" |
| 11 | +printf "‾‾‾‾‾‾‾‾‾‾‾‾‾‾\n\n" |
| 12 | + |
| 13 | +echo "This script is for advanced users, check the source and pay close attention to warnings and errors." |
| 14 | +printf "Things may break, tears may be shed.\n\n" |
| 15 | + |
| 16 | + |
| 17 | +############################################################################### |
| 18 | +# NetworkManager-wait-online.service |
| 19 | +############################################################################### |
| 20 | +# This service may slow down boot and it's usually not needed. |
| 21 | +# By masking the service, it can be started if other requires it. |
| 22 | + |
| 23 | +ask_yes_no "Mask NetworkManager-wait-online.service?" $DEFAULT_NO |
| 24 | +if answer_was_yes; then |
| 25 | + sudo systemctl stop NetworkManager-wait-online.service |
| 26 | + sudo systemctl disable NetworkManager-wait-online.service |
| 27 | + sudo systemctl mask NetworkManager-wait-online.service |
| 28 | + echo "Done." |
| 29 | +fi |
| 30 | + |
| 31 | + |
| 32 | +############################################################################### |
| 33 | +# Journal tweaks |
| 34 | +############################################################################### |
| 35 | +# The journal may grow through time making the system feel slow |
| 36 | + |
| 37 | +ask_yes_no "Limit journal size? (50M)" $DEFAULT_NO |
| 38 | +if answer_was_yes; then |
| 39 | + sudo mkdir /etc/systemd/journald.conf.d |
| 40 | + sudo tee /etc/systemd/journald.conf.d/00-journal-size.conf > /dev/null <<EOT |
| 41 | +[Journal] |
| 42 | +SystemMaxUse=50M |
| 43 | +EOT |
| 44 | + |
| 45 | + echo "Done." |
| 46 | +fi |
| 47 | + |
| 48 | + |
| 49 | +############################################################################### |
| 50 | +# ntpd.service |
| 51 | +############################################################################### |
| 52 | +# FIXME: this is wrong |
| 53 | +# This service may slow down boot; if there is a reliable hw clock, it should |
| 54 | +# be sufficiently accurate to get things started and sync later on. |
| 55 | +# |
| 56 | +# It may cause problems with programs that expect a monotonic clock. |
| 57 | +# Do not delay this service on a RasPi or on laptops without clock battery. |
| 58 | + |
| 59 | +if command -v "ntpd" &>/dev/null; then |
| 60 | + ask_yes_no "Delay ntpd.service start?" $DEFAULT_NO |
| 61 | + if answer_was_yes; then |
| 62 | + sudo cp "${TIMERS_DIR}/system/delayed-ntpd.target" "/etc/systemd/system/" |
| 63 | + sudo cp "${TIMERS_DIR}/system/delayed-ntpd.timer" "/etc/systemd/system/" |
| 64 | + sudo systemctl daemon-reload |
| 65 | + |
| 66 | + sudo timedatectl set-ntp 0 |
| 67 | + |
| 68 | + sudo systemctl stop ntpd.service |
| 69 | + sudo systemctl disable ntpd.service |
| 70 | + sudo systemctl disable ntpdate.service |
| 71 | + |
| 72 | + sudo systemctl enable delayed-ntpd.timer |
| 73 | + |
| 74 | + echo "Done." |
| 75 | + fi |
| 76 | +fi |
| 77 | + |
| 78 | + |
| 79 | +############################################################################### |
| 80 | +# fstab format check |
| 81 | +############################################################################### |
| 82 | +# If fstab has the old "nobootwait", mounts may be locking the boot sequence. |
| 83 | + |
| 84 | +FSTAB_NOBOOTWAIT=$(grep "nobootwait" /etc/fstab) |
| 85 | +if [ -n "$FSTAB_NOBOOTWAIT" ]; then |
| 86 | + echo "⚠️ Check your /etc/fstab config! 'nobootwait' is useless." |
| 87 | + echo "More info: https://wiki.archlinux.org/title/fstab#Automount_with_systemd" |
| 88 | +fi |
| 89 | +unset FSTAB_NOBOOTWAIT |
| 90 | + |
| 91 | + |
| 92 | +# Finish |
| 93 | +unset TIMERS_DIR |
| 94 | +popd &>/dev/null || exit |
0 commit comments