Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 65 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
# settingFiles

Personal dotfiles and OS setup scripts. This repository separates OS/target
environments by **branch** instead of by directory — clone the branch that
matches your target machine, not `master` directly.

## Branches

| Branch | Purpose | Notes |
|---|---|---|
| `master` | Common base | Shared dotfiles only; starting point for new OS branches |
| `arch` | Arch Linux (x86_64) | GNOME desktop, Steam, hibernate support |
| `macOS` | macOS | Homebrew, Karabiner-Elements |
| `ubuntu` | Ubuntu | |
| `alpine` | Alpine Linux | Docker container use |
| `raspi` | Raspberry Pi OS (Debian-based, `apt`) | Headless/CLI |
| `raspi-arch` | Arch Linux ARM on Raspberry Pi | Headless/CLI |

`.vimrc` is identical on every branch, and the bulk of `.zshrc` is shared too —
branches only differ in a small OS-specific tail (PATH entries, keychain/GPG
setup, plugin list, etc.). `master` holds the canonical copies of these
shared files. When editing the shared portions, port the same change to the
other branches by hand; there is no symlink/build step tying the branches
together, so nothing will warn you if they drift.

## Installation
Install zsh, tmux, neovim, git curl with your package manager.

Then,
Install `zsh`, `tmux`, `neovim`, `git`, and `curl` with your package manager
first.

Then clone the branch matching your target OS (see the table above):

```
git clone -b <branch> https://github.com/LJLee37/settingfiles.git ~/gitRepos/settingfiles
```

and run `set.sh` from inside the repo.

After running `set.sh`, enter `nvim`, then run `:call coc#util#install()` if
you hit a coc error.

## Arch Linux ARM (raspi-arch) install order

`git clone https://github.com/LJLee37/settingfiles.git ~/gitRepos/settingfiles`
This branch targets a headless Arch Linux ARM (ALARM) install on a
Raspberry Pi, scoped like `raspi` (CLI-only, no desktop/Steam like the
x86_64 `arch` branch has). ALARM's install procedure is fundamentally
different from x86 Arch's `pacstrap`/GRUB flow — see the comments at the
top of each script for details (prebuilt rootfs tarball + `bsdtar`
instead of `pacstrap`, `pacman-key --populate archlinuxarm`, Pi
firmware boot instead of GRUB, no `intel-ucode`).

And run `set.sh` in the repo.
1. On a **separate** Linux machine with the SD card/USB drive attached,
clone this branch and run `install-sdcard.sh /dev/sdX` (partitions,
formats, and extracts the ALARM rootfs onto the media). The Pi has no
OS yet at this point, so this step can't run on the Pi itself.
2. Boot the Pi from that media. SSH in as `alarm`/`alarm` (or `root`/`root`),
copy `install-firstboot.sh` over, and run it as root — pass `5` as the
first argument on a Raspberry Pi 5 (see the script header). This does
`pacman-key` init, a full system update, locale/timezone/hostname,
creates a user account, and enables NetworkManager/bluetooth/sshd.
3. Reboot, log in as that user, then run `set.sh` to pull in dotfiles.
4. `backup.sh` makes a full-system + boot-partition backup and copies it
to a LAN host — check the destination host/path before running it.

