small things
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user