From 17decdaeddb1f085e80949ac81ed600e9a3931e8 Mon Sep 17 00:00:00 2001 From: Aapo Kokko Date: Sun, 28 Jun 2026 10:59:48 +0300 Subject: [PATCH 1/2] Add linting and formatting workflow, renovate for dependencies and fix lint/format issues --- .gitattributes | 4 ++ .github/workflows/lint.yml | 72 +++++++++++++++++++ .shellcheckrc | 11 +++ .../grub-cryptomount/99_cryptomount_check | 12 +++- config/fedora/snapper/snapper-gui-pkg.sh | 8 +-- config/fedora/snapper/snapper-pre.sh | 4 +- install | 2 +- renovate.json | 33 +++++++++ scripts/lib/common.sh | 36 +++++----- scripts/lib/install.sh | 58 ++++++++++----- scripts/setup-arch | 4 +- scripts/setup-debian | 20 +++--- scripts/setup-fedora | 28 ++++---- setup | 3 +- vars/arch-vars | 2 +- vars/debian-vars | 2 +- 16 files changed, 224 insertions(+), 75 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/lint.yml create mode 100644 .shellcheckrc create mode 100644 renovate.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fe2643f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Normalize line endings so shellcheck/shfmt checks stay deterministic. +* text=auto eol=lf + +*.sh text eol=lf diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b189071 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,72 @@ +name: lint + +on: + pull_request: + +permissions: + contents: read + +env: + # Pinned tool version, kept up to date by Renovate (see renovate.json). + # renovate: datasource=github-releases depName=mvdan/sh + SHFMT_VERSION: v3.13.1 + +jobs: + shellcheck: + name: ShellCheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # Scope: actively-maintained scripts only. The Arch installer + # (scripts/install-arch*, scripts/lib/install.sh) is excluded for now and + # tracked to be cleaned up later; scripts/install-arch also fails to parse + # (arithmetic with an embedded [ ] test). shellcheck reads .shellcheckrc. + - name: Run shellcheck + run: | + shellcheck --version + shellcheck -x \ + setup \ + install \ + scripts/setup-arch \ + scripts/setup-debian \ + scripts/setup-fedora \ + scripts/lib/common.sh \ + config/fedora/snapper/*.sh \ + config/fedora/grub-cryptomount/99_cryptomount_check \ + vars/arch-vars \ + vars/debian-vars \ + vars/fedora-vars + + shfmt: + name: shfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install shfmt + run: | + curl -fsSL -o /tmp/shfmt \ + "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64" + chmod +x /tmp/shfmt + + # scripts/install-arch is excluded: shfmt cannot parse line 498 + # (a [ ] test inside $(( )) arithmetic). Everything else is formatted. + - name: Check formatting (-i 4 -ci) + run: | + /tmp/shfmt --version + /tmp/shfmt -d -i 4 -ci \ + setup \ + install \ + scripts/lib/common.sh \ + scripts/lib/install.sh \ + scripts/install-arch-backup \ + scripts/install-arch-reinstall \ + scripts/setup-arch \ + scripts/setup-debian \ + scripts/setup-fedora \ + config/fedora/snapper/*.sh \ + config/fedora/grub-cryptomount/99_cryptomount_check \ + vars/arch-vars \ + vars/debian-vars \ + vars/fedora-vars diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..b79bd2b --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,11 @@ +# ShellCheck config for linux-setup +# +# Scripts source vars/* and scripts/lib/common.sh at runtime via ${REPO_ROOT}, +# and many globals are assigned in one file but consumed in another (or read +# from sourced helpers). That architecture makes a few checks pure noise here: +# +# SC1091 can't follow non-constant 'source "${REPO_ROOT}/..."' +# SC2034 vars/* arrays + cross-file globals look "unused" within one file +# SC2016 intentional literal $VARs in _out '...' install hints / bash -c '...' +external-sources=true +disable=SC1091,SC2034,SC2016 diff --git a/config/fedora/grub-cryptomount/99_cryptomount_check b/config/fedora/grub-cryptomount/99_cryptomount_check index edd23ea..4c86105 100644 --- a/config/fedora/grub-cryptomount/99_cryptomount_check +++ b/config/fedora/grub-cryptomount/99_cryptomount_check @@ -57,11 +57,17 @@ fi echo "[${SCRIPT_NAME}] Line missing or incorrect. Current first line: '${FIRST_LINE}'" echo "[${SCRIPT_NAME}] Fixing ${GRUB_CFG}..." -TMPFILE="$(mktemp)" || { echo "[${SCRIPT_NAME}] ERROR: Could not create temp file. Aborting."; exit 1; } +TMPFILE="$(mktemp)" || { + echo "[${SCRIPT_NAME}] ERROR: Could not create temp file. Aborting." + exit 1 +} -grep -v '^cryptomount -u ' "$GRUB_CFG" > "$TMPFILE" || true +grep -v '^cryptomount -u ' "$GRUB_CFG" >"$TMPFILE" || true -{ echo "$EXPECTED_LINE"; cat "$TMPFILE"; } > "${GRUB_CFG}.new" +{ + echo "$EXPECTED_LINE" + cat "$TMPFILE" +} >"${GRUB_CFG}.new" mv "${GRUB_CFG}.new" "$GRUB_CFG" rm -f "$TMPFILE" diff --git a/config/fedora/snapper/snapper-gui-pkg.sh b/config/fedora/snapper/snapper-gui-pkg.sh index 1023b53..8daf2ec 100755 --- a/config/fedora/snapper/snapper-gui-pkg.sh +++ b/config/fedora/snapper/snapper-gui-pkg.sh @@ -17,10 +17,10 @@ desc=$(cat "$DESC_FILE" 2>/dev/null || echo "") [[ -f "$PKG_FILE" ]] && exit 0 case "$ACTION" in - I|U|D|R) - echo "GUI install ${NAME}" > "$PKG_FILE" + I | U | D | R) + echo "GUI install ${NAME}" >"$PKG_FILE" ;; - E|O) - echo "GUI remove ${NAME}" > "$PKG_FILE" + E | O) + echo "GUI remove ${NAME}" >"$PKG_FILE" ;; esac diff --git a/config/fedora/snapper/snapper-pre.sh b/config/fedora/snapper/snapper-pre.sh index b3a229c..fd9d567 100755 --- a/config/fedora/snapper/snapper-pre.sh +++ b/config/fedora/snapper/snapper-pre.sh @@ -16,7 +16,7 @@ if [[ ! -d /usr/lib/sysimage/libdnf5 ]]; then fi desc=$(/usr/local/bin/snapper-desc.sh "$PID") -echo "$desc" > "$STATE_DIR/snapper_desc_${PID}" +echo "$desc" >"$STATE_DIR/snapper_desc_${PID}" pre=$(snapper -c root create -c number -t pre -p -d "$desc") || exit 1 -echo "$pre" > "$STATE_DIR/snapper_pre_${PID}" +echo "$pre" >"$STATE_DIR/snapper_pre_${PID}" diff --git a/install b/install index 9564530..ee4ef78 100755 --- a/install +++ b/install @@ -35,7 +35,7 @@ main() { --backup) want_backup=1 ;; - -h|--help) + -h | --help) _usage exit 0 ;; diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..3ceef63 --- /dev/null +++ b/renovate.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended", + ":dependencyDashboard" + ], + "packageRules": [ + { + "description": "Auto-merge GitHub Actions and CI tool patch/minor/digest updates", + "matchManagers": ["github-actions", "custom.regex"], + "matchUpdateTypes": ["minor", "patch", "pin", "digest"], + "automerge": true + } + ], + "customManagers": [ + { + "description": "CI tool versions pinned in workflow env: blocks (annotated with # renovate:)", + "customType": "regex", + "managerFilePatterns": ["/^\\.github/workflows/.+\\.ya?ml$/"], + "matchStrings": [ + "# renovate: datasource=(?\\S+) depName=(?\\S+)(?: versioning=(?\\S+))?\\s+\\w+_VERSION:\\s*[\"']?(?[^\"'\\s]+)" + ] + }, + { + "description": "nvm version pinned in setup scripts", + "customType": "regex", + "managerFilePatterns": ["/^scripts/setup-.+$/"], + "matchStrings": ["nvm-sh/nvm/(?v[0-9][0-9.]*)/"], + "depNameTemplate": "nvm-sh/nvm", + "datasourceTemplate": "github-tags" + } + ] +} diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index e928303..0bb56f9 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -53,7 +53,7 @@ _log_cmd_output() { if [ -n "$output" ]; then while IFS= read -r line; do _log "OUT" "$line" - done <<< "$output" + done <<<"$output" fi return "$rc" @@ -167,11 +167,11 @@ _prompt_yes_no() { read -r -p "$prompt_msg" response case $response in - [Yy]|[Yy][Ee][Ss]) + [Yy] | [Yy][Ee][Ss]) _out "${prompt_msg} yes" return 0 ;; - [Nn]|[Nn][Oo]) + [Nn] | [Nn][Oo]) _out "${prompt_msg} no" return 1 ;; @@ -201,11 +201,11 @@ _set_ssh_remote() { if [ "$https_url" != "$ssh_url" ]; then _echo_run git remote set-url origin "$ssh_url" fi - cd - > /dev/null || return 1 + cd - >/dev/null || return 1 } _check_firewall_service() { - command -v "$2" &> /dev/null && systemctl is-active --quiet "$1" && { + command -v "$2" &>/dev/null && systemctl is-active --quiet "$1" && { SETUP_UFW=false _info "Service $1 already installed/enabled. Check rules manually." } @@ -278,8 +278,8 @@ _ensure_systemd_enabled_now() { } _pacman_multilib_enabled() { - [ -f /etc/pacman.conf ] \ - && grep -A1 '^\[multilib\]' /etc/pacman.conf | grep -q '^Include = ' + [ -f /etc/pacman.conf ] && + grep -A1 '^\[multilib\]' /etc/pacman.conf | grep -q '^Include = ' } _ensure_pacman_multilib() { @@ -333,7 +333,7 @@ _setup_git_config() { read -r -p " → " git_email _echo_run mkdir -p "$config_dir" - cat > "$config_file" << EOF + cat >"$config_file" </dev/null; then _echo_run sudo hostnamectl set-hostname "$hostname" else - _echo_run sudo tee /etc/hostname > /dev/null <<< "$hostname" + _echo_run sudo tee /etc/hostname >/dev/null <<<"$hostname" _echo_run sudo hostname "$hostname" fi } _wheel_sudo_nopasswd_enabled() { grep -rE '^[[:space:]]*#?[[:space:]]*%wheel[[:space:]].*NOPASSWD' \ - /etc/sudoers /etc/sudoers.d/* 2>/dev/null \ - | grep -qvE '^[[:space:]]*#' + /etc/sudoers /etc/sudoers.d/* 2>/dev/null | + grep -qvE '^[[:space:]]*#' } _setup_wheel_nopasswd_sudo() { @@ -396,7 +396,7 @@ _setup_wheel_nopasswd_sudo() { return 0 else _info "Enabling NOPASSWD for %wheel in ${sudoers_file}..." - printf '%s\n' '%wheel ALL=(ALL) NOPASSWD: ALL' | _echo_run sudo tee "$sudoers_file" > /dev/null + printf '%s\n' '%wheel ALL=(ALL) NOPASSWD: ALL' | _echo_run sudo tee "$sudoers_file" >/dev/null _echo_run sudo chmod 440 "$sudoers_file" _echo_run sudo visudo -cf "$sudoers_file" || { _error "sudoers validation failed; removing ${sudoers_file}" @@ -454,8 +454,8 @@ _install_cursor_fedora() { 'enabled=1' \ 'gpgcheck=1' \ "gpgkey=${key_url}" \ - 'repo_gpgcheck=1' \ - | _echo_run sudo tee "$repo_file" > /dev/null + 'repo_gpgcheck=1' | + _echo_run sudo tee "$repo_file" >/dev/null fi if rpm -q cursor &>/dev/null; then @@ -480,11 +480,11 @@ _install_cursor_debian() { if [ ! -f "$list_file" ]; then _info "Adding Cursor APT repository..." _echo_run sudo mkdir -p /usr/share/keyrings - _echo_run curl -fsSL https://downloads.cursor.com/keys/anysphere.asc \ - | sudo gpg --dearmor -o "$keyring" + _echo_run curl -fsSL https://downloads.cursor.com/keys/anysphere.asc | + sudo gpg --dearmor -o "$keyring" printf '%s\n' \ - "deb [signed-by=${keyring}] https://downloads.cursor.com/aptrepo stable main" \ - | _echo_run sudo tee "$list_file" > /dev/null + "deb [signed-by=${keyring}] https://downloads.cursor.com/aptrepo stable main" | + _echo_run sudo tee "$list_file" >/dev/null if command -v nala &>/dev/null; then _echo_run sudo nala update else diff --git a/scripts/lib/install.sh b/scripts/lib/install.sh index 48123e0..85d4ac4 100644 --- a/scripts/lib/install.sh +++ b/scripts/lib/install.sh @@ -335,7 +335,7 @@ _pacstrap_base_packages() { _generate_fstab() { _info "Generating fstab..." - _echo_run genfstab -U "$MNT" >> "${MNT}/etc/fstab" || return 1 + _echo_run genfstab -U "$MNT" >>"${MNT}/etc/fstab" || return 1 } _setup_bootstrap() { @@ -461,7 +461,7 @@ _configure_encryption_boot() { printf '%s\t%s\t%s\t%s\n' \ "luks_home" "UUID=${home_part_uuid}" "/etc/luks_keys/home_keyfile.bin" "luks,initramfs" \ - >> "${MNT}/etc/crypttab" + >>"${MNT}/etc/crypttab" return 0 } @@ -731,7 +731,7 @@ _configure_locales() { /etc/locale.gen || return 1 _chroot_run locale-gen || return 1 - cat > "${MNT}/etc/locale.conf" <<'EOF' + cat >"${MNT}/etc/locale.conf" <<'EOF' LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 @@ -756,7 +756,7 @@ EOF _configure_keyboard() { _info "Configuring console keyboard (${KEYMAP})..." - cat > "${MNT}/etc/vconsole.conf" <"${MNT}/etc/vconsole.conf" < "${MNT}/etc/hostname" + printf '%s\n' "$INSTALL_HOSTNAME" >"${MNT}/etc/hostname" } _setup_root_password() { @@ -852,7 +852,7 @@ _setup_root_password() { _enable_wheel_sudo() { _info "Granting sudo access to wheel group..." - printf '%%wheel ALL=(ALL:ALL) ALL\n' > "${MNT}/etc/sudoers.d/wheel" + printf '%%wheel ALL=(ALL:ALL) ALL\n' >"${MNT}/etc/sudoers.d/wheel" _chroot_run chmod 440 /etc/sudoers.d/wheel || return 1 } @@ -968,10 +968,10 @@ _detect_cpu_microcode_package() { vendor=$(arch-chroot "$MNT" lscpu 2>/dev/null | awk -F: '/Vendor ID/ {gsub(/^[ \t]+/, "", $2); print $2; exit}') case $vendor in - *AuthenticAMD*|*AMD*) + *AuthenticAMD* | *AMD*) echo "amd-ucode" ;; - *GenuineIntel*|*Intel*) + *GenuineIntel* | *Intel*) echo "intel-ucode" ;; *) @@ -993,9 +993,18 @@ _prompt_cpu_microcode_package() { read -p "Select microcode package [1-3]: " choice case $choice in - 1) echo "amd-ucode"; return 0 ;; - 2) echo "intel-ucode"; return 0 ;; - 3) echo ""; return 0 ;; + 1) + echo "amd-ucode" + return 0 + ;; + 2) + echo "intel-ucode" + return 0 + ;; + 3) + echo "" + return 0 + ;; *) _error "Invalid choice." ;; esac done @@ -1034,11 +1043,26 @@ _prompt_gpu_packages() { read -p "Select GPU driver set [1-5]: " choice case $choice in - 1) echo "mesa lib32-mesa libva-mesa-driver vulkan-radeon lib32-vulkan-radeon vulkan-mesa-implicit-layers lib32-vulkan-mesa-implicit-layers"; return 0 ;; - 2) echo "mesa lib32-mesa intel-media-driver"; return 0 ;; - 3) echo "nvidia nvidia-utils nvidia-lts"; return 0 ;; - 4) echo "xf86-video-vmware"; return 0 ;; - 5) echo ""; return 0 ;; + 1) + echo "mesa lib32-mesa libva-mesa-driver vulkan-radeon lib32-vulkan-radeon vulkan-mesa-implicit-layers lib32-vulkan-mesa-implicit-layers" + return 0 + ;; + 2) + echo "mesa lib32-mesa intel-media-driver" + return 0 + ;; + 3) + echo "nvidia nvidia-utils nvidia-lts" + return 0 + ;; + 4) + echo "xf86-video-vmware" + return 0 + ;; + 5) + echo "" + return 0 + ;; *) _error "Invalid choice." ;; esac done @@ -1052,7 +1076,7 @@ _configure_reflector() { return 0 fi - cat > "${MNT}/etc/xdg/reflector/reflector.conf" <"${MNT}/etc/xdg/reflector/reflector.conf" < "$tmp" + sed "s|^#dev = .*|dev = ${root_src}|" "$src" >"$tmp" if [ -z "$root_src" ]; then _warn "Could not detect btrfs device for / — edit dev= in /etc/snapper-rollback.conf" fi @@ -262,7 +262,7 @@ main() { _ensure_pacman_multilib _echo_run sudo pacman -Syy _info "Installing paru AUR helper..." - if ! command -v paru &> /dev/null; then + if ! command -v paru &>/dev/null; then _echo_run cd "$HOME" _echo_run git clone https://aur.archlinux.org/paru.git _echo_run cd paru diff --git a/scripts/setup-debian b/scripts/setup-debian index 246db57..8078ca7 100755 --- a/scripts/setup-debian +++ b/scripts/setup-debian @@ -66,11 +66,11 @@ _install_ghostty() { if [ ! -f "$list" ]; then _info "Adding debian.griffo.io repository for ghostty (not in official Debian repos)..." _echo_run sudo mkdir -p /usr/share/keyrings - _echo_run curl -fsSL https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc \ - | sudo gpg --dearmor -o "$keyring" + _echo_run curl -fsSL https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | + sudo gpg --dearmor -o "$keyring" printf '%s\n' \ - "deb [signed-by=${keyring}] https://debian.griffo.io/apt ${codename} main" \ - | _echo_run sudo tee "$list" > /dev/null + "deb [signed-by=${keyring}] https://debian.griffo.io/apt ${codename} main" | + _echo_run sudo tee "$list" >/dev/null _echo_run sudo nala update fi _echo_run sudo nala install -y ghostty @@ -94,11 +94,11 @@ _setup_tailscale() { local keyring="/usr/share/keyrings/tailscale-archive-keyring.gpg" local list="/etc/apt/sources.list.d/tailscale.list" _echo_run sudo mkdir -p --mode=0755 /usr/share/keyrings - _echo_run curl -fsSL "https://pkgs.tailscale.com/stable/debian/${codename}.noarmor.gpg" \ - | sudo tee "$keyring" > /dev/null + _echo_run curl -fsSL "https://pkgs.tailscale.com/stable/debian/${codename}.noarmor.gpg" | + sudo tee "$keyring" >/dev/null _echo_run sudo chmod 0644 "$keyring" - _echo_run curl -fsSL "https://pkgs.tailscale.com/stable/debian/${codename}.tailscale-keyring.list" \ - | sudo tee "$list" > /dev/null + _echo_run curl -fsSL "https://pkgs.tailscale.com/stable/debian/${codename}.tailscale-keyring.list" | + sudo tee "$list" >/dev/null _echo_run sudo chmod 0644 "$list" _echo_run sudo nala update _install_pkg "tailscale" @@ -180,7 +180,7 @@ main() { _install_pip_user_packages "${basic_packages_pip[@]}" _info "Installing pyenv for Python version management..." - if ! command -v pyenv &> /dev/null; then + if ! command -v pyenv &>/dev/null; then _info "Cloning pyenv..." _echo_run git clone https://github.com/pyenv/pyenv.git "$HOME/.pyenv" _info "Building pyenv..." @@ -218,7 +218,7 @@ main() { fi _info "Setting up NordVPN..." - if ! command -v nordvpn &> /dev/null; then + if ! command -v nordvpn &>/dev/null; then _info "Adding NordVPN repository and installing..." _echo_run curl https://repo.nordvpn.com/gpg/nordvpn_public.asc | sudo apt-key add - _echo_run sudo sh -c 'echo "deb https://repo.nordvpn.com/deb/nordvpn/debian stable main" > /etc/apt/sources.list.d/nordvpn.list' diff --git a/scripts/setup-fedora b/scripts/setup-fedora index f1f976d..7e88ca6 100755 --- a/scripts/setup-fedora +++ b/scripts/setup-fedora @@ -29,7 +29,7 @@ _dnf() { } _pkg_is_installed() { - rpm -q "$1" &> /dev/null + rpm -q "$1" &>/dev/null } _install_pkg() { @@ -79,7 +79,7 @@ _install_flatpak_apps() { local apps=("$@") [ ${#apps[@]} -eq 0 ] && return 0 - command -v flatpak &> /dev/null || { + command -v flatpak &>/dev/null || { _warn "flatpak not installed; skipping $category" return 0 } @@ -129,7 +129,7 @@ _setup_firefox_wayland() { _info "Enabling Firefox native Wayland (MOZ_ENABLE_WAYLAND=1)..." _echo_run sudo mkdir -p /etc/environment.d - printf '%s\n' 'MOZ_ENABLE_WAYLAND=1' | _echo_run sudo tee "$conf" > /dev/null + printf '%s\n' 'MOZ_ENABLE_WAYLAND=1' | _echo_run sudo tee "$conf" >/dev/null _info "Log out and back in (or reboot) for Firefox to pick up the change" } @@ -139,7 +139,7 @@ _enable_rpmfusion() { return 0 } - if rpm -q rpmfusion-free-release &> /dev/null && rpm -q rpmfusion-nonfree-release &> /dev/null; then + if rpm -q rpmfusion-free-release &>/dev/null && rpm -q rpmfusion-nonfree-release &>/dev/null; then _info "RPM Fusion already enabled" return 0 fi @@ -168,14 +168,14 @@ _setup_systemd_resolved() { } _setup_nordvpn() { - if command -v nordvpn &> /dev/null; then + if command -v nordvpn &>/dev/null; then _info "NordVPN already installed" return 0 fi _info "Setting up NordVPN..." _echo_run sudo rpm --import https://repo.nordvpn.com/gpg/nordvpn_public.asc - _echo_run sudo tee /etc/yum.repos.d/nordvpn.repo > /dev/null << 'EOF' + _echo_run sudo tee /etc/yum.repos.d/nordvpn.repo >/dev/null <<'EOF' [nordvpn] name=NordVPN baseurl=https://repo.nordvpn.com/yum/nordvpn/centos/$basearch/ @@ -241,9 +241,9 @@ _btrfs_has_snapper_layout() { _btrfs_fstab_needs_mount_opts() { grep -q btrfs /etc/fstab 2>/dev/null || return 1 - grep btrfs /etc/fstab | grep -q 'noatime' \ - && grep btrfs /etc/fstab | grep -q 'discard=async' \ - && grep btrfs /etc/fstab | grep -q 'compress=zstd:1' && return 1 + grep btrfs /etc/fstab | grep -q 'noatime' && + grep btrfs /etc/fstab | grep -q 'discard=async' && + grep btrfs /etc/fstab | grep -q 'compress=zstd:1' && return 1 return 0 } @@ -262,11 +262,11 @@ _setup_btrfs_mount_opts() { if [[ "$line" == *" btrfs "* ]] && [[ "$line" == *"subvol="* ]]; then if [[ "$line" =~ subvol=([^,[:space:]]+) ]]; then subvol="${BASH_REMATCH[1]}" - line=$(sed -E "s/subvol=[^[:space:]]+/subvol=${subvol},${BTRFS_MOUNT_OPTS}/" <<< "$line") + line=$(sed -E "s/subvol=[^[:space:]]+/subvol=${subvol},${BTRFS_MOUNT_OPTS}/" <<<"$line") fi fi printf '%s\n' "$line" - done < /etc/fstab > "$tmp" + done "$tmp" _echo_run sudo cp "$tmp" /etc/fstab rm -f "$tmp" _warn "Reboot recommended to apply btrfs mount options" @@ -503,7 +503,7 @@ _ensure_dracut_resume() { if [ ! -f "$conf" ] || ! grep -q 'resume' "$conf" 2>/dev/null; then _info "Enabling dracut resume module..." _echo_run sudo mkdir -p /etc/dracut.conf.d - printf '%s\n' 'add_dracutmodules+=" resume "' | _echo_run sudo tee "$conf" > /dev/null + printf '%s\n' 'add_dracutmodules+=" resume "' | _echo_run sudo tee "$conf" >/dev/null changed=true else _info "dracut resume module already configured" @@ -705,7 +705,7 @@ main() { _install_packages "rpmfusion nonfree" "${rpmfusion_nonfree_packages[@]}" _install_flatpak_apps "flatpak apps" "${flatpak_apps[@]}" - if command -v steamtinkerlaunch &> /dev/null; then + if command -v steamtinkerlaunch &>/dev/null; then _info "Setting Steam Tinker Launch as a Steam compatibility tool..." _echo_run steamtinkerlaunch compat add else @@ -716,7 +716,7 @@ main() { _install_pkg "python3-pip" _install_pkg "pipx" for tool in "${pip_packages[@]}"; do - command -v "$tool" &> /dev/null && { + command -v "$tool" &>/dev/null && { _info "$tool already available" continue } diff --git a/setup b/setup index ad9da65..5ef7d8b 100755 --- a/setup +++ b/setup @@ -46,8 +46,7 @@ main() { username="$(whoami)" _info "Linux setup script for Arch, Debian, and Fedora" - distro=$(_get_distro "$1") - if [ $? -ne 0 ] || [ -z "$distro" ]; then + if ! distro=$(_get_distro "$1") || [ -z "$distro" ]; then _error "Unknown distribution. Provide 'arch', 'debian', or 'fedora' as an argument." exit 1 fi diff --git a/vars/arch-vars b/vars/arch-vars index 162c986..7c2e280 100755 --- a/vars/arch-vars +++ b/vars/arch-vars @@ -17,7 +17,7 @@ basic_packages=( "git" "just" - "curl" # Needed for various installations + "curl" # Needed for various installations "wget" "sed" "awk" diff --git a/vars/debian-vars b/vars/debian-vars index 190c348..b040c6e 100644 --- a/vars/debian-vars +++ b/vars/debian-vars @@ -24,7 +24,7 @@ apt_tools=( basic_packages=( "git" "just" - "curl" # Needed for various installations + "curl" # Needed for various installations "wget" "sed" "gawk" From 2df9bfdc479426dfd7f513c0888b44d30d2a07dd Mon Sep 17 00:00:00 2001 From: Aapo Kokko Date: Sun, 28 Jun 2026 11:06:07 +0300 Subject: [PATCH 2/2] Fix shellcheck SC2001 --- scripts/lib/common.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index 0bb56f9..de39508 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -188,7 +188,10 @@ _prompt_yes_no() { _to_ssh_url() { local url=$1 - echo "$url" | sed 's|https://github\.com/|git@github.com:|' + case "$url" in + https://github.com/*) echo "git@github.com:${url#https://github.com/}" ;; + *) echo "$url" ;; + esac } _set_ssh_remote() {