add update.sh: OS detection + package list update
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 41s

- New update.sh: detects Alpine, Arch, Debian/Ubuntu, RHEL/Fedora/CentOS,
  openSUSE, Void, Gentoo and updates the package index only (no upgrades)
- clean.sh fixes:
  - Fix ((cleaned_count++)) exiting under set -e on first successful rm
  - Stop recursively deleting /var/cache and /root/.cache wholesale
  - Add CACHE_RETENTION_DAYS (7d) — clean_directory now only deletes
    files older than retention period instead of wiping everything
  - Remove dangerous rm -rf fallback in clean_directory
  - Narrow CACHE_DIRS to /var/cache/apt instead of /var/cache
  - Fix /home/*/.cache pattern to only target pip/npm caches
This commit is contained in:
2026-06-25 19:42:51 -03:00
parent 2f2ad759c1
commit 2ce71f4fc1
3 changed files with 317 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
# server-scripts
Useful scripts for managing servers written in Bash. Supported OS includes only Ubuntu/Debian and Alpine.
Useful scripts for managing servers written in Bash. Supported OS includes Debian/Ubuntu, Alpine, Arch, RHEL/Fedora/CentOS, openSUSE, Void, and Gentoo.
In the past I was using it more for maintaining my home servers, bare metal with Docker, however when I changed to k3s, I started using it less. Now I'm using this as a collection of useful scripts that I can use when needed. Also `clean.sh` is still useful.
@@ -8,6 +8,16 @@ In the past I was using it more for maintaining my home servers, bare metal with
This script is used to clean some of the files, docker dangling images, and docker stopped/unused containers.
### `update.sh`
Detects the running OS (Alpine, Arch, Debian/Ubuntu, RHEL/Fedora/CentOS, openSUSE, Void, Gentoo) and updates the **package list** only — it does not upgrade or install any packages. Useful for keeping package indexes fresh so that `upgrade` commands run faster later.
Run with `curl | bash`:
```bash
curl -sSL https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/update.sh | bash
```
### `windows-backup.ps1`
This PowerShell script is used to backup files from a Windows machine to a remote Samba server. It uses `7zip` to create the zip file, and then sends over the network using SMB protocol.