diff options
Diffstat (limited to 'src/setup-config-alpine')
| -rwxr-xr-x | src/setup-config-alpine | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/src/setup-config-alpine b/src/setup-config-alpine new file mode 100755 index 0000000..23cb6a8 --- /dev/null +++ b/src/setup-config-alpine | |||
| @@ -0,0 +1,162 @@ | |||
| 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 | cd .. | ||
| 46 | done | ||
| 47 | cd | ||
| 48 | |||
| 49 | tmp_xorg_file=$(mktemp) | ||
| 50 | cat <<EOF > "$tmp_xorg_file" | ||
| 51 | Section "InputClass" | ||
| 52 | Identifier "libinput touchpad catchall" | ||
| 53 | MatchIsTouchpad "on" | ||
| 54 | MatchDevicePath "/dev/input/event*" | ||
| 55 | Driver "libinput" | ||
| 56 | Option "Tapping" "on" | ||
| 57 | EndSection | ||
| 58 | EOF | ||
| 59 | |||
| 60 | doas mkdir -p /etc/X11/xorg.conf.d | ||
| 61 | doas mv "$tmp_xorg_file" /etc/X11/xorg.conf.d/40-libinput.conf | ||
| 62 | |||
| 63 | tmp_doas_file=$(mktemp) | ||
| 64 | cp /etc/doas.d/20-wheel.conf "$tmp_doas_file" | ||
| 65 | for c in poweroff reboot; do | ||
| 66 | printf 'permit nopass :wheel as root cmd %s\n' "$c" >> "$tmp_doas_file" | ||
| 67 | done | ||
| 68 | doas cp "$tmp_doas_file" /etc/doas.d/20-wheel.conf | ||
| 69 | |||
| 70 | |||
| 71 | print_log "Configuring the console" | ||
| 72 | |||
| 73 | tmp_kmap_file=$(mktemp) | ||
| 74 | tmp_loadkmap_file=$(mktemp) | ||
| 75 | printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > "$tmp_kmap_file" | ||
| 76 | doas loadkeys "$tmp_kmap_file" | ||
| 77 | dumpkmap > us-swapesc.bmap | ||
| 78 | gzip us-swapesc.bmap | ||
| 79 | doas mv us-swapesc.bmap.gz /etc/keymap/ | ||
| 80 | printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > "$tmp_loadkmap_file" | ||
| 81 | doas mv "$tmp_loadkmap_file" /etc/conf.d/loadkmap | ||
| 82 | |||
| 83 | tmp_blacklist_file=$(mktemp) | ||
| 84 | cp /etc/modprobe.d/blacklist.conf "$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 | ||
| 87 | |||
| 88 | |||
| 89 | print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)" | ||
| 90 | |||
| 91 | tmp_acpi_file=$(mktemp) | ||
| 92 | printf '#!/bin/sh\necho mem > /sys/power/state\n' > "$tmp_acpi_file" | ||
| 93 | |||
| 94 | for dir in LID PWRF; do | ||
| 95 | doas mkdir -p /etc/acpi/$dir | ||
| 96 | doas cp "$tmp_acpi_file" /etc/acpi/$dir/00000080 | ||
| 97 | doas chmod +x /etc/acpi/$dir/00000080 | ||
| 98 | done | ||
| 99 | |||
| 100 | doas rc-update add acpid | ||
| 101 | |||
| 102 | |||
| 103 | print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)" | ||
| 104 | |||
| 105 | tmp_iwd_file=$(mktemp) | ||
| 106 | cat <<EOF > "$tmp_iwd_file" | ||
| 107 | [General] | ||
| 108 | EnableNetworkConfiguration=True | ||
| 109 | |||
| 110 | [Network] | ||
| 111 | NameResolvingService=resolvconf | ||
| 112 | EOF | ||
| 113 | |||
| 114 | doas mv "$tmp_iwd_file" /etc/iwd/main.conf | ||
| 115 | |||
| 116 | doas rc-update add iwd boot | ||
| 117 | doas rc-update del networking boot | ||
| 118 | doas rc-service --ifstarted wpa_supplicant stop | ||
| 119 | doas rc-service iwd start | ||
| 120 | |||
| 121 | |||
| 122 | print_log "Setting up bluetooth (see https://wiki.alpinelinux.org/wiki/Bluetooth)" | ||
| 123 | |||
| 124 | doas modprobe btusb | ||
| 125 | doas adduser sebastiano lp | ||
| 126 | doas rc-update add bluetooth | ||
| 127 | doas rc-service bluetooth start | ||
| 128 | |||
| 129 | |||
| 130 | print_log "Setting up SyncThing" | ||
| 131 | |||
| 132 | tmp_syncthing_file=$(mktemp) | ||
| 133 | doas print 'SYNCTHING_USER="sebastiano"\n' > "$tmp_syncthing_file" | ||
| 134 | mv "$tmp_syncthing_file" /etc/conf.d/syncthing | ||
| 135 | doas rc-update add syncthing | ||
| 136 | doas rc-service start syncthing | ||
| 137 | |||
| 138 | |||
| 139 | print_log "Generating SSH keys" | ||
| 140 | |||
| 141 | ssh-keygen | ||
| 142 | |||
| 143 | |||
| 144 | echo "" | ||
| 145 | echo "All done!" | ||
| 146 | echo "" | ||
| 147 | echo "You should log out and back in to apply some of the changes." | ||
| 148 | echo "Additionally, you may want to perform the following manual steps:" | ||
| 149 | echo " 1. Connect to WiFi again. The default network manager has been" | ||
| 150 | echo " replaced by iwd." | ||
| 151 | echo " 2. Add your SSH key to various servers, namely:" | ||
| 152 | echo " 1a. Artemisia" | ||
| 153 | echo " 1b. pizoc (both regular user and git)" | ||
| 154 | echo " 1c. github" | ||
| 155 | echo " 1d. lampone" | ||
| 156 | echo " 3. Share folders in SyncThing, including but not limited to:" | ||
| 157 | echo " 2a. box with Artemisia, pizoc and phone" | ||
| 158 | echo " 2b. file-drop with phone" | ||
| 159 | echo " 4. Copy your mailbox.org password to .ssh/mailbox.org." | ||
| 160 | echo " 5. Log into Firefox account and set up extensions, if needed." | ||
| 161 | echo "" | ||
| 162 | echo "Enjoy!" | ||
