Jump to content

Jedi Academy turned 20 this year! We celebrated in a ton of different ways: mod contest, server event, podcast, etc. Thank you to all who have been a part of this game for the last two decades. Check out the anniversary content!

Read more

Welcome to JKHub

This community is dedicated to the games Star Wars: Jedi Outcast (2002) and Jedi Academy (2003). We host over 3,000 mods created by passionate fans around the world, and thousands of threads of people showcasing their works in progress and asking for assistance. From mods to art to troubleshooting help, we probably have it. If we don't, request or contribute!

Get started

This game turned 20 years old this year, and it is still one of the greatest Star Wars games of all time. If you're new or returning from a long hiatus, here are the basics of getting started with Star Wars Jedi Knight Jedi Academy in 2023.

Read more

AutoRestart shared GameData script (LINUX)


banhammer
#!/bin/bash


#      __ __ __   ___    __ __  _       ____ ____  ___         ___________  ____ ____  ______ 
#     /  ]  |  | /  _]  /  ]  |/ ]     /    |    \|   \       / ___/      |/    |    \|      |
#    /  /|  |  |/  [_  /  /|  ' /     |  o  |  _  |    \     (   \_|      |  o  |  D  )      |
#   /  / |  _  |    _]/  / |    \     |     |  |  |  D  |     \__  |_|  |_|     |    /|_|  |_|
#  /   \_|  |  |   [_/   \_|     |    |  _  |  |  |     |     /  \ | |  | |  _  |    \  |  |  
#  \     |  |  |     \     |  .  |    |  |  |  |  |     |     \    | |  | |  |  |  .  \ |  |  
#   \____|__|__|_____|\____|__|\_|___ |__|__|__|__|_____|_ ___ \___| |__|_|__|__|__|\_| |__|  
#  |    \|  |  |    |    \ /    |    \|  |  |/    |   |   |   |   | /  _]    \                
#  |  o  )  |  |    |  o  )  o  |  _  |  |  |  o  | _   _ | _   _ |/  [_|  D  )               
#  |     |  ~  |    |     |     |  |  |  _  |     |  \_/  |  \_/  |    _]    /                
#  |  O  |___, |    |  O  |  _  |  |  |  |  |  _  |   |   |   |   |   [_|    \                
#  |     |     |    |     |  |  |  |  |  |  |  |  |   |   |   |   |     |  .  \               
#  |_____|____/     |_____|__|__|__|__|__|__|__|__|___|___|___|___|_____|__|\_|               
                                                                                         




# Start commands with parameters for each server
START_SERVER1="nohup nice -n -15 ./linuxjampded +set dedicated 2 +set sv_fps 20 +set sv_pure 1 +set gamename 'basejka' +set fs_game 'base' +set com_hunkmegs 16384 +set net_port 29070 +exec server1.cfg +map mp/ffa3 > log_server1.txt 2>&1 & echo \$!"
START_SERVER2="nohup nice -n -15 ./linuxjampded +set dedicated 2 +set sv_fps 20 +set sv_pure 1 +set gamename 'basejka' +set fs_game 'base' +set com_hunkmegs 16384 +set net_port 29071 +exec server3.cfg +map mp/ffa3 > log_server2.txt 2>&1 & echo \$!"
START_SERVER3="nohup nice -n -15 ./linuxjampded +set dedicated 2 +set sv_fps 20 +set sv_pure 1 +set gamename 'basejka' +set fs_game 'base' +set com_hunkmegs 16384 +set net_port 29072 +exec server2.cfg +map mp/ffa3 > log_server3.txt 2>&1 & echo \$!"

# Function to check if a server is running
check_and_start_server() {
    local SERVER_NAME=$1
    local START_COMMAND=$2
    local PID_FILE="/tmp/${SERVER_NAME}.pid"

    echo "---> Checking if the server '$SERVER_NAME' is running."
    
    if [ -f $PID_FILE ]; then
        local PID=$(cat $PID_FILE)
        if ps -p $PID > /dev/null 2>&1; then
            echo "-> Server '$SERVER_NAME' (PID $PID) is already running. <-"
            return
        else
            echo "-> Server '$SERVER_NAME' (PID $PID) is no longer running. Restarting. <-"
        fi
    else
        echo "-> No PID file found for the server '$SERVER_NAME'. Starting the server. <-"
    fi

    echo "---> Starting the server '$SERVER_NAME'. <---"
    NEW_PID=$(eval $START_COMMAND)
    echo "---> Server '$SERVER_NAME' started (PID $NEW_PID). <---"
    echo $NEW_PID > $PID_FILE
}

# Infinite loop to regularly check and restart the script
while true; do
    echo "---------------------------------------------------"
    echo "--         Starting the server check.            --"
    echo "---------------------------------------------------"
    echo " "
    check_and_start_server "SERVER1" "$START_SERVER1"
    check_and_start_server "SERVER2" "$START_SERVER2"
    check_and_start_server "SERVER3" "$START_SERVER3"
    echo " "
    echo "---------------------------------------------------"
    echo "--            Server check completed.            --"
    echo "---------------------------------------------------"


    
    # Wait for 15 seconds before the next check
    echo "--                                               --"
    echo "-- Waiting for 15 seconds before the next check. --"
    echo "--                                               --"
    echo "---------------------------------------------------"
    echo " "
    echo " "
    sleep 15
done

In GameData, create a file called “check_servers.sh” and paste the code above and edit the following lines to match with your servers settings:

START_SERVER1="nohup nice -n -15 ./linuxjampded +set dedicated 2 +set sv_fps 20 +set sv_pure 1 +set gamename 'basejka' +set fs_game 'base' +set com_hunkmegs YOUR_RAM_SERVER1 +set net_port YOUR_UDP_PORT_SERVER1 +exec server1.cfg +map YOUR_START_MAP > log_SERVER1.txt 2>&1 & echo \$!"
START_SERVER2="nohup nice -n -15 ./linuxjampded +set dedicated 2 +set sv_fps 20 +set sv_pure 1 +set gamename 'basejka' +set fs_game 'base' +set com_hunkmegs YOUR_RAM_SERVER2 +set net_port YOUR_UDP_PORT_SERVER2 +exec server3.cfg +map YOUR_START_MAP > log_SERVER2.txt 2>&1 & echo \$!"
START_SERVER3="nohup nice -n -15 ./linuxjampded +set dedicated 2 +set sv_fps 20 +set sv_pure 1 +set gamename 'basejka' +set fs_game 'base' +set com_hunkmegs YOUR_RAM_SERVER3 +set net_port YOUR_UDP_PORT_SERVER3 +exec server2.cfg +map YOUR_START_MAP > log_SERVER3.txt 2>&1 & echo \$!"

(Edit YOUR_RAM_SERVER..., YOUR_UDP_PORT_SERVER..., YOUR_START_MAP...)

 

Auto start for root reboots (to edit the crontab file for the user) use the following command: 

crontab -e

Add the Crontab Entry:

@reboot /path/to/your/check_servers.sh

Save and Exit the Crontab File:

If you are using the nano editor, save the file with "Ctrl+O", press Enter, and exit the editor with "Ctrl+X".


 

To make sure your script is executable by the owner, and readable and executable by others, you should set the permissions to 755. This grants the owner full permissions (read, write, and execute), and read and execute permissions to the group and others.

Here is how you can set the permissions:

chmod 755 /path/to/your/check_servers.sh

 


User Feedback

Recommended Comments

There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...