sebastiano.tronto.net

Source files and build scripts for my personal website
git clone https://git.tronto.net/sebastiano.tronto.net
Download | Log | Files | Refs | README

setup-config-alpine (4376B)


      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 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 
    120 doas rc-update add iwd boot
    121 doas rc-update del networking boot
    122 doas rc-service --ifstarted wpa_supplicant stop
    123 doas rc-service iwd start
    124 
    125 
    126 print_log "Setting up bluetooth (see https://wiki.alpinelinux.org/wiki/Bluetooth)"
    127 
    128 doas modprobe btusb
    129 doas adduser sebastiano lp
    130 doas rc-update add bluetooth
    131 doas rc-service bluetooth start
    132 
    133 
    134 print_log "Setting up SyncThing"
    135 
    136 tmp_syncthing_file=$(mktemp)
    137 doas print 'SYNCTHING_USER="sebastiano"\n' > "$tmp_syncthing_file"
    138 mv "$tmp_syncthing_file" /etc/conf.d/syncthing
    139 doas rc-update add syncthing
    140 doas rc-service start syncthing
    141 
    142 
    143 print_log "Generating SSH keys"
    144 
    145 ssh-keygen
    146 
    147 
    148 echo ""
    149 echo "All done!"
    150 echo ""
    151 echo "You should log out and back in to apply some of the changes."
    152 echo "Additionally, you may want to perform the following manual steps:"
    153 echo "   1. Connect to WiFi again. The default network manager has been"
    154 echo "      replaced by iwd."
    155 echo "   2. Add your SSH key to various servers, namely:"
    156 echo "      1a. Artemisia"
    157 echo "      1b. pizoc (both regular user and git)"
    158 echo "      1c. github"
    159 echo "      1d. lampone"
    160 echo "   3. Share folders in SyncThing, including but not limited to:"
    161 echo "      2a. box with Artemisia, pizoc and phone"
    162 echo "      2b. file-drop with phone"
    163 echo "   4. Copy your mailbox.org password to .ssh/mailbox.org."
    164 echo "   5. Log into Firefox account and set up extensions, if needed."
    165 echo ""
    166 echo "Enjoy!"