![]() |
|
Last Chaos global server control 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 global server control script (/showthread.php?tid=5142) |
- xHypnosiaa - 01-07-2026 This script is a simple global controller for a Last Chaos server setup. It lets you start, stop, restart, and check the status of all server components with one command. It uses GNU screen, so every server runs in its own detached screen session and keeps running after you disconnect. --- What the script does Starts each LC server in the correct folder Runs each server in a dedicated screen session Prevents starting the same server twice Redirects all output to log files Lets you manage everything with one command --- Your servers must be located like this: /home/lastchaos/ ├─ Connector/ ├─ Helper/ ├─ SubHelper/ ├─ Messenger/ ├─ LoginServer/ ├─ GameServer1/ ├─ Billing/ └─ logs/ Otherwise, adjust the script if you want it to respect and use your own environment. Each server folder must contain either: a run script or an executable named like the folder (ex: Connector, Helper, etc.) --- How to use it Make the script executable: chmod +x server_start.sh Then use it : ./server_start.sh start # start all servers ./server_start.sh stop # stop all servers ./server_start.sh restart # restart all servers ./server_start.sh status # show server status --- Logs All logs are automatically written to: /home/lastchaos/logs/ One log file per server: Connector.log Helper.log GameServer1.log ... --- Screen sessions Each server runs in a screen named like: LC_Connector LC_GameServer1 ... To attach: screen -r LC_GameServer1 --- Notes for beginners Make sure screen is installed Run the script as the same user that owns the server files If a server doesn’t start, check its log first --- Script can be reworked, updated and modified to fits your need, but this is a solid base and would be useful for most beginners. #!/bin/bash # ============================================== # Last Chaos - Global Server Control Script # Author: xHypnosia # ============================================== BASE_DIR="/home/lastchaos" LOG_DIR="$BASE_DIR/logs" SCREEN_PREFIX="LC_" mkdir -p "$LOG_DIR" SERVERS=( "Connector" "Helper" "SubHelper" "Messenger" "LoginServer" "GameServer1" "Billing" ) start_server() { local name="$1" local dir="$BASE_DIR/$name" local screen_name="${SCREEN_PREFIX}${name}" if screen -list | grep -q "$screen_name"; then echo "WARNING: $name is already running." return fi if [ ! -d "$dir" ]; then echo "ERROR Directory not found: $dir" return fi echo "INFO: Starting $name..." cd "$dir" || return if [ -x ./run ]; then screen -dmS "$screen_name" bash -c "./run >> $LOG_DIR/${name}.log 2>&1" elif [ -x ./${name} ]; then screen -dmS "$screen_name" bash -c "./${name} Start >> $LOG_DIR/${name}.log 2>&1" else echo "ERROR No executable found in $dir" fi } stop_server() { local name="$1" local screen_name="${SCREEN_PREFIX}${name}" if screen -list | grep -q "$screen_name"; then echo "INFO: Stopping $name..." screen -S "$screen_name" -X quit else echo "INFO: $name is not running." fi } status_server() { local name="$1" local screen_name="${SCREEN_PREFIX}${name}" if screen -list | grep -q "$screen_name"; then echo "INFO: $name : Online" else echo "INFO: $name : Offline" fi } start_all() { echo "=== Global Last Chaos server startup ===" for s in "${SERVERS[@]}"; do start_server "$s" sleep 1 done echo "INFO: All servers have been started." } stop_all() { echo "=== Global Last Chaos server shutdown ===" for s in "${SERVERS[@]}"; do stop_server "$s" done echo "INFO: All servers have been stopped." } status_all() { echo "=== Last Chaos server status ===" for s in "${SERVERS[@]}"; do status_server "$s" done } case "$1" in start) start_all ;; stop) stop_all ;; restart) stop_all; sleep 2; start_all ;; status) status_all ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac If any help is requested althougt the script is prety straightforward, feel free to leave a comment or reach out on Discord : mrpandawaki (previously known as xHypnosia) |