small things

This commit is contained in:
2026-07-13 09:34:57 -03:00
parent 7b46d789ed
commit d5fb0b7df6
2 changed files with 21 additions and 13 deletions

View File

@@ -2,20 +2,30 @@
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.
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 `housekeeping.sh` is still useful.
### `clean.sh`
### `housekeeping.sh`
This script is used to clean some of the files, docker dangling images, and docker stopped/unused containers.
Unified system housekeeping script for package index updates, system cleanup, and oh-my-zsh updates.
### `update.sh`
Subcommands:
- `update` - detects the running OS and updates the package index only. It does not upgrade or install packages.
- `clean` - runs system cleanup for Docker resources, package manager caches, temporary/cache/log directories, systemd journal, thumbnails, and memory caches.
- `omz` - updates oh-my-zsh when `omz` is installed; otherwise it skips safely.
- `all` - runs `update`, then `clean`, then `omz`. This is the default when no subcommand is provided.
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.
The `update` subcommand supports Alpine, Arch, Debian/Ubuntu, RHEL/Fedora/CentOS, openSUSE, Void, and Gentoo family distributions.
Run with `curl | bash`:
```bash
curl -sSL https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/update.sh | bash
curl -sSL https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/housekeeping.sh | bash
```
Run a specific subcommand:
```bash
curl -sSL https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/housekeeping.sh | bash -s -- clean
```
### `windows-backup.ps1`

View File

@@ -2,7 +2,6 @@
# Housekeeping Script
# Unified system maintenance: package index update, system cleanup, and oh-my-zsh update.
# Combines the former update.sh and clean.sh into a single script with subcommand dispatch.
set -euo pipefail
@@ -109,9 +108,9 @@ get_system_info() {
# Memory info
if [[ -f /proc/meminfo ]]; then
local mem_total mem_available
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
mem_available=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
local mem_total="" mem_available=""
mem_total=$(awk '/^MemTotal:/ {print $2; exit}' /proc/meminfo 2>/dev/null || true)
mem_available=$(awk '/^MemAvailable:/ {print $2; exit}' /proc/meminfo 2>/dev/null || true)
if [[ -n "$mem_total" && -n "$mem_available" ]]; then
info+="Memory: $((mem_available/1024))MB available of $((mem_total/1024))MB total"
fi
@@ -120,7 +119,7 @@ get_system_info() {
# Disk space info
if command_exists df; then
local disk_info
disk_info=$(df -h / 2>/dev/null | tail -1 | awk '{print $4 " available of " $2 " total"}')
disk_info=$(df -h / 2>/dev/null | awk 'NR == 2 {print $4 " available of " $2 " total"}' || true)
if [[ -n "$disk_info" ]]; then
info+="${info:+, }Disk: $disk_info"
fi
@@ -495,7 +494,6 @@ cleanup_logs() {
fi
# Truncate large active log files
local large_logs
while IFS= read -r -d '' logfile; do
if [[ -f "$logfile" && -w "$logfile" ]]; then
truncate -s 0 "$logfile" 2>/dev/null || true
@@ -774,7 +772,7 @@ main() {
log_warning "Unknown subcommand: '${subcommand}'"
echo
print_usage
exit 0
exit 1
;;
esac
}