106 lines
3 KiB
Bash
Executable file
106 lines
3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Run this as root to install system-level config from dotfiles.
|
|
# Usage: sudo ./install-system.sh
|
|
|
|
set -e
|
|
|
|
DOTFILES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "please run as root"
|
|
exit 1
|
|
fi
|
|
|
|
backup_and_link() {
|
|
local src="$1"
|
|
local dst="$2"
|
|
|
|
mkdir -p "$(dirname "$dst")"
|
|
|
|
if [ -L "$dst" ]; then
|
|
echo "already a symlink, skipping: $dst"
|
|
return
|
|
fi
|
|
|
|
if [ -e "$dst" ]; then
|
|
echo "backing up: $dst -> $dst.bak"
|
|
mv "$dst" "$dst.bak"
|
|
fi
|
|
|
|
echo "linking: $dst -> $src"
|
|
ln -s "$src" "$dst"
|
|
}
|
|
|
|
# Touchpad palm detection
|
|
backup_and_link "$DOTFILES/config/xorg.conf.d/70-touchpad.conf" "/etc/X11/xorg.conf.d/70-touchpad.conf"
|
|
|
|
# Kanata key remapper
|
|
backup_and_link "$DOTFILES/config/kanata/rc.kanata" "/etc/rc.d/rc.kanata"
|
|
chmod +x /etc/rc.d/rc.kanata
|
|
|
|
# Tailscale daemon
|
|
backup_and_link "$DOTFILES/config/tailscale/rc.tailscale" "/etc/rc.d/rc.tailscale"
|
|
chmod +x /etc/rc.d/rc.tailscale
|
|
mkdir -p /var/lib/tailscale
|
|
mkdir -p /var/run/tailscale
|
|
|
|
# autofs config
|
|
backup_and_link "$DOTFILES/config/autofs/auto.master" "/etc/auto.master"
|
|
backup_and_link "$DOTFILES/config/autofs/auto.mnt" "/etc/auto.mnt"
|
|
|
|
# MPD rc script
|
|
chmod +x /etc/rc.d/rc.autofs
|
|
backup_and_link "$DOTFILES/config/mpd/rc.mpd" "/etc/rc.d/rc.mpd"
|
|
chmod +x /etc/rc.d/rc.mpd
|
|
mkdir -p /mnt
|
|
|
|
# NetworkManager wifi power saving fix
|
|
backup_and_link "$DOTFILES/config/NetworkManager/wifi-powersave-off.conf" "/etc/NetworkManager/conf.d/wifi-powersave-off.conf"
|
|
|
|
if ! grep -q "rc.kanata" /etc/rc.d/rc.local; then
|
|
echo "" >> /etc/rc.d/rc.local
|
|
echo "# Start kanata key remapper" >> /etc/rc.d/rc.local
|
|
echo "if [ -x /etc/rc.d/rc.kanata ]; then" >> /etc/rc.d/rc.local
|
|
echo " /etc/rc.d/rc.kanata start" >> /etc/rc.d/rc.local
|
|
echo "fi" >> /etc/rc.d/rc.local
|
|
echo "added kanata to rc.local"
|
|
else
|
|
echo "rc.local already has kanata entry, skipping"
|
|
fi
|
|
|
|
# Add boot output logging if not present
|
|
if ! grep -q "tee /var/log/rc.local.log" /etc/rc.d/rc.local; then
|
|
# Insert logging line after the shebang/header
|
|
sed -i '/^#.*Local system/a\\n# Log all boot output to file while still showing on console\nexec > >(tee /var/log/rc.local.log) 2>&1' /etc/rc.d/rc.local
|
|
echo "added boot logging to rc.local"
|
|
else
|
|
echo "rc.local already has boot logging, skipping"
|
|
fi
|
|
|
|
# Add tailscale, autofs, mpd to rc.local if not present
|
|
if ! grep -q "rc.tailscale" /etc/rc.d/rc.local; then
|
|
cat >> /etc/rc.d/rc.local << 'RCEOF'
|
|
|
|
# Start tailscale daemon
|
|
if [ -x /etc/rc.d/rc.tailscale ]; then
|
|
/etc/rc.d/rc.tailscale start
|
|
fi
|
|
|
|
# Start autofs (handles NFS mounts on demand)
|
|
if [ -x /etc/rc.d/rc.autofs ]; then
|
|
/etc/rc.d/rc.autofs start
|
|
fi
|
|
|
|
# Start MPD (autofs will mount /mnt/media on first access)
|
|
if [ -x /etc/rc.d/rc.mpd ]; then
|
|
/etc/rc.d/rc.mpd start
|
|
fi
|
|
RCEOF
|
|
echo "added tailscale/autofs/mpd to rc.local"
|
|
else
|
|
echo "rc.local already has tailscale entry, skipping"
|
|
fi
|
|
|
|
echo ""
|
|
echo "done. reboot or restart X for xorg changes to take effect."
|