Compare commits
2 Commits
7b46d789ed
...
9639c90799
| Author | SHA1 | Date | |
|---|---|---|---|
| 9639c90799 | |||
| d5fb0b7df6 |
22
README.md
22
README.md
@@ -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.
|
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`:
|
Run with `curl | bash`:
|
||||||
|
|
||||||
```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`
|
### `windows-backup.ps1`
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: haven-notify
|
|
||||||
labels:
|
|
||||||
app: haven-notify
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: haven-notify
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: haven-notify
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: haven-notify
|
|
||||||
image: git.ivanch.me/ivanch/haven-notify:latest
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
env:
|
|
||||||
- name: WEBHOOK_URL
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: discord-webhook
|
|
||||||
key: HAVEN_WEBHOOK_URL
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /ready
|
|
||||||
port: 8080
|
|
||||||
initialDelaySeconds: 5
|
|
||||||
periodSeconds: 10
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /live
|
|
||||||
port: 8080
|
|
||||||
initialDelaySeconds: 5
|
|
||||||
periodSeconds: 10
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: haven-notify
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: haven-notify
|
|
||||||
ports:
|
|
||||||
- protocol: TCP
|
|
||||||
port: 8080
|
|
||||||
targetPort: 8080
|
|
||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
name: haven-notify
|
|
||||||
namespace: default
|
|
||||||
spec:
|
|
||||||
ingressClassName: nginx
|
|
||||||
rules:
|
|
||||||
- host: notify.haven
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- path: /
|
|
||||||
pathType: Prefix
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: haven-notify
|
|
||||||
port:
|
|
||||||
number: 8080
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
# Housekeeping Script
|
# Housekeeping Script
|
||||||
# Unified system maintenance: package index update, system cleanup, and oh-my-zsh update.
|
# 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
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -109,9 +108,9 @@ get_system_info() {
|
|||||||
|
|
||||||
# Memory info
|
# Memory info
|
||||||
if [[ -f /proc/meminfo ]]; then
|
if [[ -f /proc/meminfo ]]; then
|
||||||
local mem_total mem_available
|
local mem_total="" mem_available=""
|
||||||
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
mem_total=$(awk '/^MemTotal:/ {print $2; exit}' /proc/meminfo 2>/dev/null || true)
|
||||||
mem_available=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
mem_available=$(awk '/^MemAvailable:/ {print $2; exit}' /proc/meminfo 2>/dev/null || true)
|
||||||
if [[ -n "$mem_total" && -n "$mem_available" ]]; then
|
if [[ -n "$mem_total" && -n "$mem_available" ]]; then
|
||||||
info+="Memory: $((mem_available/1024))MB available of $((mem_total/1024))MB total"
|
info+="Memory: $((mem_available/1024))MB available of $((mem_total/1024))MB total"
|
||||||
fi
|
fi
|
||||||
@@ -120,7 +119,7 @@ get_system_info() {
|
|||||||
# Disk space info
|
# Disk space info
|
||||||
if command_exists df; then
|
if command_exists df; then
|
||||||
local disk_info
|
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
|
if [[ -n "$disk_info" ]]; then
|
||||||
info+="${info:+, }Disk: $disk_info"
|
info+="${info:+, }Disk: $disk_info"
|
||||||
fi
|
fi
|
||||||
@@ -495,7 +494,6 @@ cleanup_logs() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Truncate large active log files
|
# Truncate large active log files
|
||||||
local large_logs
|
|
||||||
while IFS= read -r -d '' logfile; do
|
while IFS= read -r -d '' logfile; do
|
||||||
if [[ -f "$logfile" && -w "$logfile" ]]; then
|
if [[ -f "$logfile" && -w "$logfile" ]]; then
|
||||||
truncate -s 0 "$logfile" 2>/dev/null || true
|
truncate -s 0 "$logfile" 2>/dev/null || true
|
||||||
@@ -774,7 +772,7 @@ main() {
|
|||||||
log_warning "Unknown subcommand: '${subcommand}'"
|
log_warning "Unknown subcommand: '${subcommand}'"
|
||||||
echo
|
echo
|
||||||
print_usage
|
print_usage
|
||||||
exit 0
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user