After running `set.sh` file, enter `nvim` to enter neovim, then enter `:call coc#util#install()` if you encounter coc error.
Written against a Raspberry Pi 4 Model B (64-bit) using the generic
`ArchLinuxARM-rpi-aarch64-latest.tar.gz` image (ALARM lists this as also
covering the Pi 3 and 400). The Pi 5 has no dedicated ALARM image as of
this writing; `install-firstboot.sh 5` swaps in the kernel package the
community currently recommends there instead. Re-check
https://archlinuxarm.org for your specific model before a new install —
ALARM's supported devices, image names, and procedure do change over time.
6 changes: 4 additions & 2 deletions backup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Adapted from the raspi (Raspberry Pi OS) branch's backup.sh: ALARM
# mounts the boot partition at /boot directly, not /boot/firmware.
curdate=$(date +%F%Z)
sudo tar -cvpzf backup-$curdate.tar.gz --exclude=/home/ljlee/backup*.tar.gz --one-file-system /
sudo tar -cvpzf backup-firmware-$curdate.tar.gz --exclude=/home/ljlee/backup*.tar.gz --one-file-system /boot/firmware
sudo tar -cvpzf backup-boot-$curdate.tar.gz --exclude=/home/ljlee/backup*.tar.gz --one-file-system /boot
scp backup-$curdate.tar.gz 192.168.35.203:Downloads/
scp backup-firmware-$curdate.tar.gz 192.168.35.203:Downloads/
scp backup-boot-$curdate.tar.gz 192.168.35.203:Downloads/
echo Backup complete!
89 changes: 89 additions & 0 deletions install-firstboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
# First-boot provisioning for Arch Linux ARM (ALARM) on a Raspberry Pi.
# Run as root on the Pi itself, after booting the media prepared by
# install-sdcard.sh.
#
# Unlike x86 Arch (see the `arch` branch's install2.sh), there is:
# - no GRUB / EFI bootloader step -- the Pi's own firmware
# (bootcode.bin/start*.elf) loads the kernel directly per
# /boot/config.txt, so there's nothing here equivalent to
# grub-install/grub-mkconfig.
# - no mkinitcpio/initramfs step -- the stock ALARM Pi image boots the
# kernel image directly without an initramfs. Only add one back if
# you later need it (e.g. for disk encryption).
# - no intel-ucode or other x86 microcode package.
# - an extra ALARM-specific step (pacman-key --populate archlinuxarm)
# that plain Arch installs don't need, since the base tarball's
# package signatures are signed by ALARM's own keys.
#
# Written against a Raspberry Pi 4 Model B (64-bit). Pass "5" as $1 on
# a Pi 5 to additionally swap in the RPi-specific kernel package that
# the community currently recommends there in place of the generic
# aarch64 kernel the tarball ships with (Pi 5 has no official ALARM
# image as of this writing -- verify against https://archlinuxarm.org
# before trusting this on a new install).
set -euo pipefail

PI_MODEL="${1:-4}"
USERNAME="${USERNAME:-ljlee}"
HOSTNAME_VALUE="${HOSTNAME_VALUE:-raspi-arch}"

echo "==> Initializing pacman keyring for ALARM"
pacman-key --init
pacman-key --populate archlinuxarm

echo "==> Full system update"
pacman -Syu --noconfirm

if [[ "$PI_MODEL" == "5" ]]; then
echo "==> Pi 5: installing linux-rpi-16k kernel in place of the generic aarch64 kernel"
pacman -S --noconfirm linux-rpi-16k
fi

echo "==> Installing base packages"
pacman -S --needed --noconfirm \
zsh tmux neovim git base-devel htop keychain gdb ctags neofetch \
python-pip python-neovim \
networkmanager iwd bluez bluez-utils \
sudo openssh man-db man-pages

echo "==> Locale"
{
echo "en_US.UTF-8 UTF-8"
echo "en_GB.UTF-8 UTF-8"
echo "ko_KR.UTF-8 UTF-8"
echo "ja_JP.UTF-8 UTF-8"
echo "eo.UTF-8 UTF-8"
} >> /etc/locale.gen
locale-gen
echo "LANG=en_GB.UTF-8" > /etc/locale.conf

echo "==> Timezone"
ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
hwclock --systohc

echo "==> Hostname"
echo "$HOSTNAME_VALUE" > /etc/hostname

echo "==> User account ($USERNAME)"
useradd -m -G wheel -s /bin/zsh "$USERNAME"
passwd "$USERNAME"
echo "Uncomment '%wheel ALL=(ALL:ALL) ALL' in the editor that opens next:"
visudo

echo "==> Neovim symlinks"
ln -sf /usr/bin/nvim /usr/local/bin/vim
ln -sf /usr/bin/nvim /usr/local/bin/vi

echo "==> Enabling services"
# The stock image networks eth0 via systemd-networkd/dhcpcd by default;
# disable those so NetworkManager doesn't fight them for the interface.
systemctl disable systemd-networkd dhcpcd 2>/dev/null || true
systemctl enable NetworkManager
systemctl enable bluetooth
systemctl enable sshd

cat <<EOF

Done. Reboot, log in as $USERNAME, then run set.sh to pull in dotfiles.
EOF
91 changes: 91 additions & 0 deletions install-sdcard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
# Prepares SD card / USB media with Arch Linux ARM (ALARM) for a Raspberry Pi.
#
# Run this on a SEPARATE Linux machine with the target media attached
# (e.g. via a USB SD card reader) -- the Pi has no OS yet at this point,
# so unlike the `arch` branch's install1.sh (which runs from inside an
# Arch ISO on the target machine itself via pacstrap+genfstab), ALARM is
# installed by extracting a prebuilt rootfs tarball from the outside.
#
# Written against a Raspberry Pi 4 Model B (64-bit) using the generic
# "rpi-aarch64" image, which ALARM also lists as covering the Pi 3 and
# 400. The Pi 5 has no dedicated ALARM image as of this writing; the
# generic aarch64 tarball is reported to work if you swap to the
# linux-rpi/linux-rpi-16k kernel package after first boot (see
# install-firstboot.sh). Re-check https://archlinuxarm.org for the
# current recommended image/procedure for your model before relying on
# this script -- ALARM's supported devices and package names change.
set -euo pipefail

