Skip to content

Instantly share code, notes, and snippets.

View matrixino's full-sized avatar

Giuseppe Tripiciano matrixino

View GitHub Profile
#!/usr/bin/env bash
# Script by cPFence Team, https://cpfence.app
# Tested on Enhance v12 only!
# Safe Ubuntu cleanup: logs, apt, snap, temp, Docker (no volumes by default)
# Usage: sudo ./safe_cleanup.sh [--with-volumes]
WITH_VOLUMES=0
[[ "${1:-}" == "--with-volumes" ]] && WITH_VOLUMES=1
human() { # bytes to human readable
@xyzulu
xyzulu / recreate_enhance_backup_user_home-folders.sh
Created May 9, 2025 01:46
Enhance backup server - recreate user home folders (after wiping/replacing the backup disk/mount)
#!/bin/bash
declare -a users_to_create
echo "Scanning for users with missing home directories..."
while IFS=: read -r username _ uid gid _ homedir shell; do
# Ignore system users (UID < 1000), but include UID 0 (root)
# Also skip 'nobody' (UID 65534) and users with non-functional home directories
if [[ ("$uid" -ge 1000 || "$uid" -eq 0) && "$homedir" != "/nonexistent" && "$uid" -ne 65534 ]]; then
@xyzulu
xyzulu / ioncube_loaders_update.sh
Last active January 9, 2026 14:59
Update/download the latest version of ioncube loaders and update them in /usr/local/ioncube
#!/bin/bash
IONCUBE_DIR="/usr/local/ioncube"
REFERENCE_FILE="$IONCUBE_DIR/loader-wizard.php"
TMP_DIR="/tmp/ioncube_update"
LATEST_URL="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz"
echo "Updating ionCube Loaders..."
# Ensure the reference file exists
@xyzulu
xyzulu / cpfence_backup.sh
Last active January 9, 2026 14:59
Backup cPFence settings to a remote location and then delete the backup file
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
# Configuration
REMOTE_USER="your_user"
REMOTE_HOST="your_remote_host"
REMOTE_DIR="/path/to/remote/destination"
#!/bin/bash
# enhance_backup_sync.sh
#
# cPFence Team | https://cpfence.app
#
# Description:
# This script synchronizes the Enhance backup server's /backups directory with a remote server
# for disaster recovery (backup mode) or restores data from the remote server to the local server (restore mode).
#
# Usage:
@cPFence
cPFence / delete_old_backups
Created March 2, 2025 11:50
Delete Old Snapshot Backups in Enhance v12 ext4
# Dry-run version
DAYS=2
SECONDS_OLD=$((DAYS * 86400))
for site in /backups/*; do
[ -d "$site" ] || continue
current_snapshot=$(readlink "$site/current")
echo "Checking site: ${site##*/}"
find "$site" -maxdepth 1 -type d -name "snapshot-*" | while read -r snapshot; do
if [ "$snapshot" = "$current_snapshot" ]; then
#!/bin/bash
LOG_USER_DIR="/var/www"
LOG_SERVER_DIR="/var/log"
TRUNC_USER_SIZE="+3M"
TRUNC_USER_BYTES=3145728
TRUNC_SERVER_SIZE="+50M"
TRUNC_SERVER_BYTES=52428800
JOURNAL_RETENTION_DAYS=10
POSTFIX_LOG="/var/log/postfix.log"
#!/bin/bash
#
# cPFence OpenLiteSpeed Freeze - v2 (Enhance CP / Ubuntu 24)
# Version adapted for Enhance v12
# Copyright (C) 2023 - 2026 Linkers Gate LLC.
#
# Usage:
# ./cPFence_ols_freeze.sh freeze -> store current top-of-config and freeze + auto-install systemd manager
# ./cPFence_ols_freeze.sh unfreeze -> remove freeze marker and stored files + disable systemd manager
# ./cPFence_ols_freeze.sh -> run enforcement (intended for systemd path/timer or manual)
#!/bin/bash
# Script by cPFence Team, https://cpfence.app
#
# Description:
# This script performs routine server maintenance tasks:
# - Truncates user error logs larger than 5MB and server logs larger than 100MB, keeping only the last entries using `sponge` (ensure `sponge` is installed on the server).
# - Retains only the last 10 days of system journal logs.
# - Updates and upgrades packages non-interactively and checks if a reboot is required.
# - Clears APT cache to save space.
#!/bin/bash
# Written by: cPFence Team / https://cpfence.app/
#
# Description:
# This script is designed to automate the optimization and configuration of OpenLiteSpeed
# running inside a Docker container or directly on the host. It backs up the existing
# configuration file, applies updates to critical server settings such as worker processes,
# CPU affinity, memory buffer sizes, and external application configurations for PHP-LSAPI.
# MD5 checksum validation is added to detect changes and prevent redundant updates.