diff options
Diffstat (limited to '')
| -rwxr-xr-x | scripts/setup-config-alpine | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/scripts/setup-config-alpine b/scripts/setup-config-alpine new file mode 100755 index 0000000..a9a63b9 --- /dev/null +++ b/scripts/setup-config-alpine | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Set up my configuration on a new Alpine Linux installation. | ||
| 4 | |||
| 5 | print_log() { | ||
| 6 | printf '\n>>> %s \n\n' "$@" | ||
| 7 | } | ||
| 8 | |||
| 9 | set -e # Abort on first error | ||
| 10 | |||
| 11 | |||
| 12 | print_log "Installing git and cloning the config repo" | ||
| 13 | |||
| 14 | doas apk add git | ||
| 15 | cd ~ | ||
| 16 | git init . | ||
| 17 | git remote add origin https://git.tronto.net/config | ||
| 18 | git fetch && git checkout -f master | ||
| 19 | git remote set-url origin git@tronto.net:config | ||
| 20 | git remote set-url origin --add --push git@github.com:sebastianotronto/config | ||
| 21 | |||
| 22 | |||
| 23 | print_log "Installing software from alpine repositories" | ||
| 24 | |||
| 25 | tmp_repo_file=$(mktemp) | ||
| 26 | main_repo="$(grep main /etc/apk/repositories)" | ||
| 27 | community_repo="$(echo "$main_repo" | sed 's/main/community/')" | ||
| 28 | printf '%s\n%s\n' "$main_repo" "$community_repo" > $tmp_repo_file | ||
| 29 | doas mv $tmp_repo_file /etc/apk/repositories | ||
| 30 | |||
| 31 | ./scripts/apkworld | ||
| 32 | |||
| 33 | |||
| 34 | print_log "Installing and configuring desktop environment" | ||
| 35 | |||
| 36 | doas setup-xorg-base | ||
| 37 | |||
| 38 | mkdir -p src | ||
| 39 | cd src | ||
| 40 | for i in dmenu dwm st; do | ||
| 41 | git clone https://git.suckless.org/$i | ||
| 42 | cd $i | ||
| 43 | cp ~/.config/$i/config.h ./config.h | ||
| 44 | make && doas make install | ||
| 45 | done | ||
| 46 | cd | ||
| 47 | |||
| 48 | |||
| 49 | print_log "Swapping Escape and Caps Lock in console" | ||
| 50 | |||
| 51 | tmp_kmap_file=$(mktemp) | ||
| 52 | tmp_loadkmap_file=$(mktemp) | ||
| 53 | printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > $tmp_kmap_file | ||
| 54 | doas loadkeys $tmp_kmap_file | ||
| 55 | dumpkmap > us-swapesc.bmap | ||
| 56 | gzip us-swapesc.bmap | ||
| 57 | doas mv us-swapesc.bmap.gz /etc/keymap/ | ||
| 58 | printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > $tmp_loadkmap_file | ||
| 59 | doas mv $tmp_loadkmap_file /etc/conf.d/loadkmap | ||
| 60 | |||
| 61 | |||
| 62 | print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)" | ||
| 63 | |||
| 64 | tmp_acpi_file=$(mktemp) | ||
| 65 | cat <<EOF > $tmp_acpi_file | ||
| 66 | xhci="$(grep XHCI /proc/acpi/wakeup | awk '{print $3}')" | ||
| 67 | [ "$xhci" == '*enabled' ] && echo XHCI > /proc/acpi/wakeup | ||
| 68 | echo mem > /sys/power/state | ||
| 69 | EOF | ||
| 70 | |||
| 71 | for dir in LID PWRF; do | ||
| 72 | doas mkdir -p /etc/acpi/$dir | ||
| 73 | doas cp $tmp_acpi_file /etc/acpi/$dir/00000080 | ||
| 74 | doas chmod +x /etc/acpi/$dir/00000080 | ||
| 75 | done | ||
| 76 | |||
| 77 | |||
| 78 | print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)" | ||
| 79 | |||
| 80 | tmp_iwd_file=$(mktemp) | ||
| 81 | cat <<EOF > $tmp_iwd_file | ||
| 82 | [General] | ||
| 83 | EnableNetworkConfiguration=True | ||
| 84 | |||
| 85 | [Network] | ||
| 86 | NameResolvingService=resolvconf | ||
| 87 | EOF | ||
| 88 | |||
| 89 | doas mv $tmp_iwd_file /etc/iwd/main.conf | ||
| 90 | |||
| 91 | doas rc-update add iwd boot | ||
| 92 | doas rc-update del networking boot | ||
| 93 | doas rc-service --ifstarted wpa_supplicant stop | ||
| 94 | doas rc-service iwd start | ||
| 95 | |||
| 96 | |||
| 97 | print_log "Setting up bluetooth (see https://wiki.alpinelinux.org/wiki/Bluetooth)" | ||
| 98 | |||
| 99 | doas modprobe btusb | ||
| 100 | doas adduser sebastiano lp | ||
| 101 | doas rc-update add bluetooth | ||
| 102 | doas rc-service bluetooth start | ||
| 103 | |||
| 104 | |||
| 105 | print_log "Setting up SyncThing" | ||
| 106 | |||
| 107 | tmp_syncthing_file=$(mktemp) | ||
| 108 | doas print 'SYNCTHING_USER="sebastiano"\n' > $tmp_syncthing_file | ||
| 109 | mv $tmp_syncthing_file /etc/conf.d/syncthing | ||
| 110 | doas rc-update add syncthing | ||
| 111 | doas rc-service start syncthing | ||
| 112 | |||
| 113 | |||
| 114 | print_log "Generating SSH keys" | ||
| 115 | |||
| 116 | ssh-keygen | ||
| 117 | |||
| 118 | |||
| 119 | echo "" | ||
| 120 | echo "All done!" | ||
| 121 | echo "" | ||
| 122 | echo "You should log out and back in to apply some of the changes." | ||
| 123 | echo "Additionally, you may want to perform the following manual steps:" | ||
| 124 | echo " 1. Connect to WiFi again. The default network manager has been" | ||
| 125 | echo " replaced by iwd." | ||
| 126 | echo " 2. Add your SSH key to various servers, namely:" | ||
| 127 | echo " 1a. Artemisia" | ||
| 128 | echo " 1b. pizoc (both regular user and git)" | ||
| 129 | echo " 1c. github" | ||
| 130 | echo " 3. Share folders in SyncThing, including but not limited to:" | ||
| 131 | echo " 2a. box with Artemisia, pizoc and phone" | ||
| 132 | echo " 2b. file-drop with phone" | ||
| 133 | echo " 4. Copy your mailbox.org password to .ssh/mailbox.org" | ||
| 134 | echo "" | ||
| 135 | echo "Enjoy!" | ||