# --- Configuration -----------------------------------------------------
# Target block device for the WHOLE disk, e.g. /dev/sdX (USB reader) or
# /dev/mmcblk0 (built-in SD slot). NOT a partition (no trailing number).
DEVICE="${1:?Usage: $0 /dev/sdX [tarball-url]}"
TARBALL_URL="${2:-http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz}"
BOOT_SIZE_MIB=256
MOUNT_ROOT=/mnt/alarm-root

if [[ ! -b "$DEVICE" ]]; then
echo "error: $DEVICE is not a block device" >&2
exit 1
fi

for cmd in parted mkfs.vfat mkfs.ext4 bsdtar curl; do
command -v "$cmd" >/dev/null || { echo "error: $cmd is required on the host running this script" >&2; exit 1; }
done

# Partition suffix differs between /dev/sdX (sdX1) and /dev/mmcblk0 or
# /dev/nvme0n1 style devices (mmcblk0p1).
case "$DEVICE" in
*mmcblk*|*nvme*) PART_SUFFIX=p ;;
*) PART_SUFFIX= ;;
esac
BOOT_PART="${DEVICE}${PART_SUFFIX}1"
ROOT_PART="${DEVICE}${PART_SUFFIX}2"

echo "This will ERASE ALL DATA on $DEVICE ($BOOT_PART, $ROOT_PART)."
read -r -p "Type 'yes' to continue: " confirm
[[ "$confirm" == "yes" ]] || { echo "Aborted."; exit 1; }

echo "==> Partitioning $DEVICE"
parted --script "$DEVICE" \
mklabel msdos \
mkpart primary fat32 1MiB "${BOOT_SIZE_MIB}MiB" \
mkpart primary ext4 "${BOOT_SIZE_MIB}MiB" 100% \
set 1 boot on

echo "==> Formatting partitions"
mkfs.vfat -F 32 -n BOOT "$BOOT_PART"
mkfs.ext4 -F -L root "$ROOT_PART"

echo "==> Mounting"
mkdir -p "$MOUNT_ROOT"
mount "$ROOT_PART" "$MOUNT_ROOT"
mkdir -p "$MOUNT_ROOT/boot"
mount "$BOOT_PART" "$MOUNT_ROOT/boot"

echo "==> Downloading $TARBALL_URL"
TARBALL="/tmp/$(basename "$TARBALL_URL")"
curl -L -o "$TARBALL" "$TARBALL_URL"

# bsdtar (not GNU tar) is required: it preserves the extended
# attributes/ACLs the rootfs relies on, which plain `tar` can silently
# drop or mishandle.
echo "==> Extracting rootfs (bsdtar, preserves xattrs/ACLs)"
bsdtar -xpf "$TARBALL" -C "$MOUNT_ROOT"

sync
umount "$MOUNT_ROOT/boot" "$MOUNT_ROOT"
rmdir "$MOUNT_ROOT/boot" "$MOUNT_ROOT" 2>/dev/null || true
rm -f "$TARBALL"

cat <<EOF

Done. Insert $DEVICE into the Pi and boot it.

Default login over SSH (or console) is alarm/alarm or root/root.
Once booted, copy install-firstboot.sh over and run it as root:

scp install-firstboot.sh alarm@<pi-ip>:~
ssh alarm@<pi-ip> 'su -c "bash install-firstboot.sh"'
EOF
8 changes: 0 additions & 8 deletions install.sh

This file was deleted.

4 changes: 2 additions & 2 deletions set.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ curl -sL install-node.now.sh/lts | sudo bash
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
mkdir ~/.config
mkdir ~/.config/nvim
cp ~/gitRepos/Personal/settingfiles/init.vim ~/.config/nvim/init.vim
cp ~/gitRepos/settingfiles/init.vim ~/.config/nvim/init.vim
mv ~/.zshrc ~/.zshrc.bak
cp ~/gitRepos/Personal/settingfiles/.zshrc ~/.zshrc
cp ~/gitRepos/settingfiles/.zshrc ~/.zshrc
ln -s ~/.config/nvim/init.vim ~/init.vim
nvim +PlugInstall +qall