commit 37c0762a51d6ef2c2d859d779839aeb5257a8d7d
parent 04f32fb0f91a3e61d6d2c2dedeae64b6f6d639ac
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu, 14 May 2026 09:34:40 +0200
Shellcheck and simplify standby logic
Diffstat:
1 file changed, 20 insertions(+), 26 deletions(-)
diff --git a/scripts/setup-config-alpine b/scripts/setup-config-alpine
@@ -25,8 +25,8 @@ 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
+printf '%s\n%s\n' "$main_repo" "$community_repo" > "$tmp_repo_file"
+doas mv "$tmp_repo_file" /etc/apk/repositories
./scripts/apkworld
@@ -47,7 +47,7 @@ done
cd
tmp_xorg_file=$(mktemp)
-cat <<EOF > $tmp_xorg_file
+cat <<EOF > "$tmp_xorg_file"
Section "InputClass"
Identifier "libinput touchpad catchall"
MatchIsTouchpad "on"
@@ -58,48 +58,42 @@ EndSection
EOF
doas mkdir -p /etc/X11/xorg.conf.d
-doas mv $tmp_xorg_file /etc/X11/xorg.conf.d/40-libinput.conf
+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
+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
+ 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
+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
+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
+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
+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)
-cat <<EOF > $tmp_acpi_file
-#!/bin/sh
-
-xhci="$(grep XHCI /proc/acpi/wakeup | awk '{print $3}')"
-[ "$xhci" == '*enabled' ] && echo XHCI > /proc/acpi/wakeup
-echo mem > /sys/power/state
-EOF
+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 cp "$tmp_acpi_file" /etc/acpi/$dir/00000080
doas chmod +x /etc/acpi/$dir/00000080
done
@@ -109,7 +103,7 @@ 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
+cat <<EOF > "$tmp_iwd_file"
[General]
EnableNetworkConfiguration=True
@@ -117,7 +111,7 @@ EnableNetworkConfiguration=True
NameResolvingService=resolvconf
EOF
-doas mv $tmp_iwd_file /etc/iwd/main.conf
+doas mv "$tmp_iwd_file" /etc/iwd/main.conf
doas rc-update add iwd boot
doas rc-update del networking boot
@@ -136,8 +130,8 @@ 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 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