![]() |
|
Last Chaos build deployment script - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Guides & Help Section (https://lckb.dev/forum/forumdisplay.php?fid=193) +---- Forum: Tutorials & Guides (https://lckb.dev/forum/forumdisplay.php?fid=124) +----- Forum: Ep4 Guides (https://lckb.dev/forum/forumdisplay.php?fid=125) +----- Thread: Last Chaos build deployment script (/showthread.php?tid=5144) |
- xHypnosiaa - 01-08-2026 Simple guide – How to use the build deployment script This script is used to deploy the latest compiled build to your Last Chaos server folders. It automates what most people usually do by hand. --- What the script does When you run it, the script will: Take the latest compiled build Backup the existing files before replacing them Copy the new binaries to the correct server directories Apply permissions 777 on deployed files Overwrite old builds in a clean and repeatable way This avoids manual copy/paste and reduces deployment mistakes. --- About backups Before replacing anything, the script backs up the current files. If something goes wrong, you can easily restore the previous version. This is especially useful when testing new builds. --- About permissions (777) The script sets permissions to 777 to avoid permission issues during testing. Important note 777 is NOT recommended for production / live servers It is acceptable for test, dev, or private setups For live environments, permissions should be tightened properly The script favors simplicity over security for development use. --- Before using it Make sure: Your build is already compiled Servers are stopped before deployment You run the script as the same user that owns the server files Paths inside the script match your setup --- Make the script executable Run once: chmod +x deploy_latest.sh --- How to deploy a build Run: ./deploy_latest.sh No arguments needed. The script will: Backup old files Deploy the new build Apply permissions Finish in one pass --- After deployment Restart your servers normally If something doesn’t start, check logs first If needed, restore the backup and investigate --- Common mistakes Deploying while servers are still running Using it directly on a live server without adjusting permissions Wrong folder paths --- Final note This script is meant to: Speed up deployments Make updates safer with backups Keep your workflow clean during development For production setups, adapt permissions and security rules before using it. Quick notes : Made for linux. If you use windows files, you'll need to update the script. This assumes you have a builds folder with all your compiled builds in it. --- Script : #!/bin/bash # ============================================== # Last Chaos - Deploy Latest Build Script # Author: xHypnosia # ============================================== set -e # ===== CONFIG ===== BUILD_ROOT="/home/lastchaos/builds" TARGET_ROOT="/home/lastchaos" DATE=$(date +"%d_%m_%Y_%H_%M_%S") # ================== echo "[+] Searching for newest build in ${BUILD_ROOT}" # Find newest build directory NEWEST_BUILD=$(find "${BUILD_ROOT}" -maxdepth 1 -mindepth 1 -type d | sort -r | head -n 1) if [ -z "${NEWEST_BUILD}" ]; then echo "[!] No build directories found in ${BUILD_ROOT}" exit 1 fi echo "[?] Using build: ${NEWEST_BUILD}" # Backup directory inside the build BACKUP_DIR="${NEWEST_BUILD}/backup_${DATE}" echo "[+] Creating backup directory: ${BACKUP_DIR}" mkdir -p "${BACKUP_DIR}" # Backup + deploy function backup_and_deploy() { local SRC="$1" local DEST="$2" local DEST_DIR DEST_DIR=$(dirname "${DEST}") local REL_PATH="${DEST_DIR#${TARGET_ROOT}/}" echo "[>] Deploying $(basename "${DEST}")" # Ensure destination directory exists mkdir -p "${DEST_DIR}" # Backup existing binary if [ -f "${DEST}" ]; then echo " [-] Backing up existing binary" mkdir -p "${BACKUP_DIR}/${REL_PATH}" cp -f "${DEST}" "${BACKUP_DIR}/${REL_PATH}/" else echo " [ ] No existing binary to backup" fi # Deploy new binary if [ ! -f "${SRC}" ]; then echo "[!] Source file missing: ${SRC}" exit 1 fi cp -f "${SRC}" "${DEST}" chmod 777 "${DEST}" echo " [?] Deployed ${SRC} -> ${DEST}" } echo "[+] Deploying binaries" backup_and_deploy "${NEWEST_BUILD}/GameServer1" "${TARGET_ROOT}/GameServer1/GameServer1" backup_and_deploy "${NEWEST_BUILD}/LoginServer" "${TARGET_ROOT}/LoginServer/LoginServer" backup_and_deploy "${NEWEST_BUILD}/Helper" "${TARGET_ROOT}/Helper/Helper" backup_and_deploy "${NEWEST_BUILD}/SubHelper" "${TARGET_ROOT}/SubHelper/SubHelper" backup_and_deploy "${NEWEST_BUILD}/Connector" "${TARGET_ROOT}/Connector/Connector" backup_and_deploy "${NEWEST_BUILD}/Messenger" "${TARGET_ROOT}/Messenger/Messenger" backup_and_deploy "${NEWEST_BUILD}/Billing" "${TARGET_ROOT}/Billing/Billing" echo "[?] Build deployed successfully" echo "[?] Backups stored in: ${BACKUP_DIR}" |