justfiles for automating various tasks on my workstation
1# Setup systemd services 2[group('setup')] 3setup-services: 4 #!/usr/bin/env bash 5 services=( 6 "atop.service" 7 "atopacct.service" 8 "atop-rotate.timer" 9 "firewalld.service" 10 "prometheus-node-exporter.service" 11 "snapper-cleanup.timer" 12 "snapper-timeline.timer" 13 "tailscaled.service" 14 ) 15 for svc in "${services[@]}"; do 16 if ! sudo systemctl is-active --quiet "$svc"; then 17 sudo systemctl enable --now "$svc" 18 fi 19 done 20 21# Setup XDG user dirs 22[group('setup')] 23setup-xdg-user-dirs: 24 #!/usr/bin/env bash 25 cat <<EOF | sudo tee /etc/xdg/user-dirs.defaults 26 DESKTOP=desktop 27 DOWNLOAD=downloads 28 TEMPLATES=templates 29 PUBLICSHARE=nextcloud 30 DOCUMENTS=documents 31 MUSIC= 32 PICTURES=pictures 33 VIDEOS= 34 EOF 35 36 rm -fv "${HOME}/.config/user-dirs.dirs" 37 for dir in "Desktop" "Documents" "Downloads" "Music" "Pictures" "Public" "Templates" "Videos"; do 38 rm -rfv "${HOME}/${dir}" 39 done 40 xdg-user-dirs-update 41 42# Setup borgmatic config 43[group('setup')] 44setup-borgmatic-config: 45 #!/usr/bin/env bash 46 sudo mkdir /etc/borgmatic 47 sudo wget https://tildegit.org/hyperreal/borgmatic-configs/raw/branch/main/desktop/config.yaml -O /etc/borgmatic/config.yaml 48 sudo systemd-ask-password -n | sudo systemd-creds encrypt - /etc/credstore.encrypted/borgmatic.pw 49 50# Setup git repos locally 51[group('setup')] 52setup-repos: 53 #!/usr/bin/env bash 54 set -euo pipefail 55 56 if [ ! -f "${HOME}/.ssh/id_ed25519" ]; then 57 echo "SSH key not found. Please ensure your SSH key is available." 58 exit 1 59 fi 60 61 echo "Preparing local git directories..." 62 mkdir -p "${HOME}/repos/tildegit.org/hyperreal" 63 64 echo "Cloning repos from tildegit.org/hyperreal..." 65 hyperreal_repos=( 66 "ansible-homelab" 67 "dotfiles" 68 "hyperreal.coffee" 69 "podman-services" 70 "qbt-helper" 71 ) 72 for repo in "${hyperreal_repos[@]}"; do 73 if [ -d "${HOME}/repos/tildegit.org/hyperreal/${repo}" ]; then 74 rm -rf "${HOME}/repos/tildegit.org/hyperreal/${repo}" 75 fi 76 git clone "git@tildegit.org:hyperreal/${repo}.git" "${HOME}/repos/tildegit.org/hyperreal/${repo}" 77 done 78 79# Setup hyperreal configs 80[group('setup')] 81setup-cli: 82 #!/usr/bin/env bash 83 set -euo pipefail 84 85 DOTFILES_DIR="${HOME}/repos/tildegit.org/hyperreal/dotfiles" 86 if [ ! -d "$DOTFILES_DIR" ]; then 87 echo "${DOTFILES_DIR} not found." 88 exit 1 89 fi 90 91 find "${DOTFILES_DIR}/config" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}/.config" \; 92 find "${DOTFILES_DIR}/todo" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}" \; 93 find "${DOTFILES_DIR}/zsh" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}" \; 94 95# vim: ts=4 sts=4 sw=4 et ft=just