commit e3af791378d051b791f8d1ca72e964555ecf75cf
parent 93cbf681422d4fbb3e112b8b260d1bbc84c772fb
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu, 14 May 2026 09:48:31 +0200
Add setup config script
Diffstat:
1 file changed, 162 insertions(+), 0 deletions(-)
diff --git a/src/setup-config-alpine b/src/setup-config-alpine
@@ -0,0 +1,162 @@
+#!/bin/sh
+
+# Set up my configuration on a new Alpine Linux installation.
+
+print_log() {
+ printf '\n>>> %s \n\n' "$@"
+}
+
+set -e # Abort on first error
+
+
+print_log "Installing git and cloning the config repo"
+
+doas apk add git
+cd ~
+git init .
+git remote add origin https://git.tronto.net/config
+git fetch && git checkout -f master
+git remote set-url origin git@tronto.net:config
+git remote set-url origin --add --push git@github.com:sebastianotronto/config
+
+
+print_log "Installing software from alpine repositories"
+
+tmp_repo_file=$(mktemp)
+main_repo="$(grep main /etc/apk/repositories)"
+community_repo="$(echo "$main_repo" | sed 's/main/community/')"
+printf '%s\n%s\n' "$main_repo" "$community_repo" > "$tmp_repo_file"
+doas mv "$tmp_repo_file" /etc/apk/repositories
+
+./scripts/apkworld
+
+
+print_log "Installing and configuring desktop environment"
+
+doas setup-xorg-base
+
+mkdir -p src
+cd src
+for i in dmenu dwm st; do
+ git clone https://git.suckless.org/$i
+ cd $i
+ cp ~/.config/$i/config.h ./config.h
+ make && doas make install
+ cd ..
+done
+cd
+
+tmp_xorg_file=$(mktemp)
+cat <<EOF > "$tmp_xorg_file"
+Section "InputClass"
+ Identifier "libinput touchpad catchall"
+ MatchIsTouchpad "on"
+ MatchDevicePath "/dev/input/event*"
+ Driver "libinput"
+ Option "Tapping" "on"
+EndSection
+EOF
+
+doas mkdir -p /etc/X11/xorg.conf.d
+doas mv "$tmp_xorg_file" /etc/X11/xorg.conf.d/40-libinput.conf
+
+tmp_doas_file=$(mktemp)
+cp /etc/doas.d/20-wheel.conf "$tmp_doas_file"
+for c in poweroff reboot; do
+ printf 'permit nopass :wheel as root cmd %s\n' "$c" >> "$tmp_doas_file"
+done
+doas cp "$tmp_doas_file" /etc/doas.d/20-wheel.conf
+
+
+print_log "Configuring the console"
+
+tmp_kmap_file=$(mktemp)
+tmp_loadkmap_file=$(mktemp)
+printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > "$tmp_kmap_file"
+doas loadkeys "$tmp_kmap_file"
+dumpkmap > us-swapesc.bmap
+gzip us-swapesc.bmap
+doas mv us-swapesc.bmap.gz /etc/keymap/
+printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > "$tmp_loadkmap_file"
+doas mv "$tmp_loadkmap_file" /etc/conf.d/loadkmap
+
+tmp_blacklist_file=$(mktemp)
+cp /etc/modprobe.d/blacklist.conf "$tmp_blacklist_file"
+printf '\n# Disable PC speaker for real\nblacklist pcspkr\n' >> "$tmp_blacklist_file"
+doas cp "$tmp_blacklist_file" /etc/modprobe.d/blacklist.conf
+
+
+print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)"
+
+tmp_acpi_file=$(mktemp)
+printf '#!/bin/sh\necho mem > /sys/power/state\n' > "$tmp_acpi_file"
+
+for dir in LID PWRF; do
+ doas mkdir -p /etc/acpi/$dir
+ doas cp "$tmp_acpi_file" /etc/acpi/$dir/00000080
+ doas chmod +x /etc/acpi/$dir/00000080
+done
+
+doas rc-update add acpid
+
+
+print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)"
+
+tmp_iwd_file=$(mktemp)
+cat <<EOF > "$tmp_iwd_file"
+[General]
+EnableNetworkConfiguration=True
+
+[Network]
+NameResolvingService=resolvconf
+EOF
+
+doas mv "$tmp_iwd_file" /etc/iwd/main.conf
+
+doas rc-update add iwd boot
+doas rc-update del networking boot
+doas rc-service --ifstarted wpa_supplicant stop
+doas rc-service iwd start
+
+
+print_log "Setting up bluetooth (see https://wiki.alpinelinux.org/wiki/Bluetooth)"
+
+doas modprobe btusb
+doas adduser sebastiano lp
+doas rc-update add bluetooth
+doas rc-service bluetooth start
+
+
+print_log "Setting up SyncThing"
+
+tmp_syncthing_file=$(mktemp)
+doas print 'SYNCTHING_USER="sebastiano"\n' > "$tmp_syncthing_file"
+mv "$tmp_syncthing_file" /etc/conf.d/syncthing
+doas rc-update add syncthing
+doas rc-service start syncthing
+
+
+print_log "Generating SSH keys"
+
+ssh-keygen
+
+
+echo ""
+echo "All done!"
+echo ""
+echo "You should log out and back in to apply some of the changes."
+echo "Additionally, you may want to perform the following manual steps:"
+echo " 1. Connect to WiFi again. The default network manager has been"
+echo " replaced by iwd."
+echo " 2. Add your SSH key to various servers, namely:"
+echo " 1a. Artemisia"
+echo " 1b. pizoc (both regular user and git)"
+echo " 1c. github"
+echo " 1d. lampone"
+echo " 3. Share folders in SyncThing, including but not limited to:"
+echo " 2a. box with Artemisia, pizoc and phone"
+echo " 2b. file-drop with phone"
+echo " 4. Copy your mailbox.org password to .ssh/mailbox.org."
+echo " 5. Log into Firefox account and set up extensions, if needed."
+echo ""
+echo "Enjoy!"