setup-config-alpine (4529B)
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 ip udhcpc mount umount; 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 if (dumpkmap > /dev/null 2>&1); then 75 tmp_loadkmap_file=$(mktemp) 76 printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > "$tmp_kmap_file" 77 doas loadkeys "$tmp_kmap_file" 78 dumpkmap > us-swapesc.bmap 79 gzip us-swapesc.bmap 80 doas mv us-swapesc.bmap.gz /etc/keymap/ 81 printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > "$tmp_loadkmap_file" 82 doas mv "$tmp_loadkmap_file" /etc/conf.d/loadkmap 83 else 84 echo "dumpkmap failed, skipping console keybaord settings" 85 fi 86 87 tmp_blacklist_file=$(mktemp) 88 cp /etc/modprobe.d/blacklist.conf "$tmp_blacklist_file" 89 printf '\n# Disable PC speaker for real\nblacklist pcspkr\n' >> "$tmp_blacklist_file" 90 doas cp "$tmp_blacklist_file" /etc/modprobe.d/blacklist.conf 91 92 93 print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)" 94 95 tmp_acpi_file=$(mktemp) 96 printf '#!/bin/sh\necho mem > /sys/power/state\n' > "$tmp_acpi_file" 97 98 for dir in LID PWRF; do 99 doas mkdir -p /etc/acpi/$dir 100 doas cp "$tmp_acpi_file" /etc/acpi/$dir/00000080 101 doas chmod +x /etc/acpi/$dir/00000080 102 done 103 104 doas rc-update add acpid 105 106 107 print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)" 108 109 tmp_iwd_file=$(mktemp) 110 cat <<EOF > "$tmp_iwd_file" 111 [General] 112 EnableNetworkConfiguration=True 113 114 [Network] 115 NameResolvingService=resolvconf 116 EOF 117 118 doas mv "$tmp_iwd_file" /etc/iwd/main.conf 119 doas cp /dev/null /etc/network/interfaces 120 121 doas rc-update add iwd boot 122 doas rc-update del networking boot 123 doas rc-service --ifstarted wpa_supplicant stop 124 doas rc-service iwd start 125 126 127 print_log "Setting up cups" 128 129 doas adduser sebastiano lpadmin 130 doas rc-update add cupsd 131 132 133 print_log "Setting up bluetooth (see https://wiki.alpinelinux.org/wiki/Bluetooth)" 134 135 doas modprobe btusb 136 doas adduser sebastiano lp 137 doas rc-update add bluetooth 138 doas rc-service bluetooth start 139 140 141 print_log "Setting up SyncThing" 142 143 tmp_syncthing_file=$(mktemp) 144 doas print 'SYNCTHING_USER="sebastiano"\n' > "$tmp_syncthing_file" 145 mv "$tmp_syncthing_file" /etc/conf.d/syncthing 146 doas rc-update add syncthing 147 doas rc-service start syncthing 148 149 150 print_log "Generating SSH keys" 151 152 ssh-keygen 153 154 155 echo "" 156 echo "All done!" 157 echo "" 158 echo "You should log out and back in to apply some of the changes." 159 echo "Additionally, you may want to perform the following manual steps:" 160 echo " 1. Connect to WiFi again. The default network manager has been" 161 echo " replaced by iwd." 162 echo " 2. Add your SSH key to various servers, namely:" 163 echo " 1a. Artemisia" 164 echo " 1b. pizoc (both regular user and git)" 165 echo " 1c. github" 166 echo " 1d. lampone" 167 echo " 3. Share folders in SyncThing, including but not limited to:" 168 echo " 2a. box with Artemisia, pizoc and phone" 169 echo " 2b. file-drop with phone" 170 echo " 4. Copy your mailbox.org password to .ssh/mailbox.org." 171 echo " 5. Log into Firefox account and set up extensions, if needed." 172 echo "" 173 echo "Enjoy!"