Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 02b6ae1

Browse files
committed
feat: add games package support and improve Borg backup script
- Update setup.sh to support -G option for games installation - Enhance home-borgbackup.sh with better error handling and checks - Update default packages to include more dev and games packages - Remove obsolete configs/borg/README.md which it is already handle copy location auto to opt dir and add root permission for script to sudoers file - Change Borg backup timer to 07:00 and improve comments
1 parent 21979ea commit 02b6ae1

File tree

8 files changed

+91
-45
lines changed

8 files changed

+91
-45
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## v0.4.0-alpha
5+
### CHANGES
6+
New setups and improvements.
7+
48
## v0.3.0-alpha
59
### CHANGES
610
New setups and improvements.

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,3 @@ Experimental: Below functions are need to tested with caution.
5858
Example:
5959
sudo $0 -a
6060
```
61-
62-
```
63-
64-
```

configs/borg/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

configs/borg/borgbackup-home.timer

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
Description=Timer for Home Backup using BorgBackup
33

44
[Timer]
5-
# Schedules the backup at 10:00 every day.
6-
OnCalendar=*-*-* 10:00:00
5+
# Schedules the backup at 07:00 every day.
6+
OnCalendar=*-*-* 07:00:00
7+
# Persistence will ensure the timer runs even if the system is down at the scheduled time.
78
Persistent=true
8-
# Note: systemd timers work with local time. To follow Europe/Istanbul time, ensure your system’s timezone is set accordingly.
9+
# Note: systemd timers work with local time.
10+
# ensure your system’s timezone is set accordingly.
911

1012
[Install]
1113
WantedBy=timers.target

configs/borg/home-borgbackup.sh

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
#!/bin/bash -e
2-
# Extract command
3-
# sudo borg extract --progress --list /mnt/backups/borgbackup/doc-repo::doc-27-02-2024
4-
#NOTE: this file need to be on /opt/borg/home-borgbackup.sh
1+
#!/usr/bin/env bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
55

6-
export BORG_UKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
6+
# Check prerequisites
7+
command -v borg >/dev/null 2>&1 || {
8+
echo >&2 "Borg is not installed. Please install it first."
9+
exit 1
10+
}
11+
[[ -d /mnt/backups/borgbackup ]] || {
12+
echo >&2 "Backup directory does not exist."
13+
exit 1
14+
}
715

8-
REPOSITORY_home='/mnt/backups/borgbackup/home-nixos'
16+
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
917

10-
echo "Starting backup"
11-
# home
12-
sudo borg create --list --filter=AME --progress --stats --exclude-caches --show-rc \
18+
borg_home_repo='/mnt/backups/borgbackup/home-repo'
19+
20+
echo "Starting backup for home"
21+
22+
# --show-rc: if return 0 code, then it's successful
23+
if ! sudo borg create --list --filter=AME --progress --stats --exclude-caches --show-rc \
1324
--exclude /home/*/Documents/backup-for-cloud/ \
1425
--exclude /home/*/.cache/ \
1526
--exclude /home/*Downloads/ \
@@ -25,33 +36,38 @@ sudo borg create --list --filter=AME --progress --stats --exclude-caches --show-
2536
--exclude /home/*/.tox/ \
2637
--exclude /home/*/.venv/ \
2738
--exclude /home/*/.backups/ \
28-
--compression zstd,15 $REPOSITORY_home::'{now:home-developer-%d-%m-%Y}' \
29-
/home/developer/
39+
--compression zstd,15 $borg_home_repo::'{now:home-developer-%d-%m-%Y}' \
40+
/home/developer/; then
41+
echo "Backup of home directory failed" >&2
42+
exit 1
43+
fi
3044

3145
echo "Backup of home directory complete"
3246

33-
echo "Pruning old home backups"
34-
35-
# --show-rc: if return 0 code, then it's successful
36-
sudo borg prune -v $REPOSITORY_home --list --stats --show-rc \
47+
if ! sudo borg prune -v $borg_home_repo --list --stats --show-rc \
3748
--keep-daily=7 \
3849
--keep-weekly=4 \
39-
--keep-monthly=2
50+
--keep-monthly=2; then
51+
echo "Pruning of home backups failed" >&2
52+
exit 1
53+
fi
54+
55+
echo "Pruning of home backups complete"
4056

41-
sudo borg check $REPOSITORY_home
42-
# after check
43-
echo "Check complete"
57+
if ! sudo borg check $borg_home_repo; then
58+
echo "Check of home backups failed" >&2
59+
exit 1
60+
fi
61+
echo "borg check completed successfully"
4462

45-
# compact the repository to free up the space
46-
sudo borg compact $REPOSITORY_home
63+
if ! sudo borg compact $borg_home_repo; then
64+
echo "Compaction of home backups failed" >&2
65+
exit 1
66+
fi
4767

4868
echo "Compaction complete"
49-
# make sure to sync
69+
70+
# Being paronoid here
5071
sync
5172

52-
# if return = 'rc 0' then it's successful
53-
if [ $? -eq 0 ]; then
54-
echo "Backup and prune complete!"
55-
else
56-
echo "Backup and prune failed!"
57-
fi
73+
echo "Borg backup completed successfully"

setup.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ needs_dnf_speedup() {
124124
$install_system_specific_packages_option ||
125125
$install_app_packages_option ||
126126
$install_dev_packages_option ||
127+
$install_games_packages_option ||
127128
$librewolf_option ||
128129
$qtile_option ||
129130
$brave_option ||
@@ -226,6 +227,16 @@ install_dev_packages() {
226227
log_info "Development packages installation completed."
227228
}
228229

230+
install_games_packages() {
231+
log_info "Installing games..."
232+
if ! sudo dnf install -y "${GAMES_PACKAGES[@]}"; then
233+
log_error "Error: Failed to install games." >&2
234+
return 1
235+
fi
236+
237+
log_info "Games installation completed."
238+
}
239+
229240
install_flatpak_packages() {
230241
log_info "Installing Flatpak packages..."
231242

@@ -358,6 +369,7 @@ main() {
358369
install_system_specific_packages_option=false
359370
install_app_packages_option=false
360371
install_dev_packages_option=false
372+
install_games_packages_option=false
361373
flatpak_option=false
362374
librewolf_option=false
363375
qtile_option=false
@@ -395,11 +407,12 @@ main() {
395407
nfancurve_option=false
396408

397409
# Process command-line options.
398-
while getopts "abBcdDEFfghHIiAalLjnNopPrstTuUvVzqQxCMSX" opt; do
410+
while getopts "abBcdDEFfGghHIiAalLjnNopPrstTuUvVzqQxCMSX" opt; do
399411
case $opt in
400412
a) all_option=true ;;
401413
A) install_app_packages_option=true ;;
402414
D) install_dev_packages_option=true ;;
415+
G) install_games_packages_option=true ;;
403416
b) brave_option=true ;;
404417
B) borgbackup_option=true ;;
405418
c) touchpad_option=true ;;
@@ -446,6 +459,7 @@ main() {
446459
[[ "$install_system_specific_packages_option" == "false" ]] &&
447460
[[ "$install_app_packages_option" == "false" ]] &&
448461
[[ "$install_dev_packages_option" == "false" ]] &&
462+
[[ "$install_games_packages_option" == "false" ]] &&
449463
[[ "$flatpak_option" == "false" ]] &&
450464
[[ "$borgbackup_option" == "false" ]] &&
451465
[[ "$touchpad_option" == "false" ]] &&
@@ -521,6 +535,7 @@ main() {
521535
install_core_packages
522536
install_app_packages
523537
install_dev_packages
538+
install_games_packages
524539
install_system_specific_packages "$system_type"
525540

526541
# System-specific additional functions.
@@ -569,6 +584,7 @@ main() {
569584
if $install_core_packages_option; then install_core_packages; fi
570585
if $install_app_packages_option; then install_app_packages; fi
571586
if $install_dev_packages_option; then install_dev_packages; fi
587+
if $install_games_packages_option; then install_games_packages; fi
572588
if $install_system_specific_packages_option; then install_system_specific_packages "$system_type"; fi
573589
if $touchpad_option; then touchpad_setup; fi
574590
if $flatpak_option; then install_flatpak_packages; fi

src/config.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,21 @@ create_default_packages_json() {
348348
"neovim",
349349
"vim",
350350
"pavucontrol",
351-
"chromium"
351+
"chromium",
352+
"gimp",
352353
],
353354
"dev": [
355+
"gparted",
356+
"kernel-tools",
357+
"kdiskmark",
358+
"gitleaks",
359+
"stow",
354360
"clamav",
361+
"freshclam",
355362
"libsecret",
356363
"libsecret-devel",
364+
"gnome-screenshot",
365+
"openssh-askpass",
357366
"papirus-icon-theme",
358367
"git-credential-libsecret",
359368
"gh",
@@ -417,9 +426,12 @@ create_default_packages_json() {
417426
"xev"
418427
],
419428
"games": [
420-
"wine",
421-
"wine-mono",
422-
"lutris",
429+
"wine",
430+
"wine-mono",
431+
"winetricks",
432+
"lutris",
433+
"steam",
434+
"heroic-games-launcher-bin"
423435
],
424436
"flatpak": [
425437
"org.signal.Signal",
@@ -964,6 +976,7 @@ load_package_arrays() {
964976
CORE_PACKAGES=($(parse_json "$packages_file" ".core[]"))
965977
APPS_PACKAGES=($(parse_json "$packages_file" ".apps[]"))
966978
DEV_PACKAGES=($(parse_json "$packages_file" ".dev[]"))
979+
GAMES_PACKAGES=($(parse_json "$packages_file" ".games[]"))
967980
DESKTOP_PACKAGES=($(parse_json "$packages_file" ".desktop[]"))
968981
LAPTOP_PACKAGES=($(parse_json "$packages_file" ".laptop[]"))
969982
QTILE_PACKAGES=($(parse_json "$packages_file" ".qtile[]"))
@@ -1083,6 +1096,7 @@ init_config() {
10831096
log_info "Qtile Packages: ${#QTILE_PACKAGES[@]} packages"
10841097
log_info "Flatpak Packages: ${#FLATPAK_PACKAGES[@]} packages"
10851098
log_info "Development Packages: ${#DEV_PACKAGES[@]} packages"
1099+
log_info "Games Packages: ${#GAMES_PACKAGES[@]} packages"
10861100
log_info "Desktop Packages: ${#DESKTOP_PACKAGES[@]} packages"
10871101
log_info "Laptop Packages: ${#LAPTOP_PACKAGES[@]} packages"
10881102
log_info "===== End of Summary ====="

tests/test_config.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,12 @@ load_package_arrays() {
264264
DEV_PACKAGES=("dev1" "dev2")
265265
DESKTOP_PACKAGES=("desktop1" "desktop2")
266266
LAPTOP_PACKAGES=("laptop1" "laptop2")
267+
GAMES_PACKAGES=("game1" "game2")
267268
QTILE_PACKAGES=("feh" "picom" "i3lock")
268269
FLATPAK_PACKAGES=("app1" "app2")
269270
270271
# Export arrays
271-
export CORE_PACKAGES APPS_PACKAGES DEV_PACKAGES
272+
export CORE_PACKAGES APPS_PACKAGES DEV_PACKAGES GAMES_PACKAGES
272273
export DESKTOP_PACKAGES LAPTOP_PACKAGES
273274
export QTILE_PACKAGES FLATPAK_PACKAGES
274275
@@ -518,6 +519,7 @@ run_config_function() {
518519
grep -q '"browser"' "$test_file"
519520
grep -q '"system"' "$test_file"
520521
}
522+
521523
# Test load_json_config with existing file
522524
@test "load_json_config returns path for existing file" {
523525
# Create a config dir and file directly in the test directory

0 commit comments

Comments
 (0)