Expand cleanup_lxc to support more distros

The cleanup_lxc function now supports package manager cleanup for Fedora, Rocky, AlmaLinux, CentOS (dnf/yum), openSUSE (zypper), and Gentoo (emerge), in addition to Alpine and Debian/Ubuntu. All package manager and language tool cleanup commands now suppress error output for robustness. JSON files were reformatted for consistent indentation.
This commit is contained in:
CanbiZ 2025-12-04 14:55:00 +01:00
parent 3971eb49c7
commit 8aecfce5a3
12 changed files with 411 additions and 371 deletions

View File

@ -1,33 +1,35 @@
{ {
"name": "AlmaLinux", "name": "AlmaLinux",
"slug": "almalinux", "slug": "almalinux",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://wiki.almalinux.org/", "privileged": false,
"website": "https://almalinux.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/almalinux.webp", "documentation": "https://wiki.almalinux.org/",
"config_path": "", "website": "https://almalinux.org/",
"description": "AlmaLinux is an open-source, community-driven Linux distribution, 1:1 binary compatible with RHEL. A free alternative to CentOS.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/almalinux.webp",
"install_methods": [ "config_path": "",
{ "description": "AlmaLinux is an open-source, community-driven Linux distribution, 1:1 binary compatible with RHEL. A free alternative to CentOS.",
"type": "default", "install_methods": [
"script": "ct/almalinux.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/almalinux.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "almalinux", "ram": 512,
"version": "10" "hdd": 4,
} "os": "almalinux",
} "version": "10"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "Alpine Linux", "name": "Alpine Linux",
"slug": "alpine", "slug": "alpine",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://wiki.alpinelinux.org/", "privileged": false,
"website": "https://alpinelinux.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/alpine-linux.webp", "documentation": "https://wiki.alpinelinux.org/",
"config_path": "", "website": "https://alpinelinux.org/",
"description": "Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox. Perfect for containers due to its minimal footprint.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/alpine-linux.webp",
"install_methods": [ "config_path": "",
{ "description": "Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox. Perfect for containers due to its minimal footprint.",
"type": "default", "install_methods": [
"script": "ct/alpine.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/alpine.sh",
"ram": 512, "resources": {
"hdd": 1, "cpu": 1,
"os": "alpine", "ram": 512,
"version": "3.22" "hdd": 1,
} "os": "alpine",
} "version": "3.22"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,38 +1,40 @@
{ {
"name": "CentOS Stream", "name": "CentOS Stream",
"slug": "centos", "slug": "centos",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://docs.centos.org/", "privileged": false,
"website": "https://www.centos.org/centos-stream/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/centos.webp", "documentation": "https://docs.centos.org/",
"config_path": "", "website": "https://www.centos.org/centos-stream/",
"description": "CentOS Stream is a continuously delivered Linux distribution that tracks just ahead of RHEL development. The upstream for the next RHEL release.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/centos.webp",
"install_methods": [ "config_path": "",
{ "description": "CentOS Stream is a continuously delivered Linux distribution that tracks just ahead of RHEL development. The upstream for the next RHEL release.",
"type": "default", "install_methods": [
"script": "ct/centos.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/centos.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "centos", "ram": 512,
"version": "9" "hdd": 4,
} "os": "centos",
} "version": "9"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [ "password": null
{ },
"text": "CentOS Stream is the upstream development platform for RHEL.", "notes": [
"type": "info" {
} "text": "CentOS Stream is the upstream development platform for RHEL.",
] "type": "info"
}
]
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "Debian", "name": "Debian",
"slug": "debian", "slug": "debian",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://www.debian.org/doc/", "privileged": false,
"website": "https://www.debian.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/debian.webp", "documentation": "https://www.debian.org/doc/",
"config_path": "", "website": "https://www.debian.org/",
"description": "Debian is a free operating system (OS) that comes with over 59000 packages. It's known for its stability, security, and extensive software repository.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/debian.webp",
"install_methods": [ "config_path": "",
{ "description": "Debian is a free operating system (OS) that comes with over 59000 packages. It's known for its stability, security, and extensive software repository.",
"type": "default", "install_methods": [
"script": "ct/debian.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/debian.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "debian", "ram": 512,
"version": "13" "hdd": 4,
} "os": "debian",
} "version": "13"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,38 +1,40 @@
{ {
"name": "Devuan", "name": "Devuan",
"slug": "devuan", "slug": "devuan",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://www.devuan.org/os/documentation", "privileged": false,
"website": "https://www.devuan.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/devuan.webp", "documentation": "https://www.devuan.org/os/documentation",
"config_path": "", "website": "https://www.devuan.org/",
"description": "Devuan is a fork of Debian without systemd. It uses sysvinit and other alternative init systems, providing freedom of choice.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/devuan.webp",
"install_methods": [ "config_path": "",
{ "description": "Devuan is a fork of Debian without systemd. It uses sysvinit and other alternative init systems, providing freedom of choice.",
"type": "default", "install_methods": [
"script": "ct/devuan.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/devuan.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "devuan", "ram": 512,
"version": "5.0" "hdd": 4,
} "os": "devuan",
} "version": "5.0"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [ "password": null
{ },
"text": "Devuan uses sysvinit instead of systemd.", "notes": [
"type": "info" {
} "text": "Devuan uses sysvinit instead of systemd.",
] "type": "info"
}
]
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "Fedora", "name": "Fedora",
"slug": "fedora", "slug": "fedora",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://docs.fedoraproject.org/", "privileged": false,
"website": "https://fedoraproject.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/fedora.webp", "documentation": "https://docs.fedoraproject.org/",
"config_path": "", "website": "https://fedoraproject.org/",
"description": "Fedora is a cutting-edge Linux distribution sponsored by Red Hat. It features the latest software and technologies while maintaining stability.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/fedora.webp",
"install_methods": [ "config_path": "",
{ "description": "Fedora is a cutting-edge Linux distribution sponsored by Red Hat. It features the latest software and technologies while maintaining stability.",
"type": "default", "install_methods": [
"script": "ct/fedora.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/fedora.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "fedora", "ram": 512,
"version": "42" "hdd": 4,
} "os": "fedora",
} "version": "42"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,38 +1,40 @@
{ {
"name": "Gentoo", "name": "Gentoo",
"slug": "gentoo", "slug": "gentoo",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://wiki.gentoo.org/", "privileged": false,
"website": "https://www.gentoo.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/gentoo.webp", "documentation": "https://wiki.gentoo.org/",
"config_path": "", "website": "https://www.gentoo.org/",
"description": "Gentoo is a highly customizable source-based Linux distribution. Users compile software optimized for their specific hardware.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/gentoo.webp",
"install_methods": [ "config_path": "",
{ "description": "Gentoo is a highly customizable source-based Linux distribution. Users compile software optimized for their specific hardware.",
"type": "default", "install_methods": [
"script": "ct/gentoo.sh", {
"resources": { "type": "default",
"cpu": 2, "script": "ct/gentoo.sh",
"ram": 1024, "resources": {
"hdd": 8, "cpu": 2,
"os": "gentoo", "ram": 1024,
"version": "current" "hdd": 8,
} "os": "gentoo",
} "version": "current"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [ "password": null
{ },
"text": "Gentoo compiles packages from source. Initial setup may take time.", "notes": [
"type": "warning" {
} "text": "Gentoo compiles packages from source. Initial setup may take time.",
] "type": "warning"
}
]
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "openEuler", "name": "openEuler",
"slug": "openeuler", "slug": "openeuler",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://docs.openeuler.org/", "privileged": false,
"website": "https://www.openeuler.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/openeuler.webp", "documentation": "https://docs.openeuler.org/",
"config_path": "", "website": "https://www.openeuler.org/",
"description": "openEuler is an open-source Linux distribution from Huawei. It's designed for servers and cloud computing with enterprise-grade features.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/openeuler.webp",
"install_methods": [ "config_path": "",
{ "description": "openEuler is an open-source Linux distribution from Huawei. It's designed for servers and cloud computing with enterprise-grade features.",
"type": "default", "install_methods": [
"script": "ct/openeuler.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/openeuler.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "openeuler", "ram": 512,
"version": "25.03" "hdd": 4,
} "os": "openeuler",
} "version": "25.03"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "openSUSE", "name": "openSUSE",
"slug": "opensuse", "slug": "opensuse",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://doc.opensuse.org/", "privileged": false,
"website": "https://www.opensuse.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/opensuse.webp", "documentation": "https://doc.opensuse.org/",
"config_path": "", "website": "https://www.opensuse.org/",
"description": "openSUSE is a stable, easy-to-use, and complete Linux distribution. Known for its YaST configuration tool and zypper package manager.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/opensuse.webp",
"install_methods": [ "config_path": "",
{ "description": "openSUSE is a stable, easy-to-use, and complete Linux distribution. Known for its YaST configuration tool and zypper package manager.",
"type": "default", "install_methods": [
"script": "ct/opensuse.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/opensuse.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "opensuse", "ram": 512,
"version": "15.6" "hdd": 4,
} "os": "opensuse",
} "version": "15.6"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "Rocky Linux", "name": "Rocky Linux",
"slug": "rockylinux", "slug": "rockylinux",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://docs.rockylinux.org/", "privileged": false,
"website": "https://rockylinux.org/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/rocky-linux.webp", "documentation": "https://docs.rockylinux.org/",
"config_path": "", "website": "https://rockylinux.org/",
"description": "Rocky Linux is an enterprise-grade Linux distribution designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux (RHEL).", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/rocky-linux.webp",
"install_methods": [ "config_path": "",
{ "description": "Rocky Linux is an enterprise-grade Linux distribution designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux (RHEL).",
"type": "default", "install_methods": [
"script": "ct/rockylinux.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/rockylinux.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "rockylinux", "ram": 512,
"version": "10" "hdd": 4,
} "os": "rockylinux",
} "version": "10"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -1,33 +1,35 @@
{ {
"name": "Ubuntu", "name": "Ubuntu",
"slug": "ubuntu", "slug": "ubuntu",
"categories": [0], "categories": [
"date_created": "2025-12-04", 0
"type": "ct", ],
"updateable": true, "date_created": "2025-12-04",
"privileged": false, "type": "ct",
"interface_port": null, "updateable": true,
"documentation": "https://help.ubuntu.com/", "privileged": false,
"website": "https://ubuntu.com/", "interface_port": null,
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/ubuntu.webp", "documentation": "https://help.ubuntu.com/",
"config_path": "", "website": "https://ubuntu.com/",
"description": "Ubuntu is a popular Linux distribution based on Debian. Known for its ease of use and regular release cycle with LTS versions.", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/ubuntu.webp",
"install_methods": [ "config_path": "",
{ "description": "Ubuntu is a popular Linux distribution based on Debian. Known for its ease of use and regular release cycle with LTS versions.",
"type": "default", "install_methods": [
"script": "ct/ubuntu.sh", {
"resources": { "type": "default",
"cpu": 1, "script": "ct/ubuntu.sh",
"ram": 512, "resources": {
"hdd": 4, "cpu": 1,
"os": "ubuntu", "ram": 512,
"version": "24.04" "hdd": 4,
} "os": "ubuntu",
} "version": "24.04"
], }
"default_credentials": { }
"username": "root", ],
"password": null "default_credentials": {
}, "username": "root",
"notes": [] "password": null
},
"notes": []
} }

View File

@ -787,7 +787,8 @@ is_verbose_mode() {
# cleanup_lxc() # cleanup_lxc()
# #
# - Comprehensive cleanup of package managers, caches, and logs # - Comprehensive cleanup of package managers, caches, and logs
# - Supports Alpine (apk), Debian/Ubuntu (apt), and language package managers # - Supports Alpine (apk), Debian/Ubuntu (apt), Fedora/Rocky/CentOS (dnf/yum),
# openSUSE (zypper), Gentoo (emerge), and language package managers
# - Cleans: Python (pip/uv), Node.js (npm/yarn/pnpm), Go, Rust, Ruby, PHP # - Cleans: Python (pip/uv), Node.js (npm/yarn/pnpm), Go, Rust, Ruby, PHP
# - Truncates log files and vacuums systemd journal # - Truncates log files and vacuums systemd journal
# - Run at end of container creation to minimize disk usage # - Run at end of container creation to minimize disk usage
@ -795,13 +796,30 @@ is_verbose_mode() {
cleanup_lxc() { cleanup_lxc() {
msg_info "Cleaning up" msg_info "Cleaning up"
# OS-specific package manager cleanup
if is_alpine; then if is_alpine; then
$STD apk cache clean || true $STD apk cache clean 2>/dev/null || true
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
else elif command -v apt &>/dev/null; then
$STD apt -y autoremove || true # Debian/Ubuntu/Devuan
$STD apt -y autoclean || true $STD apt -y autoremove 2>/dev/null || true
$STD apt -y clean || true $STD apt -y autoclean 2>/dev/null || true
$STD apt -y clean 2>/dev/null || true
elif command -v dnf &>/dev/null; then
# Fedora/Rocky/AlmaLinux/CentOS 8+
$STD dnf clean all 2>/dev/null || true
$STD dnf autoremove -y 2>/dev/null || true
elif command -v yum &>/dev/null; then
# CentOS 7/older RHEL
$STD yum clean all 2>/dev/null || true
elif command -v zypper &>/dev/null; then
# openSUSE
$STD zypper clean --all 2>/dev/null || true
elif command -v emerge &>/dev/null; then
# Gentoo
$STD emerge --quiet --depclean 2>/dev/null || true
$STD eclean-dist -d 2>/dev/null || true
$STD eclean-pkg -d 2>/dev/null || true
fi fi
# Clear temp artifacts (keep sockets/FIFOs; ignore errors) # Clear temp artifacts (keep sockets/FIFOs; ignore errors)
@ -815,22 +833,22 @@ cleanup_lxc() {
fi fi
# Node.js npm # Node.js npm
if command -v npm &>/dev/null; then $STD npm cache clean --force || true; fi if command -v npm &>/dev/null; then $STD npm cache clean --force 2>/dev/null || true; fi
# Node.js yarn # Node.js yarn
if command -v yarn &>/dev/null; then $STD yarn cache clean || true; fi if command -v yarn &>/dev/null; then $STD yarn cache clean 2>/dev/null || true; fi
# Node.js pnpm # Node.js pnpm
if command -v pnpm &>/dev/null; then $STD pnpm store prune || true; fi if command -v pnpm &>/dev/null; then $STD pnpm store prune 2>/dev/null || true; fi
# Go # Go
if command -v go &>/dev/null; then $STD go clean -cache -modcache || true; fi if command -v go &>/dev/null; then $STD go clean -cache -modcache 2>/dev/null || true; fi
# Rust cargo # Rust cargo
if command -v cargo &>/dev/null; then $STD cargo clean || true; fi if command -v cargo &>/dev/null; then $STD cargo clean 2>/dev/null || true; fi
# Ruby gem # Ruby gem
if command -v gem &>/dev/null; then $STD gem cleanup || true; fi if command -v gem &>/dev/null; then $STD gem cleanup 2>/dev/null || true; fi
# Composer (PHP) # Composer (PHP)
if command -v composer &>/dev/null; then $STD composer clear-cache || true; fi if command -v composer &>/dev/null; then $STD composer clear-cache 2>/dev/null || true; fi
if command -v journalctl &>/dev/null; then if command -v journalctl &>/dev/null; then
$STD journalctl --vacuum-time=10m || true $STD journalctl --vacuum-time=10m 2>/dev/null || true
fi fi
msg_ok "Cleaned" msg_ok "Cleaned"
} }