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