diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-14 09:34:40 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-14 09:34:40 +0200 |
| commit | 37c0762a51d6ef2c2d859d779839aeb5257a8d7d (patch) | |
| tree | fb6b8add93b322779d60c61ea0083be1413258b2 /scripts/setup-config-alpine | |
| parent | 04f32fb0f91a3e61d6d2c2dedeae64b6f6d639ac (diff) | |
| download | config-37c0762a51d6ef2c2d859d779839aeb5257a8d7d.tar.gz config-37c0762a51d6ef2c2d859d779839aeb5257a8d7d.zip | |
Shellcheck and simplify standby logic
Diffstat (limited to 'scripts/setup-config-alpine')
| -rwxr-xr-x | scripts/setup-config-alpine | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/scripts/setup-config-alpine b/scripts/setup-config-alpine index 5b414aa..23cb6a8 100755 --- a/scripts/setup-config-alpine +++ b/scripts/setup-config-alpine | |||
| @@ -25,8 +25,8 @@ print_log "Installing software from alpine repositories" | |||
| 25 | tmp_repo_file=$(mktemp) | 25 | tmp_repo_file=$(mktemp) |
| 26 | main_repo="$(grep main /etc/apk/repositories)" | 26 | main_repo="$(grep main /etc/apk/repositories)" |
| 27 | community_repo="$(echo "$main_repo" | sed 's/main/community/')" | 27 | community_repo="$(echo "$main_repo" | sed 's/main/community/')" |
| 28 | printf '%s\n%s\n' "$main_repo" "$community_repo" > $tmp_repo_file | 28 | printf '%s\n%s\n' "$main_repo" "$community_repo" > "$tmp_repo_file" |
| 29 | doas mv $tmp_repo_file /etc/apk/repositories | 29 | doas mv "$tmp_repo_file" /etc/apk/repositories |
| 30 | 30 | ||
| 31 | ./scripts/apkworld | 31 | ./scripts/apkworld |
| 32 | 32 | ||
| @@ -47,7 +47,7 @@ done | |||
| 47 | cd | 47 | cd |
| 48 | 48 | ||
| 49 | tmp_xorg_file=$(mktemp) | 49 | tmp_xorg_file=$(mktemp) |
| 50 | cat <<EOF > $tmp_xorg_file | 50 | cat <<EOF > "$tmp_xorg_file" |
| 51 | Section "InputClass" | 51 | Section "InputClass" |
| 52 | Identifier "libinput touchpad catchall" | 52 | Identifier "libinput touchpad catchall" |
| 53 | MatchIsTouchpad "on" | 53 | MatchIsTouchpad "on" |
| @@ -58,48 +58,42 @@ EndSection | |||
| 58 | EOF | 58 | EOF |
| 59 | 59 | ||
| 60 | doas mkdir -p /etc/X11/xorg.conf.d | 60 | doas mkdir -p /etc/X11/xorg.conf.d |
| 61 | doas mv $tmp_xorg_file /etc/X11/xorg.conf.d/40-libinput.conf | 61 | doas mv "$tmp_xorg_file" /etc/X11/xorg.conf.d/40-libinput.conf |
| 62 | 62 | ||
| 63 | tmp_doas_file=$(mktemp) | 63 | tmp_doas_file=$(mktemp) |
| 64 | cp /etc/doas.d/20-wheel.conf $tmp_doas_file | 64 | cp /etc/doas.d/20-wheel.conf "$tmp_doas_file" |
| 65 | for c in poweroff reboot; do | 65 | for c in poweroff reboot; do |
| 66 | printf 'permit nopass :wheel as root cmd %s\n' "$c" >> $tmp_doas_file | 66 | printf 'permit nopass :wheel as root cmd %s\n' "$c" >> "$tmp_doas_file" |
| 67 | done | 67 | done |
| 68 | doas cp $tmp_doas_file /etc/doas.d/20-wheel.conf | 68 | doas cp "$tmp_doas_file" /etc/doas.d/20-wheel.conf |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | print_log "Configuring the console" | 71 | print_log "Configuring the console" |
| 72 | 72 | ||
| 73 | tmp_kmap_file=$(mktemp) | 73 | tmp_kmap_file=$(mktemp) |
| 74 | tmp_loadkmap_file=$(mktemp) | 74 | tmp_loadkmap_file=$(mktemp) |
| 75 | printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > $tmp_kmap_file | 75 | printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > "$tmp_kmap_file" |
| 76 | doas loadkeys $tmp_kmap_file | 76 | doas loadkeys "$tmp_kmap_file" |
| 77 | dumpkmap > us-swapesc.bmap | 77 | dumpkmap > us-swapesc.bmap |
| 78 | gzip us-swapesc.bmap | 78 | gzip us-swapesc.bmap |
| 79 | doas mv us-swapesc.bmap.gz /etc/keymap/ | 79 | doas mv us-swapesc.bmap.gz /etc/keymap/ |
| 80 | printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > $tmp_loadkmap_file | 80 | printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > "$tmp_loadkmap_file" |
| 81 | doas mv $tmp_loadkmap_file /etc/conf.d/loadkmap | 81 | doas mv "$tmp_loadkmap_file" /etc/conf.d/loadkmap |
| 82 | 82 | ||
| 83 | tmp_blacklist_file=$(mktemp) | 83 | tmp_blacklist_file=$(mktemp) |
| 84 | cp /etc/modprobe.d/blacklist.conf $tmp_blacklist_file | 84 | cp /etc/modprobe.d/blacklist.conf "$tmp_blacklist_file" |
| 85 | printf '\n# Disable PC speaker for real\nblacklist pcspkr\n' >> $tmp_blacklist_file | 85 | printf '\n# Disable PC speaker for real\nblacklist pcspkr\n' >> "$tmp_blacklist_file" |
| 86 | doas cp $tmp_blacklist_file /etc/modprobe.d/blacklist.conf | 86 | doas cp "$tmp_blacklist_file" /etc/modprobe.d/blacklist.conf |
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)" | 89 | print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)" |
| 90 | 90 | ||
| 91 | tmp_acpi_file=$(mktemp) | 91 | tmp_acpi_file=$(mktemp) |
| 92 | cat <<EOF > $tmp_acpi_file | 92 | printf '#!/bin/sh\necho mem > /sys/power/state\n' > "$tmp_acpi_file" |
| 93 | #!/bin/sh | ||
| 94 | |||
| 95 | xhci="$(grep XHCI /proc/acpi/wakeup | awk '{print $3}')" | ||
| 96 | [ "$xhci" == '*enabled' ] && echo XHCI > /proc/acpi/wakeup | ||
| 97 | echo mem > /sys/power/state | ||
| 98 | EOF | ||
| 99 | 93 | ||
| 100 | for dir in LID PWRF; do | 94 | for dir in LID PWRF; do |
| 101 | doas mkdir -p /etc/acpi/$dir | 95 | doas mkdir -p /etc/acpi/$dir |
| 102 | doas cp $tmp_acpi_file /etc/acpi/$dir/00000080 | 96 | doas cp "$tmp_acpi_file" /etc/acpi/$dir/00000080 |
| 103 | doas chmod +x /etc/acpi/$dir/00000080 | 97 | doas chmod +x /etc/acpi/$dir/00000080 |
| 104 | done | 98 | done |
| 105 | 99 | ||
| @@ -109,7 +103,7 @@ doas rc-update add acpid | |||
| 109 | print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)" | 103 | print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)" |
| 110 | 104 | ||
| 111 | tmp_iwd_file=$(mktemp) | 105 | tmp_iwd_file=$(mktemp) |
| 112 | cat <<EOF > $tmp_iwd_file | 106 | cat <<EOF > "$tmp_iwd_file" |
| 113 | [General] | 107 | [General] |
| 114 | EnableNetworkConfiguration=True | 108 | EnableNetworkConfiguration=True |
| 115 | 109 | ||
| @@ -117,7 +111,7 @@ EnableNetworkConfiguration=True | |||
| 117 | NameResolvingService=resolvconf | 111 | NameResolvingService=resolvconf |
| 118 | EOF | 112 | EOF |
| 119 | 113 | ||
| 120 | doas mv $tmp_iwd_file /etc/iwd/main.conf | 114 | doas mv "$tmp_iwd_file" /etc/iwd/main.conf |
| 121 | 115 | ||
| 122 | doas rc-update add iwd boot | 116 | doas rc-update add iwd boot |
| 123 | doas rc-update del networking boot | 117 | doas rc-update del networking boot |
| @@ -136,8 +130,8 @@ doas rc-service bluetooth start | |||
| 136 | print_log "Setting up SyncThing" | 130 | print_log "Setting up SyncThing" |
| 137 | 131 | ||
| 138 | tmp_syncthing_file=$(mktemp) | 132 | tmp_syncthing_file=$(mktemp) |
| 139 | doas print 'SYNCTHING_USER="sebastiano"\n' > $tmp_syncthing_file | 133 | doas print 'SYNCTHING_USER="sebastiano"\n' > "$tmp_syncthing_file" |
| 140 | mv $tmp_syncthing_file /etc/conf.d/syncthing | 134 | mv "$tmp_syncthing_file" /etc/conf.d/syncthing |
| 141 | doas rc-update add syncthing | 135 | doas rc-update add syncthing |
| 142 | doas rc-service start syncthing | 136 | doas rc-service start syncthing |
| 143 | 137 | ||
