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 ln -sf "${HOME}/nextcloud/Documents" "${HOME}/documents" 41 ln -sf "${HOME}/nextcloud/Pictures" "${HOME}/pictures" 42 xdg-user-dirs-update 43 44# Setup borgmatic config 45[group('setup')] 46setup-borgmatic-config: 47 #!/usr/bin/env bash 48 sudo mkdir /etc/borgmatic 49 sudo wget https://tildegit.org/hyperreal/borgmatic-configs/raw/branch/main/desktop/config.yaml -O /etc/borgmatic/config.yaml 50 sudo systemd-ask-password -n | sudo systemd-creds encrypt - /etc/credstore.encrypted/borgmatic.pw 51 52# Setup git repos locally 53[group('setup')] 54setup-repos: 55 #!/usr/bin/env bash 56 set -euo pipefail 57 58 if [ ! -f "${HOME}/.ssh/id_ed25519" ]; then 59 echo "SSH key not found. Please ensure your SSH key is available." 60 exit 1 61 fi 62 63 echo "Preparing local git directories..." 64 mkdir -p "${HOME}/repos/tildegit.org/hyperreal" 65 66 echo "Cloning repos from tildegit.org/hyperreal..." 67 hyperreal_repos=( 68 "ansible-homelab" 69 "dotfiles" 70 "hyperreal.coffee" 71 "podman-services" 72 "qbt-helper" 73 ) 74 for repo in "${hyperreal_repos[@]}"; do 75 if [ -d "${HOME}/repos/tildegit.org/hyperreal/${repo}" ]; then 76 rm -rf "${HOME}/repos/tildegit.org/hyperreal/${repo}" 77 fi 78 git clone "git@tildegit.org:hyperreal/${repo}.git" "${HOME}/repos/tildegit.org/hyperreal/${repo}" 79 done 80 81# Setup hyperreal configs 82[group('setup')] 83setup-cli: 84 #!/usr/bin/env bash 85 set -euo pipefail 86 87 DOTFILES_DIR="${HOME}/repos/tildegit.org/hyperreal/dotfiles" 88 if [ ! -d "$DOTFILES_DIR" ]; then 89 echo "${DOTFILES_DIR} not found." 90 exit 1 91 fi 92 93 find "${DOTFILES_DIR}/config" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}/.config" \; 94 find "${DOTFILES_DIR}/todo" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}" \; 95 find "${DOTFILES_DIR}/zsh" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}" \; 96 97# vim: ts=4 sts=4 sw=4 et ft=just