├── README ├── README.md ├── bin ├── AutoInstall ├── ChangePassword ├── CheckAddonCreationStatus ├── CheckCreateServerStatus ├── CheckGame ├── CheckInstall ├── CheckLoad ├── CheckSupportedInstallStatus ├── CheckTemplateStatus ├── CheckTemplates ├── CheckUpdateStatus ├── ConfigUpdate ├── CreateAddon ├── CreateDirectory ├── CreateServer ├── CreateTemplate ├── CreateUser ├── DeleteAddon ├── DeleteDirectory ├── DeleteServer ├── DeleteTemplate ├── DeleteUser ├── FileContent ├── FileDelete ├── FileSave ├── FileType ├── GPXManager ├── InstallAddon ├── InstallSupportedServer ├── MoveServerLocal ├── RemoveAddon ├── Restart ├── ServerOutput ├── ServerSendCMD ├── SteamCMDFunctions ├── SteamCMDInstall ├── SteamInstall ├── Stop ├── UpdateServer ├── UsernameChange └── VERSION ├── ftp.sh ├── gpx-remote-latest.tar.gz ├── initscripts ├── daemon-start ├── daemon-stop ├── debian-init.sh ├── gentoo-init.sh └── redhat-init.sh ├── install.sh ├── uninstall.sh ├── update.sh ├── updates └── 3.0.15.sh └── upgrade_309_3012.sh /README: -------------------------------------------------------------------------------- 1 | THIS PROJECT IS NO LONGER ACTIVELY MAINTAINED. 2 | 3 | Unfortunately I lack the time to work on this anymore. If someone is interested in taking the project over I may be open to that given the right skillset. 4 | 5 | 6 | Thank you for choosing GamePanelX Remote! 7 | 8 | SUPPORTED OPERATING SYSTEMS 9 | ------------------------------ 10 | Linux: RedHat/CentOS 4.x-6.x, Debian/Ubuntu, Gentoo 11 | 12 | 13 | 14 | INSTALLATION 15 | ------------------------------ 16 | # sudo chmod u+x install.sh 17 | # sudo ./install.sh 18 | 19 | This will get you started on the installation. This will also ask you if you want to install the FTP server. 20 | 21 | 22 | 23 | UPDATE 24 | ------------------------------ 25 | To update, run: 26 | # sudo chmod u+x update.sh 27 | # sudo ./update.sh 28 | 29 | Note: To update a Remote release _older_ than 3.0.10, run: 30 | # sudo chmod u+x upgrade_309_3012.sh 31 | # sudo ./upgrade_309_3012.sh 32 | 33 | 34 | 35 | SUPPORT/DOCUMENTATION/TUTORIALS 36 | ------------------------------- 37 | Website: http://gamepanelx.com/ 38 | Documentation: http://gamepanelx.com/wikiv3/index.php?title=Remote_Install 39 | Support Forums: http://gamepanelx.com/forums/ 40 | General Documentation: http://gamepanelx.com/wikiv3/ 41 | 42 | 43 | 44 | UNINSTALL 45 | ------------------------------- 46 | To uninstall, this will walk you through removal. 47 | NOTE: If you answer YES to removing your GPX user, this will remove ALL gpx files including gameservers and accounts for GamePanelX Remote in /usr/local/gpx. 48 | 49 | # sudo chmod u+x ./uninstall.sh 50 | # sudo ./uninstall.sh 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | THIS PROJECT IS NO LONGER ACTIVELY MAINTAINED. 2 | 3 | Unfortunately I lack the time to work on this anymore. It hurts/sucks to say that since this project has been a huge passion of mine since I started it. If someone is interested in taking the project over I may be open to that given the right skillset. -Ryan 4 | 5 | 6 | Thank you for choosing GamePanelX Remote! 7 | 8 | SUPPORTED OPERATING SYSTEMS 9 | ------------------------------ 10 | Linux: RedHat/CentOS 4.x-6.x, Debian/Ubuntu, Gentoo 11 | 12 | 13 | 14 | INSTALLATION 15 | ------------------------------ 16 | # sudo chmod u+x install.sh 17 | # sudo ./install.sh 18 | 19 | This will get you started on the installation. This will also ask you if you want to install the FTP server. 20 | 21 | 22 | 23 | UPDATE 24 | ------------------------------ 25 | To update, run: 26 | # sudo chmod u+x update.sh 27 | # sudo ./update.sh 28 | 29 | Note: To update a Remote release _older_ than 3.0.10, run: 30 | # sudo chmod u+x upgrade_309_3012.sh 31 | # sudo ./upgrade_309_3012.sh 32 | 33 | 34 | 35 | SUPPORT/DOCUMENTATION/TUTORIALS 36 | ------------------------------- 37 | Website: http://gamepanelx.com/ 38 | Documentation: http://gamepanelx.com/wikiv3/index.php?title=Remote_Install 39 | Support Forums: http://gamepanelx.com/forums/ 40 | General Documentation: http://gamepanelx.com/wikiv3/ 41 | 42 | 43 | 44 | UNINSTALL 45 | ------------------------------- 46 | To uninstall, this will walk you through removal. 47 | NOTE: If you answer YES to removing your GPX user, this will remove ALL gpx files including gameservers and accounts for GamePanelX Remote in /usr/local/gpx. 48 | 49 | # sudo chmod u+x ./uninstall.sh 50 | # sudo ./uninstall.sh 51 | -------------------------------------------------------------------------------- /bin/AutoInstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Auto installer - use given mirrors+cmd to install a gameserver, then being template process. 7 | # This script should be sent to /dev/null 2>&1 & since it will take some time to complete 8 | # 9 | # Example usage: 10 | # ./AutoInstall -m "http://example.com/gamefiles.gz,http://othermirror2.example.com/gamefiles.gz" -M 920df382ab316eca2d5e57fc5581f577 -c "gunzip gamefiles.gz ; mv gamefiles/* . ; rm -fr gamefiles" -i 24 >> /dev/null 2>&1 & 11 | # 12 | # -M: MD5sum of the downloaded file 13 | # -m: Mirror to download gameserver files from (direct link) 14 | # -c: Command to run after files are downloaded 15 | # -i: Template ID to use after install is done 16 | # 17 | install_mirror= 18 | install_md5= 19 | install_cmd= 20 | tpl_id= 21 | callback_url= 22 | cback="wget -qO-" 23 | debug_on= 24 | 25 | while getopts "m:M:c:C:i:d:" OPTION 26 | do 27 | case $OPTION in 28 | m) 29 | install_mirror=$OPTARG 30 | ;; 31 | c) 32 | install_cmd=$OPTARG 33 | ;; 34 | i) 35 | tpl_id=$OPTARG 36 | ;; 37 | M) 38 | install_md5=$OPTARG 39 | ;; 40 | C) 41 | callback_url=$OPTARG 42 | ;; 43 | d) 44 | debug_on=$OPTARG 45 | ;; 46 | ?) 47 | exit 48 | ;; 49 | esac 50 | done 51 | 52 | if [[ "$install_mirror" == "" || "$install_cmd" == "" || "$tpl_id" == "" ]] 53 | then 54 | echo "AutoInstall: Required settings were left out. Exiting." 55 | exit 56 | fi 57 | 58 | # Setup 59 | rm -fr /usr/local/gpx/tmp/$tpl_id 60 | mkdir /usr/local/gpx/tmp/$tpl_id 61 | install_dir=/usr/local/gpx/tmp/$tpl_id 62 | install_dir_local="tmp/$tpl_id" 63 | #install_log="$install_dir/.gpx_auto.log" 64 | install_log="/usr/local/gpx/logs/templates.log" 65 | echo > $install_log 66 | 67 | # Move to dir 68 | cd $install_dir 69 | 70 | ####################################################################################### 71 | 72 | # Download server files (hopefully an archive) 73 | # wget -q $install_mirror 2>&1 >> $install_log 74 | 75 | # Check MD5, if given 76 | if [[ "$install_md5" && "$install_md5" != "$(md5sum * 2>&1)" ]] 77 | then 78 | echo "AutoInstall: MD5sum does not match! Maybe the download failed ...exiting." 79 | exit 80 | fi 81 | 82 | # Download files 83 | wget -q $install_mirror 2>&1 >> $install_log 84 | 85 | # Run given commands to extract/move files 86 | echo '#!/bin/bash' > ./.gpx_auto.sh 87 | # echo "wget -q $install_mirror 2>&1 >> $install_log" >> ./.gpx_auto.sh 88 | echo -e $install_cmd >> ./.gpx_auto.sh 89 | chmod u+x ./.gpx_auto.sh 90 | 91 | # Debug on; print full output 92 | if [ "$debug_on" ] 93 | then 94 | ./.gpx_auto.sh 2>&1 95 | # Send to background 96 | else 97 | ./.gpx_auto.sh 2>&1 >> $install_log & 98 | auto_pid=$! 99 | 100 | # Check for script completion 101 | while [ true ] 102 | do 103 | # Done 104 | if [ ! -e /proc/$auto_pid ] 105 | then 106 | echo "AutoInstall script completed ($(date))." >> $install_log 107 | break 108 | # Still running 109 | else 110 | echo "AutoInstall script still running, sleeping 3 seconds ($(date)) ..." >> $install_log 111 | fi 112 | 113 | sleep 3 114 | done 115 | fi 116 | 117 | # No GNU Screen, start normally 118 | #if [ "$(which screen 2>&1 | grep 'no screen in')" ] 119 | #then 120 | # ./.gpx_auto.sh 2>&1 >> $install_log >> /dev/null 2>&1 & 121 | ## Start in Screen 122 | #else 123 | # # Start installation process in Screen 124 | # screen -wipe 2>&1 >> /dev/null 125 | # screen -d -m -S "gpxauto_$tpl_id" ./.gpx_auto.sh 126 | #fi 127 | 128 | # Setup debugging for tpl 129 | if [ "$debug_on" ] 130 | then 131 | add_debug=" -d yes" 132 | echo "Beginning template creation ..." 133 | else 134 | add_debug="" 135 | fi 136 | 137 | # Debug; start template now, instead of backgrounding 138 | #if [ "$debug_on" ] 139 | #then 140 | # /usr/local/gpx/bin/CreateTemplate -p $install_dir_local -i $tpl_id -u "$callback_url" $add_debug 141 | ## Start tpl in background 142 | #else 143 | # /usr/local/gpx/bin/CreateTemplate -p $install_dir_local -i $tpl_id -u "$callback_url" $add_debug >> /dev/null 2>&1 & 144 | #fi 145 | 146 | /usr/local/gpx/bin/CreateTemplate -p $install_dir_local -i $tpl_id -u "$callback_url" $add_debug 147 | 148 | 149 | # echo "success" 150 | -------------------------------------------------------------------------------- /bin/ChangePassword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Queue a password change of a gpx user account 7 | # -p passwords should be done with crypt() before giving it here, no plaintext passwords can be used here. 8 | # Example usage: 9 | # 10 | # ./ChangePassword -u test1 -p pass123 11 | # 12 | sso_user= 13 | sso_pass= 14 | tmp_dir="/usr/local/gpx/tmp" 15 | queue_dir="/usr/local/gpx/queue" 16 | rand_str="$(date +%s | sha256sum | base64 | head -c 24 ; echo)" 17 | 18 | while getopts "u:p:" OPTION 19 | do 20 | case $OPTION in 21 | u) 22 | sso_user=$OPTARG 23 | ;; 24 | p) 25 | sso_pass=$OPTARG 26 | ;; 27 | ?) 28 | exit 29 | ;; 30 | esac 31 | done 32 | 33 | # Check empty 34 | if [[ "$sso_user" == "" || "$sso_pass" == "" ]] 35 | then 36 | echo "Insufficient info given, exiting." 37 | exit 38 | fi 39 | 40 | # Check if user actually exists 41 | if [ "$(grep "^gpx$sso_user:" /etc/passwd)" == "" ] 42 | then 43 | echo "That user ($sso_user) does not exist, exiting." 44 | exit 45 | fi 46 | 47 | # Send to tmp file so manager doesn't read before we're done writing 48 | echo "type: changepass" > $tmp_dir/queue_$rand_str 49 | echo "username: $sso_user" >> $tmp_dir/queue_$rand_str 50 | echo "password: $sso_pass" >> $tmp_dir/queue_$rand_str 51 | 52 | # Move to queue dir 53 | mv $tmp_dir/queue_$rand_str $queue_dir/$rand_str 54 | touch $tmp_dir/$sso_user 55 | echo "gpx$sso_user:$sso_pass" > $tmp_dir/$sso_user 56 | 57 | echo "success" 58 | -------------------------------------------------------------------------------- /bin/CheckAddonCreationStatus: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of Addon creation 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckAddonCreationStatus -i fa4990f190de97a37abfab9980e8df8e06bbc291 12 | # 13 | tpl_hash= 14 | 15 | while getopts "i:" OPTION 16 | do 17 | case $OPTION in 18 | i) 19 | tpl_hash=$OPTARG 20 | ;; 21 | ?) 22 | exit 23 | ;; 24 | esac 25 | done 26 | 27 | if [[ "$tpl_hash" == "" ]] 28 | then 29 | echo "CheckAddonCreationStatus: Required settings were left out. Exiting." 30 | exit 31 | fi 32 | 33 | if [ -f /usr/local/gpx/addons/.gpx_$tpl_hash ] 34 | then 35 | pid=`cat /usr/local/gpx/addons/.gpx_$tpl_hash` 36 | check_pid=`ps aux | grep $pid | grep -v grep` 37 | 38 | if [ "$check_pid" == "" ] 39 | then 40 | echo "complete" 41 | else 42 | echo "running" 43 | fi 44 | else 45 | echo "complete" 46 | fi 47 | -------------------------------------------------------------------------------- /bin/CheckCreateServerStatus: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of Game/Voice Server creation 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckCreateServerStatus -u user123 -t game -i 192.168.10.10 -p 27015 12 | # 13 | srv_username= 14 | srv_type= 15 | srv_ip= 16 | srv_port= 17 | 18 | while getopts "u:t:i:p:" OPTION 19 | do 20 | case $OPTION in 21 | u) 22 | srv_username=$OPTARG 23 | ;; 24 | t) 25 | srv_type=$OPTARG 26 | ;; 27 | i) 28 | srv_ip=$OPTARG 29 | ;; 30 | p) 31 | srv_port=$OPTARG 32 | ;; 33 | ?) 34 | exit 35 | ;; 36 | esac 37 | done 38 | 39 | 40 | if [[ "$srv_username" == "" || "$srv_type" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 41 | then 42 | echo "CheckCreateServerStatus: Required settings were left out. Exiting." 43 | exit 44 | fi 45 | 46 | if [ -f /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/.gpx_template ] 47 | then 48 | pid=`cat /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/.gpx_template` 49 | check_pid=`ps aux | grep $pid | grep -v grep` 50 | 51 | if [ "$check_pid" == "" ] 52 | then 53 | echo "complete" 54 | else 55 | echo "running" 56 | fi 57 | else 58 | echo "complete" 59 | fi 60 | -------------------------------------------------------------------------------- /bin/CheckGame: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of servers (get PID(s), cpu/mem info, time running) 7 | # 8 | # -u: Client's gpx username 9 | # -i: Server IP Address (x.x.x.x) 10 | # -p: Server Port 11 | # 12 | # Example usage: 13 | # ./CheckGame -u user123 -i 192.168.10.10 -p 27015 14 | # 15 | srv_username= 16 | srv_ip= 17 | srv_port= 18 | 19 | while getopts "u:i:p:" OPTION 20 | do 21 | case $OPTION in 22 | u) 23 | srv_username=$OPTARG 24 | ;; 25 | i) 26 | srv_ip=$OPTARG 27 | ;; 28 | p) 29 | srv_port=$OPTARG 30 | ;; 31 | ?) 32 | exit 33 | ;; 34 | esac 35 | done 36 | 37 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 38 | then 39 | echo '{"error":"Restart: Required settings were left out"}' 40 | exit 41 | fi 42 | 43 | # Check for homedir 44 | if [ ! -d /usr/local/gpx/users/$srv_username/$srv_ip.$srv_port ]; then 45 | echo '{"error":"Restart: Game directory ('$gpxdir') doesnt exist!"}' 46 | exit 47 | else 48 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 49 | fi 50 | 51 | # wtf? 52 | #srv_username= 53 | #srv_ip= 54 | #srv_port= 55 | 56 | # Restart PID, server PID 57 | if [ -f $gpxdir/.gpxrespid ]; then 58 | res_pid=$(cat $gpxdir/.gpxrespid); 59 | else 60 | res_pid= 61 | fi 62 | 63 | # Parent server PID 64 | if [ -f $gpxdir/.gpxpid ]; then 65 | parent_pid=$(cat $gpxdir/.gpxpid) 66 | else 67 | parent_pid= 68 | fi 69 | 70 | # Child PID, if it exists 71 | child_pid="$(ps -ef | grep \"$parent_pid\" | grep -v grep | awk '{print $2}' | grep -v \"$parent_pid\")" 72 | 73 | # Get CPU and Mem info 74 | if [ "$child_pid" ] 75 | then 76 | cpuinfo="$(ps -p $child_pid -o %cpu | tail -1)" 77 | meminfo="$(ps -p $child_pid -o %mem | tail -1)" 78 | else 79 | cpuinfo="$(ps -p $parent_pid -o %cpu | tail -1)" 80 | meminfo="$(ps -p $parent_pid -o %mem | tail -1)" 81 | fi 82 | 83 | # Output JSON response 84 | echo '{"respid":"'$res_pid'","ppid":"'$parent_pid'","cpid":"'$child_pid'","cpu":"'$cpuinfo'","mem":"'$meminfo'"}' 85 | -------------------------------------------------------------------------------- /bin/CheckInstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check the Remote Server installation 7 | # 8 | master_cback= 9 | user_accounts= 10 | 11 | while getopts "c:u:" OPTION 12 | do 13 | case $OPTION in 14 | c) 15 | master_cback=$OPTARG 16 | ;; 17 | u) 18 | user_accounts=$OPTARG 19 | ;; 20 | ?) 21 | exit 22 | ;; 23 | esac 24 | done 25 | 26 | if [ ! -d "/usr/local/gpx/bin" ] 27 | then 28 | echo "Unable to find the scripts directory; exiting." 29 | exit 30 | else 31 | if [ ! -f "/usr/local/gpx/bin/CheckLoad" ] 32 | then 33 | echo "Missing scripts in the scripts directory; exiting." 34 | exit 35 | fi 36 | if [ ! -f "/usr/local/gpx/bin/Restart" ] 37 | then 38 | echo "Missing scripts in the scripts directory; exiting." 39 | exit 40 | fi 41 | if [ ! -f "/usr/local/gpx/bin/Stop" ] 42 | then 43 | echo "Missing scripts in the scripts directory; exiting." 44 | exit 45 | fi 46 | fi 47 | if [ ! -d "/usr/local/gpx/users" ] 48 | then 49 | echo "Unable to find the accounts directory; exiting." 50 | exit 51 | fi 52 | if [ ! -d "/usr/local/gpx/addons" ] 53 | then 54 | echo "Unable to find the addons directory; exiting." 55 | exit 56 | fi 57 | if [ ! -d "/usr/local/gpx/templates" ] 58 | then 59 | echo "Unable to find the templates directory; exiting." 60 | exit 61 | fi 62 | if [ ! -d "/usr/local/gpx/tmp" ] 63 | then 64 | echo "Unable to find the tmp directory; exiting." 65 | exit 66 | fi 67 | if [ ! -d "/usr/local/gpx/uploads" ] 68 | then 69 | echo "Unable to find the uploads directory; exiting." 70 | exit 71 | fi 72 | 73 | # Create any user account dirs that are in the db 74 | if [ "$user_accounts" ] 75 | then 76 | for usr_acct in $(echo "$user_accounts" | sed s/,/\\n/g); do 77 | this_usr="$(echo $usr_acct | awk -F':' '{print $1}')" 78 | this_pass="$(echo $usr_acct | awk -F':' '{print $2}')" 79 | 80 | # Skip if no usr/pass 81 | if [[ "$this_usr" == "" || "$this_pass" == "" ]]; then 82 | continue 83 | fi 84 | 85 | # Create user if they dont exist 86 | if [ ! "$(grep gpx$this_usr: /etc/passwd)" ]; then 87 | /usr/local/gpx/bin/CreateUser -u "$this_usr" -p "$this_pass" >> /dev/null 2>&1 & 88 | fi 89 | done 90 | fi 91 | 92 | # Update config with token 93 | if [ "$master_cback" ] 94 | then 95 | # Check if already there 96 | if [ "$(grep master_callback /usr/local/gpx/etc/config.cfg)" ] 97 | then 98 | # sed -i "s/^master_callback\:\ .*\r\n//g" /usr/local/gpx/etc/config.cfg 99 | sed -i '/^master_callback\:\ http.*/d' /usr/local/gpx/etc/config.cfg 100 | echo "master_callback: $master_cback" >> /usr/local/gpx/etc/config.cfg 101 | else 102 | echo "master_callback: $master_cback" >> /usr/local/gpx/etc/config.cfg 103 | fi 104 | fi 105 | 106 | echo "success" 107 | -------------------------------------------------------------------------------- /bin/CheckLoad: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check system load average 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckLoad 12 | # 13 | freemem=`cat /proc/meminfo | grep MemFree | awk '{print $2}'` 14 | totalmem=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'` 15 | loadavg=`uptime|awk '{print $10}' | tr ',' ' '` 16 | 17 | echo "$loadavg,$totalmem,$freemem" 18 | -------------------------------------------------------------------------------- /bin/CheckSupportedInstallStatus: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of Supported Server creation 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckSupportedInstallStatus -i 12 12 | # 13 | tpl_id= 14 | total_size= 15 | 16 | while getopts "i:s:" OPTION 17 | do 18 | case $OPTION in 19 | i) 20 | tpl_id=$OPTARG 21 | ;; 22 | s) 23 | # Deprecated 24 | total_size=$OPTARG 25 | ;; 26 | ?) 27 | exit 28 | ;; 29 | esac 30 | done 31 | 32 | if [[ "$tpl_id" == "" ]] 33 | then 34 | echo "CheckSupportedInstallStatus: Required settings were left out. Exiting." 35 | exit 36 | fi 37 | 38 | if [ -f /usr/local/gpx/tmp/$tpl_id/.gpxpid ] 39 | then 40 | pid=`cat /usr/local/gpx/tmp/$tpl_id/.gpxpid` 41 | check_pid=`ps aux | grep $pid | grep -v grep` 42 | 43 | # Completed 44 | if [ "$check_pid" == "" ] 45 | then 46 | echo "complete" 47 | # Steam Installs 48 | elif [ -f ~/tmp/$tpl_id/.gpxinstall.log ] 49 | then 50 | # Get percentage done 51 | steam_percent=`tail -n1 ~/tmp/$tpl_id/.gpxinstall.log | awk '{print $1}'` 52 | 53 | # "No" for "No installation record found at ./css" etc 54 | if [ "$steam_percent" == "No" ] 55 | then 56 | echo "running" 57 | else 58 | echo $steam_percent 59 | fi 60 | 61 | # Total Size 62 | else 63 | if [ -n "$total_size" ] 64 | then 65 | curr_size=`du -s /usr/local/gpx/tmp/$tpl_id/ | awk '{print $1}'` 66 | echo "running,$curr_size" 67 | else 68 | echo "running" 69 | fi 70 | fi 71 | else 72 | echo "unknown" 73 | fi 74 | -------------------------------------------------------------------------------- /bin/CheckTemplateStatus: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of Template creation 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckTemplateStatus -i fa4990f190de97a37abfab9980e8df8e06bbc291 12 | # 13 | tpl_hash= 14 | 15 | while getopts "i:" OPTION 16 | do 17 | case $OPTION in 18 | i) 19 | tpl_hash=$OPTARG 20 | ;; 21 | ?) 22 | exit 23 | ;; 24 | esac 25 | done 26 | 27 | if [[ "$tpl_hash" == "" ]] 28 | then 29 | echo "CheckTemplateStatus: Required settings were left out. Exiting." 30 | exit 31 | fi 32 | 33 | if [ -f /usr/local/gpx/templates/.gpx_$tpl_hash ] 34 | then 35 | pid=`cat /usr/local/gpx/templates/.gpx_$tpl_hash` 36 | check_pid=`ps aux | grep $pid | grep -v grep` 37 | 38 | if [ "$check_pid" == "" ] 39 | then 40 | echo "complete" 41 | else 42 | echo "running" 43 | fi 44 | else 45 | echo "complete" 46 | fi 47 | -------------------------------------------------------------------------------- /bin/CheckTemplates: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of Template creation 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckTemplateStatus -i fa4990f190de97a37abfab9980e8df8e06bbc291 12 | # 13 | tpl_ids= 14 | outp='{' 15 | 16 | while getopts "i:" OPTION 17 | do 18 | case $OPTION in 19 | i) 20 | tpl_ids=$OPTARG 21 | ;; 22 | ?) 23 | exit 24 | ;; 25 | esac 26 | done 27 | 28 | if [[ "$tpl_ids" == "" ]] 29 | then 30 | echo "CheckTpls: No template IDs provided! Exiting." 31 | exit 32 | fi 33 | 34 | for tplid in $(echo "$tpl_ids" | sed 's/\,/\ /g') 35 | do 36 | if [ -f /usr/local/gpx/templates/.gpx_"$tplid" ] 37 | then 38 | this_pid="$(cat /usr/local/gpx/templates/.gpx_"$tplid")" 39 | 40 | if [ "$this_pid" ] 41 | then 42 | # Check if running 43 | # Giving wrong output due to other matching PIDs: if [ "$(ps -ef | grep $this_pid | grep -v grep)" ] 44 | if [ "$(ps -ef | awk '{print $2}' | grep '^'$this_pid'$' | grep -v grep)" ] 45 | then 46 | this_status="running" 47 | else 48 | this_status="complete" 49 | fi 50 | 51 | outp="$outp"'"'$tplid'":"'$this_status'",' 52 | fi 53 | fi 54 | done 55 | 56 | # Remove last comma 57 | outp=${outp%?} 58 | 59 | # Finish JSON output 60 | outp="$outp"'}' 61 | 62 | 63 | # JSON Response 64 | echo $outp 65 | -------------------------------------------------------------------------------- /bin/CheckUpdateStatus: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Check status of a Game/Voice server update 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CheckUpdateStatus -u user123 -t game -i 192.168.10.10 -p 27015 12 | # 13 | srv_username= 14 | srv_type= 15 | srv_ip= 16 | srv_port= 17 | 18 | while getopts "u:t:i:p:" OPTION 19 | do 20 | case $OPTION in 21 | u) 22 | srv_username=$OPTARG 23 | ;; 24 | t) 25 | srv_type=$OPTARG 26 | ;; 27 | i) 28 | srv_ip=$OPTARG 29 | ;; 30 | p) 31 | srv_port=$OPTARG 32 | ;; 33 | ?) 34 | exit 35 | ;; 36 | esac 37 | done 38 | 39 | if [[ "$srv_username" == "" || "$srv_type" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 40 | then 41 | echo "CheckUpdateStatus: Required settings were left out. Exiting." 42 | exit 43 | fi 44 | 45 | if [ -f /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/.gpxupdatepid ] 46 | then 47 | pid=`cat /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/.gpxupdatepid` 48 | check_pid=`ps aux | grep $pid | grep -v grep` 49 | 50 | if [ "$check_pid" == "" ] 51 | then 52 | echo "complete" 53 | else 54 | echo "running" 55 | fi 56 | else 57 | echo "complete" 58 | fi 59 | -------------------------------------------------------------------------------- /bin/ConfigUpdate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Update configuration file with server values 7 | # 8 | # Example: ./ConfigUpdate -f "css/cstrike/cfg/server.cfg" -s '=' -u user1 -i 1.2.3.4 -p 27015 ... 9 | # 10 | cfg_file= 11 | cfg_sep= 12 | cfg_key_ip= 13 | cfg_key_port= 14 | cfg_key_map= 15 | cfg_key_maxpl= 16 | cfg_key_rcon= 17 | cfg_key_hostn= 18 | cfg_key_passw= 19 | cfg_val_ip= 20 | cfg_val_port= 21 | cfg_val_map= 22 | cfg_val_maxpl= 23 | cfg_val_rcon= 24 | cfg_val_hostn= 25 | cfg_val_passw= 26 | 27 | # while getopts "X:c:s:u:i:p:d:e:f:g:h:j:k:L:m:n:O:q:r:t:" OPTION 28 | while getopts "x:u:i:p:c:s:d:e:f:g:h:j:k:L:m:n:O:q:r:t:" OPTION 29 | do 30 | case $OPTION in 31 | x) 32 | cfg_val_port=$OPTARG 33 | ;; 34 | u) 35 | srv_username=$OPTARG 36 | ;; 37 | i) 38 | srv_ip=$OPTARG 39 | ;; 40 | p) 41 | srv_port=$OPTARG 42 | ;; 43 | c) 44 | cfg_file=$OPTARG 45 | ;; 46 | s) 47 | cfg_sep=$OPTARG 48 | ;; 49 | d) 50 | cfg_key_ip=$OPTARG 51 | ;; 52 | e) 53 | cfg_key_port=$OPTARG 54 | ;; 55 | f) 56 | cfg_key_map=$OPTARG 57 | ;; 58 | g) 59 | cfg_key_maxpl=$OPTARG 60 | ;; 61 | h) 62 | cfg_key_rcon=$OPTARG 63 | ;; 64 | j) 65 | cfg_key_hostn=$OPTARG 66 | ;; 67 | k) 68 | cfg_val_ip=$OPTARG 69 | ;; 70 | L) 71 | cfg_port_value=$OPTARG 72 | ;; 73 | m) 74 | cfg_val_map=$OPTARG 75 | ;; 76 | n) 77 | cfg_val_maxpl=$OPTARG 78 | ;; 79 | O) 80 | cfg_val_rcon=$OPTARG 81 | ;; 82 | q) 83 | cfg_val_hostn=$OPTARG 84 | ;; 85 | r) 86 | cfg_key_passw=$OPTARG 87 | ;; 88 | t) 89 | cfg_val_passw=$OPTARG 90 | ;; 91 | ?) 92 | exit 93 | ;; 94 | esac 95 | done 96 | 97 | # Check empty 98 | if [ "$cfg_file" == "" ] 99 | then 100 | echo "ConfigUpdate: Config Filename (-c) was left out, exiting." 101 | exit 102 | elif [ "$cfg_sep" == "" ] 103 | then 104 | echo "ConfigUpdate: Config separator (-s) was left out, exiting." 105 | exit 106 | fi 107 | 108 | # Check gameserver dir 109 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 110 | 111 | if [ ! -d $gpxdir ] 112 | then 113 | echo "ConfigUpdate: Server directory doesnt exist, exiting." 114 | exit 115 | fi 116 | 117 | # Set config file to full path 118 | cfg_file="$gpxdir/$cfg_file" 119 | 120 | # Ensure config exists 121 | if [ ! -f $cfg_file ] 122 | then 123 | # Do nothing, they can create configs manually if they want them updated+managed 124 | echo "success" 125 | exit 126 | 127 | # # Optionally create config automatically and add in some defaults. This was breaking some games, like Steam based games. Removing this as it only adds complication. 128 | # # NOTE: Uncomment these below (and the "exit" line above) if you want config files automatically created and populated with some basic defaults. 129 | # 130 | # # Create the config for them 131 | # touch $cfg_file 132 | # 133 | # # Add defaults if they are set 134 | # if [ "$cfg_key_ip" ]; then echo $cfg_key_ip"$cfg_sep"$cfg_val_ip >> $cfg_file; fi 135 | # if [ "$cfg_key_port" ]; then echo $cfg_key_port"$cfg_sep"$cfg_val_port >> $cfg_file; fi 136 | # if [[ "$cfg_key_maxpl" && "$cfg_val_maxpl" ]]; then echo $cfg_key_maxpl"$cfg_sep"$cfg_val_maxpl >> $cfg_file; fi 137 | # if [[ "$cfg_key_map" && "$cfg_val_map" ]]; then echo $cfg_key_map"$cfg_sep"$cfg_val_map >> $cfg_file; fi 138 | # if [[ "$cfg_key_rcon" && "$cfg_val_rcon" ]]; then echo $cfg_key_rcon"$cfg_sep"$cfg_val_rcon >> $cfg_file; fi 139 | # if [[ "$cfg_key_hostn" && "$cfg_val_hostn" ]]; then echo $cfg_key_hostn"$cfg_sep"$cfg_val_hostn >> $cfg_file; fi 140 | # if [[ "$cfg_key_passw" && "$cfg_val_passw" ]]; then echo $cfg_key_passw"$cfg_sep"$cfg_val_passw >> $cfg_file; fi 141 | fi 142 | 143 | ################################################################################# 144 | 145 | # Normal key/vals 146 | # Replace key=value with the correct key, separator, and value on this config 147 | # e.g. ip=x.x.x.x 148 | # Key being ip, separator being =, and value being x.x.x.x 149 | if [ "$cfg_key_ip" ]; then sed -i "s/^$cfg_key_ip.*/$cfg_key_ip$cfg_sep$cfg_val_ip/g" $cfg_file; fi 150 | if [ "$cfg_key_port" ]; then sed -i "s/^$cfg_key_port.*/$cfg_key_port$cfg_sep$cfg_val_port/g" $cfg_file; fi 151 | if [ "$cfg_key_map" ]; then sed -i "s/^$cfg_key_map.*/$cfg_key_map$cfg_sep$cfg_val_map/g" $cfg_file; fi 152 | if [ "$cfg_key_maxpl" ]; then sed -i "s/^$cfg_key_maxpl.*/$cfg_key_maxpl$cfg_sep$cfg_val_maxpl/g" $cfg_file; fi 153 | if [ "$cfg_key_rcon" ]; then sed -i "s/^$cfg_key_rcon.*/$cfg_key_rcon$cfg_sep$cfg_val_rcon/g" $cfg_file; fi 154 | if [ "$cfg_key_hostn" ]; then sed -i "s/^$cfg_key_hostn.*/$cfg_key_hostn$cfg_sep$cfg_val_hostn/g" $cfg_file; fi 155 | if [ "$cfg_key_passw" ]; then sed -i "s/^$cfg_key_passw.*/$cfg_key_passw$cfg_sep$cfg_val_passw/g" $cfg_file; fi 156 | 157 | ################################################################################# 158 | 159 | # XML Config files (such as Multi-Theft Auto/MTA). Set "Config Separator" to "X" (caps matters) in default games to make it work with XML. 160 | if [ "$cfg_sep" == "X" ]; then 161 | if [ "$cfg_key_ip" ]; then sed -i "s/<$cfg_key_ip>.*/<$cfg_key_ip>$cfg_val_ip<\/$cfg_key_ip>/g" $cfg_file; fi 162 | if [ "$cfg_key_port" ]; then sed -i "s/<$cfg_key_port>.*/<$cfg_key_port>$cfg_val_port<\/$cfg_key_port>/g" $cfg_file; fi 163 | if [ "$cfg_key_map" ]; then sed -i "s/<$cfg_key_map>.*/<$cfg_key_map>$cfg_val_map<\/$cfg_key_map>/g" $cfg_file; fi 164 | if [ "$cfg_key_maxpl" ]; then sed -i "s/<$cfg_key_maxpl>.*/<$cfg_key_maxpl>$cfg_val_maxpl<\/$cfg_key_maxpl>/g" $cfg_file; fi 165 | if [ "$cfg_key_rcon" ]; then sed -i "s/<$cfg_key_rcon>.*/<$cfg_key_rcon>$cfg_val_rcon<\/$cfg_key_rcon>/g" $cfg_file; fi 166 | if [ "$cfg_key_hostn" ]; then sed -i "s/<$cfg_key_hostn>.*/<$cfg_key_hostn>$cfg_val_hostn<\/$cfg_key_hostn>/g" $cfg_file; fi 167 | if [ "$cfg_key_passw" ]; then sed -i "s/<$cfg_key_passw>.*/<$cfg_key_passw>$cfg_val_passw<\/$cfg_key_passw>/g" $cfg_file; fi 168 | fi 169 | 170 | echo "success" 171 | -------------------------------------------------------------------------------- /bin/CreateAddon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Create a Game/Voice Server Addon 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./CreateAddon -p /home/gpx/tmp/maniadmin -i fa4990f190de97a37abfab9980e8df8e06bbc291 12 | # 13 | tpl_file_path= 14 | tpl_hash= 15 | 16 | while getopts "p:i:" OPTION 17 | do 18 | case $OPTION in 19 | p) 20 | tpl_file_path=$OPTARG 21 | ;; 22 | i) 23 | tpl_hash=$OPTARG 24 | ;; 25 | ?) 26 | exit 27 | ;; 28 | esac 29 | done 30 | 31 | if [[ "$tpl_file_path" == "" || "$tpl_hash" == "" ]] 32 | then 33 | echo "CreateAddon: Required settings were left out. Exiting." 34 | exit 35 | fi 36 | 37 | cd $tpl_file_path 38 | tar -czf /usr/local/gpx/addons/$tpl_hash.tar.gz * >> /dev/null 2>&1 & 39 | pid=$! 40 | echo $pid > /usr/local/gpx/addons/.gpx_$tpl_hash 41 | -------------------------------------------------------------------------------- /bin/CreateDirectory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Create Directory on game/voice servers 7 | # 8 | # -u: Client's gpx username 9 | # -i: Server IP Address (x.x.x.x) 10 | # -p: Server Port 11 | # -d: New directory name (with relative path, such as "cstrike/newdirname") 12 | # 13 | # Example usage: 14 | # ./CreateDirectory -u user123 -i 192.168.10.10 -p 27015 -d newdirname 15 | # 16 | srv_username= 17 | srv_ip= 18 | srv_port= 19 | new_dir= 20 | 21 | while getopts "u:i:p:d:" OPTION 22 | do 23 | case $OPTION in 24 | u) 25 | srv_username=$OPTARG 26 | ;; 27 | i) 28 | srv_ip=$OPTARG 29 | ;; 30 | p) 31 | srv_port=$OPTARG 32 | ;; 33 | d) 34 | new_dir=$OPTARG 35 | ;; 36 | ?) 37 | exit 38 | ;; 39 | esac 40 | done 41 | 42 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" || "$new_dir" == "" ]] 43 | then 44 | echo "CreateDirectory: Required settings were left out! Exiting." 45 | exit 46 | fi 47 | 48 | # Check for homedir 49 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 50 | 51 | if [ ! -d $gpxdir ] 52 | then 53 | echo ": Game directory ($gpxdir) doesnt exist! Exiting." 54 | exit 55 | fi 56 | 57 | # Create directory 58 | mkdir $gpxdir/$new_dir 59 | 60 | echo "success" 61 | -------------------------------------------------------------------------------- /bin/CreateServer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Create a Game/Voice Server 7 | # 8 | # Example usage: 9 | # 10 | # Create only: 11 | # ./CreateServer -u user123 -i 192.168.10.10 -p 27015 -x 27 12 | # 13 | # Create and Start the server: 14 | # ./CreateServer -u user123 -i 192.168.10.10 -p 27015 -x 27 -s yes -P server.pid -o './srcds_run -game cstrike -ip 192.168.10.10 -port 27015 +map de_dust2' 15 | # 16 | srv_username= 17 | srv_ip= 18 | srv_port= 19 | tpl_id= 20 | start_server= 21 | working_dir= 22 | server_pid= 23 | srv_cmd_line= 24 | callback_url= 25 | cback="wget -qO-" 26 | 27 | while getopts "u:i:p:x:s:w:P:o:c:" OPTION 28 | do 29 | case $OPTION in 30 | u) 31 | srv_username=$OPTARG 32 | ;; 33 | i) 34 | srv_ip=$OPTARG 35 | ;; 36 | p) 37 | srv_port=$OPTARG 38 | ;; 39 | x) 40 | tpl_id=$OPTARG 41 | ;; 42 | s) 43 | start_server=$OPTARG 44 | ;; 45 | w) 46 | working_dir=$OPTARG 47 | ;; 48 | c) 49 | callback_url=$OPTARG 50 | ;; 51 | P) 52 | server_pid=$OPTARG 53 | ;; 54 | o) 55 | srv_cmd_line=$OPTARG 56 | ;; 57 | ?) 58 | exit 59 | ;; 60 | esac 61 | done 62 | 63 | # Setup logging 64 | srv_log=/usr/local/gpx/logs/servers.log 65 | 66 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" || "$tpl_id" == "" ]] 67 | then 68 | echo "CreateServer: Required settings were left out. Exiting." 69 | echo "$(date) $(hostname) CreateServer: Required settings were left out. Exiting." >> $srv_log 70 | if [ "$callback_url" ]; then $cback "$callback_url&do=createsrv_status&status=failed" >> /dev/null; fi 71 | exit 72 | fi 73 | 74 | if [ -d /usr/local/gpx/users/$srv_username/$srv_ip\.$srv_port ] 75 | then 76 | echo "CreateServer: Account directory exists! Exiting." 77 | echo "$(date) $(hostname) CreateServer: Account directory exists! Exiting." >> $srv_log 78 | if [ "$callback_url" ]; then $cback "$callback_url&do=createsrv_status&status=failed" >> /dev/null; fi 79 | exit 80 | else 81 | echo "$(date) $(hostname) CreateServer: Creating server directory /usr/local/gpx/users/$srv_username/$srv_ip.$srv_port ..." >> $srv_log 82 | mkdir -p /usr/local/gpx/users/$srv_username/$srv_ip\.$srv_port 83 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 84 | fi 85 | 86 | echo "$(date) $(hostname) CreateServer: Extracting TPL ($tpl_id) to $gpxdir ..." >> $srv_log 87 | 88 | tar -zxf /usr/local/gpx/templates/$tpl_id.tar.gz -C $gpxdir/ >> $srv_log 2>&1 & 89 | pid=$! 90 | 91 | if [ "$pid" == "" ] 92 | then 93 | echo "No PID found! Exiting" 94 | exit 95 | fi 96 | 97 | echo $pid > $gpxdir/.gpx_template 98 | 99 | # Start checking if creation is complete to start server 100 | while [ true ] 101 | do 102 | # Check if complete 103 | #if [ "$(ps aux | grep $pid | grep -v grep)" == "" ] 104 | if [ ! -e /proc/$pid ] 105 | then 106 | # Ready, update callback 107 | if [ "$callback_url" ]; then $cback "$callback_url&do=createsrv_status&status=complete" >> /dev/null; fi 108 | 109 | # Start server up 110 | if [[ "$start_server" == "yes" || "$start_server" == "y" ]] 111 | then 112 | sleep 2 113 | if [ -n "$srv_cmd_line" ] 114 | then 115 | if [ -n "$working_dir" ] 116 | then 117 | if [ -n "$server_pid" ] 118 | then 119 | /usr/local/gpx/bin/Restart -u $srv_username -i $srv_ip -p $srv_port -P $server_pid -w $working_dir -o "$srv_cmd_line" 120 | else 121 | /usr/local/gpx/bin/Restart -u $srv_username -i $srv_ip -p $srv_port -w $working_dir -o "$srv_cmd_line" 122 | fi 123 | else 124 | if [ -n "$server_pid" ] 125 | then 126 | /usr/local/gpx/bin/Restart -u $srv_username -i $srv_ip -p $srv_port -P $server_pid -o "$srv_cmd_line" 127 | else 128 | /usr/local/gpx/bin/Restart -u $srv_username -i $srv_ip -p $srv_port -o "$srv_cmd_line" 129 | fi 130 | fi 131 | fi 132 | fi 133 | break 134 | # Not ready, wait... 135 | else 136 | sleep 5 137 | fi 138 | done >> /dev/null 2>&1 & 139 | 140 | echo "success" 141 | -------------------------------------------------------------------------------- /bin/CreateTemplate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Create a Game/Voice Template 7 | # 8 | # 9 | # Example usage: 10 | # ./CreateTemplate -p /home/gpx/tmp/mygame -i 23 11 | # 12 | tpl_file_path= 13 | tpl_id= 14 | callback_url= 15 | from_steam= 16 | cback="wget -qO-" 17 | debug_on= 18 | 19 | while getopts "p:i:u:s:d:" OPTION 20 | do 21 | case $OPTION in 22 | p) 23 | tpl_file_path=$OPTARG 24 | ;; 25 | i) 26 | tpl_id=$OPTARG 27 | ;; 28 | u) 29 | callback_url=$OPTARG 30 | ;; 31 | s) 32 | from_steam=$OPTARG 33 | ;; 34 | d) 35 | debug_on=$OPTARG 36 | ;; 37 | ?) 38 | exit 39 | ;; 40 | esac 41 | done 42 | 43 | if [[ "$tpl_file_path" == "" || "$tpl_id" == "" ]] 44 | then 45 | echo "CreateTemplate: Required settings were left out. Exiting." 46 | exit 47 | fi 48 | 49 | if [ ! -d "/usr/local/gpx/$tpl_file_path" ] 50 | then 51 | echo "CreateTemplate: That directory was not found (/usr/local/gpx/$tpl_file_path)! Exiting." 52 | exit 53 | fi 54 | 55 | # Setup logging 56 | tpl_log=/usr/local/gpx/logs/templates.log 57 | echo > $tpl_log 58 | 59 | # Update callback if needed 60 | if [ "$callback_url" ] 61 | then 62 | if [ "$debug_on" ]; then echo "CreateTemplate: Connecting to callback URL ($callback_url&do=tpl_status&status=started) ..."; fi 63 | 64 | echo "CreateTemplate: ($(date)) Connecting to callback URL ($callback_url&do=tpl_status&status=started) ..." >> $tpl_log 65 | $cback "$callback_url&do=tpl_status&status=started" >> /dev/null 66 | fi 67 | 68 | if [ "$debug_on" ]; then echo "CreateTemplate: Beginning archive of template directory (/usr/local/gpx/$tpl_file_path) ..."; fi 69 | echo "CreateTemplate: ($(date)) Beginning archive of template directory (/usr/local/gpx/$tpl_file_path) ..." >> $tpl_log 70 | 71 | # Check empty tpl dir 72 | if [ "$(ls -I '^.' /usr/local/gpx/$tpl_file_path)" == "" ] 73 | then 74 | echo "CreateTemplate: Failed: Template directory (/usr/local/gpx/$tpl_file_path) is empty. Exiting." 75 | echo "CreateTemplate: Failed: Template directory (/usr/local/gpx/$tpl_file_path) is empty. Exiting." >> $tpl_log 76 | $cback "$callback_url&do=tpl_status&status=failed" >> /dev/null 77 | exit 78 | fi 79 | 80 | # Begin tar 81 | if [ "$debug_on" ]; then echo "CreateTemplate: Beginning tar (/usr/local/gpx/templates/$tpl_id.tar.gz) on directory (/usr/local/gpx/$tpl_file_path) ..."; fi 82 | 83 | # Move to tmp dir 84 | cd /usr/local/gpx/$tpl_file_path 85 | 86 | # Output tar 87 | #if [ "$debug_on" ] 88 | #then 89 | # tar -cvzf /usr/local/gpx/templates/$tpl_id.tar.gz * 2>&1 90 | # tar_pid=$! 91 | # Send to bg 92 | #else 93 | tar -czf /usr/local/gpx/templates/$tpl_id.tar.gz * >> /dev/null 2>&1 & 94 | tar_pid=$! 95 | #fi 96 | 97 | echo $tar_pid > /usr/local/gpx/templates/.gpx_$tpl_id 98 | 99 | if [ "$BASHPID" ] 100 | then 101 | thispid=$BASHPID 102 | else 103 | thispid=$$ 104 | fi 105 | 106 | if [ "$debug_on" ]; then echo "CreateTemplate: Archive of template directory started (Script PID $thispid, tar PID $tar_pid) ..."; fi 107 | echo "CreateTemplate: ($(date)) Archive of template directory started (Script PID $thispid, tar PID $tar_pid) ..." >> $tpl_log 108 | 109 | # Fork the check for the template creation to be completed 110 | while [ true ] 111 | do 112 | # Check completed based on tar PID 113 | # if [ "$(ps aux | awk '{print $2}' | grep $tar_pid | grep -v grep)" == "" ] 114 | if [ ! -e /proc/$tar_pid ] 115 | then 116 | echo "CreateTemplate: ($(date)) Archive creation completed" >> $tpl_log 117 | 118 | # Done, hit callback 119 | if [ "$callback_url" ] 120 | then 121 | # Get size of template 122 | tpl_size="$(du -sh /usr/local/gpx/templates/$tpl_id.tar.gz | awk '{print $1}')" 123 | 124 | # Run the callback 125 | echo "CreateTemplate: ($(date)) Running callback url for completed" >> $tpl_log 126 | $cback "$callback_url&do=tpl_status&status=complete&size=$tpl_size" >> /dev/null 127 | 128 | # If from steam creation, remove old tmp files if we're in the right /usr/local/gpx/tmp/x dir 129 | if [[ "$from_steam" && "$(pwd | grep /tmp/$tpl_id)" ]] 130 | then 131 | cd 132 | echo "CreateTemplate: ($(date)) Beginning removal of original template files ($tpl_file_path) ..." >> $tpl_log 133 | rm -fr /usr/local/gpx/$tpl_file_path 134 | echo "CreateTemplate: ($(date)) Completed removal of original template files" >> $tpl_log 135 | fi 136 | else 137 | echo "CreateTemplate: ($(date)) NO callback specified, NOT running callback URL." >> $tpl_log 138 | fi 139 | 140 | # Remove any temporary files 141 | rm -fr /usr/local/gpx/tmp/$tpl_id 142 | 143 | # Set permissions so gpx users cannot write/truncate/remove templates 144 | chmod 0640 /usr/local/gpx/templates/$tpl_id.tar.gz 145 | 146 | break 147 | fi 148 | 149 | sleep 3 150 | 151 | # echo "CreateTemplate: ($(date)) Status incomplete, sleeping 3 seconds ..." >> $tpl_log 152 | 153 | done >> /dev/null 2>&1 & 154 | check_tpl_pid=$! 155 | 156 | echo "CreateTemplate: ($(date)) Check while loop forked off to PID: $check_tpl_pid" >> $tpl_log 157 | 158 | > /usr/local/gpx/$tpl_file_path/.gpxtplcheck.pid 159 | echo $check_tpl_pid > /usr/local/gpx/$tpl_file_path/.gpxtplcheck.pid 160 | 161 | echo "success" 162 | -------------------------------------------------------------------------------- /bin/CreateUser: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.11 5 | # 6 | # Queue creation of a GPX system user 7 | # -p passwords should be done with crypt() before giving it here, no plaintext passwords can be used here. 8 | # Example usage: 9 | # 10 | # Create only: 11 | # ./CreateUser -u test1 -p pass123 12 | # 13 | sso_user= 14 | sso_pass= 15 | tmp_dir="/usr/local/gpx/tmp" 16 | queue_dir="/usr/local/gpx/queue" 17 | # rand_str="$(date +%s | sha256sum | base64 | head -c 24 ; echo)" 18 | # rand_str="$([ $RANDOM * 12 ] | sha256sum | head -c 24; echo)" 19 | rand_str="$(echo $RANDOM * 12 | sha256sum | head -c 24; echo)" 20 | 21 | while getopts "u:p:" OPTION 22 | do 23 | case $OPTION in 24 | u) 25 | sso_user=$OPTARG 26 | ;; 27 | p) 28 | sso_pass=$OPTARG 29 | ;; 30 | ?) 31 | exit 32 | ;; 33 | esac 34 | done 35 | 36 | # Check empty 37 | if [[ "$sso_user" == "" || "$sso_pass" == "" ]] 38 | then 39 | echo "Insufficient info given, exiting." 40 | exit 41 | fi 42 | 43 | # Check if user already exists 44 | if [ "$(grep "^gpx$sso_user:" /etc/passwd)" ] 45 | then 46 | echo "That user already exists, exiting." 47 | exit 48 | fi 49 | 50 | # Send to tmp file so manager doesn't read before we're done writing 51 | echo "type: adduser" > $tmp_dir/queue_$rand_str 52 | echo "username: $sso_user" >> $tmp_dir/queue_$rand_str 53 | echo "password: $sso_pass" >> $tmp_dir/queue_$rand_str 54 | 55 | # Move to queue dir 56 | mv $tmp_dir/queue_$rand_str $queue_dir/$rand_str 57 | 58 | echo "Moved $tmp_dir/queue_$rand_str to $queue_dir/$rand_str ..." >> /usr/local/gpx/logs/queue.log 59 | 60 | echo "success" 61 | -------------------------------------------------------------------------------- /bin/DeleteAddon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Delete a Game/Voice Addon 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./DeleteAddon -i fa4990f190de97a37abfab9980e8df8e06bbc291 12 | # 13 | tpl_hash= 14 | 15 | while getopts "i:" OPTION 16 | do 17 | case $OPTION in 18 | i) 19 | tpl_hash=$OPTARG 20 | ;; 21 | ?) 22 | exit 23 | ;; 24 | esac 25 | done 26 | 27 | if [[ "$tpl_hash" == "" ]] 28 | then 29 | echo "DeleteAddon: Required settings were left out. Exiting." 30 | exit 31 | fi 32 | 33 | if [ -f /usr/local/gpx/addons/$tpl_hash.tar.gz ] 34 | then 35 | rm -f /usr/local/gpx/addons/$tpl_hash.tar.gz /usr/local/gpx/addons/.gpx_$tpl_hash 36 | fi 37 | -------------------------------------------------------------------------------- /bin/DeleteDirectory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Delete a gameserver directory (only if empty) 7 | # 8 | # Example usage: 9 | # ./DeleteDirectory -f /path/to/some/dir 10 | # 11 | file= 12 | 13 | while getopts "f:" OPTION 14 | do 15 | case $OPTION in 16 | f) 17 | file=$OPTARG 18 | ;; 19 | ?) 20 | exit 21 | ;; 22 | esac 23 | done 24 | 25 | if [ "$file" == "" ] 26 | then 27 | echo "DeleteDirectory: No filename given! Exiting." 28 | exit 29 | fi 30 | 31 | # Ensure directory exists 32 | if [ -f $file ] 33 | then 34 | # Make sure it's empty 35 | if [ "$(ls $file)" == "" ] 36 | then 37 | rmdir $file 38 | echo "success" 39 | else 40 | echo "DeleteDirectory: That directory isnt empty! Exiting." 41 | exit 42 | fi 43 | # No such directory 44 | else 45 | echo "DeleteDirectory: That directory ($file) doesnt exist! Exiting." 46 | fi 47 | 48 | -------------------------------------------------------------------------------- /bin/DeleteServer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX Pro 4 | # Remote scripts v3.0.15 5 | # 6 | # Delete a Game/Voice Server 7 | # 8 | # Example usage: 9 | # ./DeleteServer -u user123 -i 192.168.10.10 -p 27015 10 | # 11 | srv_username= 12 | srv_ip= 13 | srv_port= 14 | 15 | while getopts "u:i:p:" OPTION 16 | do 17 | case $OPTION in 18 | u) 19 | srv_username=$OPTARG 20 | ;; 21 | i) 22 | srv_ip=$OPTARG 23 | ;; 24 | p) 25 | srv_port=$OPTARG 26 | ;; 27 | ?) 28 | exit 29 | ;; 30 | esac 31 | done 32 | 33 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 34 | then 35 | echo "DeleteServer: Required settings were left out ($srv_username,$srv_ip,$srv_port) . Exiting." 36 | exit 37 | fi 38 | 39 | if [ -d /usr/local/gpx/users/$srv_username/$srv_ip\.$srv_port ] 40 | then 41 | # Make sure server is stopped 42 | /usr/local/gpx/bin/Stop -u $srv_username -i $srv_ip -p $srv_port >> /dev/null 2>&1 43 | 44 | # Delete all contents 45 | rm -fr /usr/local/gpx/users/$srv_username/$srv_ip\.$srv_port >> /dev/null 2>&1 & 46 | fi 47 | 48 | echo "success" 49 | -------------------------------------------------------------------------------- /bin/DeleteTemplate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Delete a Game/Voice Template 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./DeleteTemplate -i 24 12 | # 13 | archive_id= 14 | 15 | while getopts "i:" OPTION 16 | do 17 | case $OPTION in 18 | i) 19 | archive_id=$OPTARG 20 | ;; 21 | ?) 22 | exit 23 | ;; 24 | esac 25 | done 26 | 27 | if [ "$archive_id" == "" ] 28 | then 29 | echo "DeleteTemplate: Required settings were left out. Exiting." 30 | exit 31 | fi 32 | 33 | # Home Dir 34 | tpl_tmp=/usr/local/gpx/tmp/$archive_id 35 | 36 | # Kill any related processes (game installer PID) 37 | if [ -f $tpl_tmp/.gpxpid ] 38 | then 39 | game_install_pid=`cat $tpl_tmp/.gpxpid` 40 | game_child=$(ps -ef | grep "$game_install_pid" | grep -v grep | awk '{print $2}' | grep -v "$game_install_pid") 41 | 42 | # Kill game child processes first 43 | if [ "`ps aux | grep "$game_child" | grep -v grep`" ] 44 | then 45 | for child_pid in $(ps -ef | grep "$game_child" | grep -v grep | awk '{print $2}') 46 | do 47 | if [ "$child_pid" ]; then kill -9 $child_pid; fi 48 | done 49 | fi 50 | 51 | # Kill game installer and it's child processes 52 | if [ "$(ps aux | grep "$game_install_pid" | grep -v grep)" ] 53 | then 54 | for srv_pid in $(ps -ef | grep "$game_install_pid" | grep -v grep | awk '{print $2}' | sort -r) 55 | do 56 | if [[ "$srv_pid" && -e /proc/$srv_pid ]]; then kill -9 $srv_pid; fi 57 | done 58 | fi 59 | fi 60 | 61 | # Watcher PID 62 | if [ -f $tpl_tmp/.gpxinstall.pid ] 63 | then 64 | watcher_pid="$(cat $tpl_tmp/.gpxinstall.pid)" 65 | 66 | # Kill watcher 67 | if [[ "$watcher_pid" && -e /proc/$watcher_pid ]]; then kill -9 $watcher_pid; fi 68 | fi 69 | 70 | 71 | # Kill any Steam processes 72 | if [ -f $tpl_tmp/.gpxsteam.pid ] 73 | then 74 | # Kill 'steaminstall.sh' process 75 | if [ -f $tpl_tmp/.gpxtplcheck.pid ] 76 | then 77 | ck_pid="$(cat $tpl_tmp/.gpxtplcheck.pid)" 78 | if [[ "$ck_pid" && -e /proc/$ck_pid ]]; then kill -9 $ck_pid; fi 79 | fi 80 | 81 | # Kill './steam -command update ...' process 82 | stm_pid="$(cat $tpl_tmp/.gpxsteam.pid)" 83 | if [[ "$stm_pid" && -e /proc/$stm_pid ]]; then kill -9 $stm_pid; fi 84 | fi 85 | 86 | # Remove Template tarball 87 | if [[ -f /usr/local/gpx/templates/$archive_id.tar.gz || -d /usr/local/gpx/tmp/$archive_id ]] 88 | then 89 | rm -fr /usr/local/gpx/templates/$archive_id.tar.gz /usr/local/gpx/templates/.gpx_$archive_id /usr/local/gpx/tmp/$archive_id/ >> /dev/null 2>&1 & 90 | fi 91 | 92 | echo "success" 93 | -------------------------------------------------------------------------------- /bin/DeleteUser: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Queue deletion of a GPX system user 7 | # 8 | # Example usage: 9 | # 10 | # ./DeleteUser -u test1 11 | # 12 | sso_user= 13 | tmp_dir="/usr/local/gpx/tmp" 14 | queue_dir="/usr/local/gpx/queue" 15 | rand_str="$(date +%s | sha256sum | base64 | head -c 24 ; echo)" 16 | 17 | while getopts "u:" OPTION 18 | do 19 | case $OPTION in 20 | u) 21 | sso_user=$OPTARG 22 | ;; 23 | ?) 24 | exit 25 | ;; 26 | esac 27 | done 28 | 29 | # Check empty 30 | if [ "$sso_user" == "" ] 31 | then 32 | echo "No username given, exiting." 33 | exit 34 | fi 35 | 36 | # Check if user exists at all 37 | if [ "$(grep "^gpx$sso_user:" /etc/passwd)" == "" ] 38 | then 39 | echo "That user does not exist, exiting." 40 | exit 41 | fi 42 | 43 | # Send to tmp file so manager doesn't read before we're done writing 44 | echo "type: deleteuser" > $tmp_dir/queue_$rand_str 45 | echo "username: $sso_user" >> $tmp_dir/queue_$rand_str 46 | 47 | # Move to queue dir 48 | mv $tmp_dir/queue_$rand_str $queue_dir/$rand_str 49 | 50 | echo "success" 51 | -------------------------------------------------------------------------------- /bin/FileContent: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Get contents of a file 7 | # 8 | # Example usage: 9 | # ./FileContent -f /path/to/some/file.txt 10 | # 11 | file= 12 | 13 | while getopts "f:" OPTION 14 | do 15 | case $OPTION in 16 | f) 17 | file=$OPTARG 18 | ;; 19 | ?) 20 | exit 21 | ;; 22 | esac 23 | done 24 | 25 | if [ "$file" == "" ] 26 | then 27 | echo "FileContent: No filename given! Exiting." 28 | exit 29 | fi 30 | 31 | cat $file 32 | -------------------------------------------------------------------------------- /bin/FileDelete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Delete a gameserver file 7 | # 8 | # Example usage: 9 | # ./FileDelete -f /path/to/some/file.txt 10 | # 11 | file= 12 | 13 | while getopts "f:" OPTION 14 | do 15 | case $OPTION in 16 | f) 17 | file=$OPTARG 18 | ;; 19 | ?) 20 | exit 21 | ;; 22 | esac 23 | done 24 | 25 | if [ "$file" == "" ] 26 | then 27 | echo "FileDelete: No filename given! Exiting." 28 | exit 29 | fi 30 | 31 | # File exists 32 | if [ -f $file ] 33 | then 34 | rm -f $file 35 | echo "success" 36 | # No such file 37 | else 38 | echo "FileDelete: That file ($file) doesnt exist! Exiting." 39 | fi 40 | 41 | -------------------------------------------------------------------------------- /bin/FileSave: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Save new contents to a file 7 | # 8 | # Example usage: 9 | # ./FileSave -f /path/to/some/file.txt -c "lots\nof\n\n\ncontents\nhere" 10 | # 11 | file= 12 | content= 13 | 14 | while getopts "f:c:" OPTION 15 | do 16 | case $OPTION in 17 | f) 18 | file=$OPTARG 19 | ;; 20 | c) 21 | content=$OPTARG 22 | ;; 23 | ?) 24 | exit 25 | ;; 26 | esac 27 | done 28 | 29 | if [ "$file" == "" ] 30 | then 31 | echo "FileSave: No filename given! Exiting." 32 | exit 33 | fi 34 | 35 | if [ ! -f $file ] 36 | then 37 | touch $file 38 | fi 39 | 40 | # Try and strip slashes on quotes 41 | content=$(echo $content | sed 's/\\"/"/g') 42 | 43 | echo -e $content > $file 44 | 45 | echo "success" 46 | -------------------------------------------------------------------------------- /bin/FileType: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Get a file type 7 | # 8 | # Example usage: 9 | # 10 | # ./FileType -d /path/to/accounts/user123/game/192.168.10.10\:27015/ -f cstrike/cfg/server.cfg 11 | # 12 | srv_directory= 13 | srv_filename= 14 | 15 | while getopts "d:f:" OPTION 16 | do 17 | case $OPTION in 18 | d) 19 | srv_directory=$OPTARG 20 | ;; 21 | f) 22 | srv_filename=$OPTARG 23 | ;; 24 | ?) 25 | exit 26 | ;; 27 | esac 28 | done 29 | 30 | if [[ "$srv_directory" == "" || "$srv_filename" == "" ]] 31 | then 32 | echo "FileType: Required options were left out" 33 | exit 34 | fi 35 | 36 | if [ ! -d "$srv_directory" ] 37 | then 38 | echo "FileType: The specified directory does not exist" 39 | exit 40 | fi 41 | 42 | if [ ! -f "$srv_directory/$srv_filename" ] 43 | then 44 | echo "FileType: The specified filename does not exist" 45 | exit 46 | fi 47 | 48 | file $srv_directory/$srv_filename 49 | -------------------------------------------------------------------------------- /bin/GPXManager: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX Remote 4 | # Manager for user creation 5 | # 6 | # Written by Ryan Gehrig 7 | ## 8 | gpxuser="$(grep -v '^#' /usr/local/gpx/etc/config.cfg | grep 'username: ' | awk -F': ' '{print $2}')" 9 | queuepath="/usr/local/gpx/queue" 10 | queuelog="/usr/local/gpx/logs/queue.log" 11 | tmp_dir="/usr/local/gpx/tmp" 12 | echo "$(date) $(hostname) Starting GPXManager ..." >> $queuelog 13 | 14 | # Sanity check 15 | if [ "$gpxuser" == "" ]; then 16 | echo "$(date) $(hostname) No gpx user found. Exiting." >> $queuelog 17 | exit 18 | elif [ "$UID" -ne "0" ]; then 19 | echo "ERROR: You must be the root user to run this script. Exiting." 20 | exit 21 | fi 22 | 23 | # Check if already running PID 24 | if [ -f /usr/local/gpx/gpxmanager.pid ]; then 25 | cur_pid=$(cat /usr/local/gpx/gpxmanager.pid) 26 | if [[ "$cur_pid" && -e /proc/$cur_pid ]]; then 27 | echo "GPXManager is already running in another process ($cur_pid)! Please stop it and try again." 28 | exit 29 | fi 30 | fi 31 | 32 | # Fix ourself 33 | chown root: /usr/local/gpx/bin/GPXManager 34 | chmod 0700 /usr/local/gpx/bin/GPXManager 35 | 36 | COUNTER=0 37 | while [ true ] 38 | do 39 | #for acctfile in $(ls -a $queuepath) 40 | for acctfile in $queuepath/* 41 | do 42 | if [[ "$acctfile" != "." && "$acctfile" != ".." && "$acctfile" != "$queuepath/*" ]] 43 | then 44 | # Get account info (pass needs to be given with crypt(), no plaintext) 45 | #gpxnew_type="$(grep 'type: ' $queuepath/$acctfile | awk -F': ' '{print $2}')" 46 | #gpxnew_user="$(grep 'username: ' $queuepath/$acctfile | awk -F': ' '{print $2}')" 47 | #gpxnew_pass="$(grep 'password: ' $queuepath/$acctfile | awk -F': ' '{print $2}')" 48 | #gpxnew_user_changeto="$(grep 'newusername: ' $queuepath/$acctfile | awk -F': ' '{print $2}')" 49 | gpxnew_type="$(grep 'type: ' $acctfile | awk -F': ' '{print $2}')" 50 | gpxnew_user="$(grep 'username: ' $acctfile | awk -F': ' '{print $2}')" 51 | gpxnew_pass="$(grep 'password: ' $acctfile | awk -F': ' '{print $2}')" 52 | gpxnew_user_changeto="$(grep 'newusername: ' $acctfile | awk -F': ' '{print $2}')" 53 | 54 | # Add new user 55 | if [ "$gpxnew_type" == "adduser" ] 56 | then 57 | # Double check 58 | if [ "$gpxnew_user" == "" ] 59 | then 60 | echo "$(date) $(hostname) Username: Invalid or empty username ($gpxnew_user) given. Exiting." >> $queuelog 61 | break 62 | elif [ "$gpxnew_pass" == "" ] 63 | then 64 | echo "$(date) $(hostname) Password: Invalid or empty password ($gpxnew_pass) given. Exiting." >> $queuelog 65 | break 66 | fi 67 | 68 | # Logging 69 | echo "$(date) $(hostname): Adding user $gpxnew_user ..." >> $queuelog 70 | 71 | # Create the user (with 'gpx' prefixed) 72 | useradd -m -p "$gpxnew_pass" -d /usr/local/gpx/users/$gpxnew_user -s /bin/bash -c "GamePanelX User" gpx$gpxnew_user 73 | sleep 1 74 | 75 | # Add to GPX group so they can execute scripts 76 | gpasswd -a gpx$gpxnew_user $gpxuser 77 | 78 | # Security 79 | gpasswd -d gpx$gpxnew_user wheel 2>&1 >> /dev/null 80 | # chmod 600 /usr/local/gpx/users/$gpxnew_user -R 81 | 82 | # Change Password 83 | elif [ "$gpxnew_type" == "changepass" ] 84 | then 85 | # Double check 86 | if [ "$gpxnew_user" == "" ] 87 | then 88 | echo "$(date) $(hostname) Username: Invalid or empty username ($gpxnew_user) given. Exiting." >> $queuelog 89 | break 90 | elif [ "$gpxnew_pass" == "" ] 91 | then 92 | echo "$(date) $(hostname) Password: Invalid or empty password ($gpxnew_pass) given. Exiting." >> $queuelog 93 | break 94 | fi 95 | 96 | # Logging 97 | echo "$(date) $(hostname) Changing password for $gpxnew_user ..." >> $queuelog 98 | 99 | # Change the password 100 | cat $tmp_dir/$gpxnew_user | chpasswd -e 101 | rm -f $tmp_dir/$gpxnew_user 102 | 103 | # Change Username 104 | elif [ "$gpxnew_type" == "changeusername" ] 105 | then 106 | # Double check 107 | if [ "$gpxnew_user" == "" ] 108 | then 109 | echo "$(date) $(hostname) Username: Invalid or empty username ($gpxnew_user) given. Exiting." >> $queuelog 110 | break 111 | elif [ "$gpxnew_user_changeto" == "" ] 112 | then 113 | echo "$(date) $(hostname) New Username: Invalid or empty new username ($gpxnew_user_changeto) given. Exiting." >> $queuelog 114 | break 115 | fi 116 | 117 | # Logging 118 | echo "$(date) $(hostname): Changing username from $gpxnew_user to $gpxnew_user_changeto ..." >> $queuelog 119 | 120 | # Check existing dir 121 | if [ -d /usr/local/gpx/users/$gpxnew_user_changeto ] 122 | then 123 | echo "$(date) $(hostname): Username change: Removing existing directory /usr/local/gpx/users/$gpxnew_user_changeto ..." >> $queuelog 124 | rm -fr /usr/local/gpx/users/$gpxnew_user_changeto 125 | # Check existing user 126 | elif [ "$(grep -E "^gpx$gpxnew_user_changeto:" /etc/passwd)" ] 127 | then 128 | echo "$(date) $(hostname): Username change: User $gpxnew_user_changeto already exists! Exiting." >> $queuelog 129 | exit 130 | fi 131 | 132 | # Change the username 133 | usermod -l gpx$gpxnew_user_changeto gpx$gpxnew_user 134 | mv /usr/local/gpx/users/$gpxnew_user /usr/local/gpx/users/$gpxnew_user_changeto 135 | 136 | # Delete User 137 | elif [ "$gpxnew_type" == "deleteuser" ] 138 | then 139 | # Double check 140 | if [ "$gpxnew_user" == "" ] 141 | then 142 | echo "$(date) $(hostname) Username: Invalid or empty username ($gpxnew_user) given. Exiting." >> $queuelog 143 | break 144 | fi 145 | 146 | # Logging 147 | echo "$(date) $(hostname): Deleting user $gpxnew_user ..." >> $queuelog 148 | 149 | # Delete the user 150 | userdel gpx$gpxnew_user >> /dev/null 2>&1 151 | sleep 1 152 | 153 | # Stop any processes under this user 154 | usrpid= 155 | for usrpid in $(ps -ef | awk '{print $1,$2}' | grep -E "^$gpxnew_user [0-9]+" | awk '{print $2}') 156 | do 157 | if [[ "$usrpid" && -e /proc/$usrpid ]] 158 | then 159 | kill -9 $usrpid 160 | fi 161 | done 162 | 163 | # Stop any processes under this user ID 164 | usrpid= 165 | usr_userid="$(id -u $gpxnew_user)" 166 | for usrpid in $(ps -ef | awk '{print $1,$2}' | grep -E "^$usr_userid [0-9]+" | awk '{print $2}') 167 | do 168 | if [[ "$usrpid" && -e /proc/$usrpid ]] 169 | then 170 | kill -9 $usrpid 171 | fi 172 | done 173 | 174 | # Remove user homedir 175 | if [[ "$gpxnew_user" && -d /usr/local/gpx/users/$gpxnew_user ]] 176 | then 177 | rm -fr /usr/local/gpx/users/$gpxnew_user 178 | fi 179 | 180 | # Change exe permissions 181 | elif [ "$gpxnew_type" == "exeperms" ] 182 | then 183 | # Comma separated list of executables 184 | # gpxnew_files="$(grep 'files: ' $queuepath/$acctfile | awk -F': ' '{print $2}' | sed 's/,/\n/g')" 185 | gpxnew_files="$(grep 'files: ' $acctfile | awk -F': ' '{print $2}' | sed 's/,/\n/g')" 186 | 187 | if [ "$gpxnew_files" == "" ] 188 | then 189 | echo "File: Invalid or empty file ($gpxnew_file) given. Exiting." 190 | break 191 | fi 192 | 193 | # Loop through exe files 194 | for exename in $gpxnew_files 195 | do 196 | # Read only, user executable. 197 | if [ -f $exename ] 198 | then 199 | chmod 0540 $exename 200 | fi 201 | done 202 | # Something else... 203 | else 204 | echo "$(date) $(hostname) Unknown request type ($gpxnew_type) in file $acctfile. Exiting." >> $queuelog 205 | fi 206 | 207 | # Remove queue file 208 | # rm -f $queuepath/$acctfile 209 | rm -f $acctfile 210 | fi 211 | done 212 | midloop_pid=$! 213 | 214 | # Report load info every 3 minutes 215 | let COUNTER=COUNTER+1 216 | rem=$(( $COUNTER % 60 )) 217 | if [ $rem -eq 0 ] 218 | then 219 | # Get current load info 220 | loadavg=$(uptime|awk '{print $10}' | tr ',' ' ') 221 | 222 | # Calculate actual free memory 223 | mem_total="$(grep '^MemTotal' /proc/meminfo | awk '{print $2}')" 224 | mem_given_free="$(grep '^MemFree' /proc/meminfo | awk '{print $2}')" 225 | mem_buffers="$(grep '^Buffers' /proc/meminfo | awk '{print $2}')" 226 | mem_cached="$(grep '^Cached' /proc/meminfo | awk '{print $2}')" 227 | mem_free="$(($mem_given_free + $mem_buffers + $mem_cached))" 228 | 229 | # Report load information to the Master 230 | master_cback="$(grep -v '^#' /usr/local/gpx/etc/config.cfg | grep 'master_callback: ' | awk -F': ' '{print $2}')" 231 | 232 | if [ "$master_cback" ] 233 | then 234 | master_cback=$master_cback"&do=remote_load&ip=$main_ip&freemem=$mem_free&totalmem=$mem_total&loadavg=$loadavg" 235 | main_ip="$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n1)" 236 | 237 | # echo "$(date) $(hostname) Running callback to $master_cback ..." >> $queuelog 238 | wget -qO- "$master_cback" >> /dev/null 2>&1 239 | fi 240 | fi 241 | 242 | # Sleep 3 secs 243 | sleep 3 244 | done >> /dev/null 2>&1 & 245 | gpxman_pid=$! 246 | 247 | # Create PID for this script 248 | touch /usr/local/gpx/gpxmanager.pid 249 | echo $gpxman_pid > /usr/local/gpx/gpxmanager.pid 250 | chown root: /usr/local/gpx/gpxmanager.pid 251 | chmod 600 /usr/local/gpx/gpxmanager.pid 252 | -------------------------------------------------------------------------------- /bin/InstallAddon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Install a Game/Voice server Addon 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./InstallAddon -u user123 -t game -i 192.168.10.10 -p 27015 -x fa4990f190de97a37abfab9980e8df8e06bbc291 -a / 12 | # 13 | srv_username= 14 | srv_type= 15 | srv_ip= 16 | srv_port= 17 | tpl_hash= 18 | install_target= 19 | 20 | while getopts "u:t:i:p:x:a:" OPTION 21 | do 22 | case $OPTION in 23 | u) 24 | srv_username=$OPTARG 25 | ;; 26 | t) 27 | srv_type=$OPTARG 28 | ;; 29 | i) 30 | srv_ip=$OPTARG 31 | ;; 32 | p) 33 | srv_port=$OPTARG 34 | ;; 35 | x) 36 | tpl_hash=$OPTARG 37 | ;; 38 | a) 39 | install_target=$OPTARG 40 | ;; 41 | ?) 42 | exit 43 | ;; 44 | esac 45 | done 46 | 47 | if [[ "$srv_username" == "" || "$srv_type" == "" || "$srv_ip" == "" || "$srv_port" == "" || "$tpl_hash" == "" || "$install_target" == "" ]] 48 | then 49 | echo "InstallAddon: Required settings were left out. Exiting." 50 | exit 51 | fi 52 | 53 | nice -n 19 tar -zxf /usr/local/gpx/addons/$tpl_hash.tar.gz -C /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/$install_target/ >> /dev/null 2>&1 & 54 | pid=$! 55 | echo $pid > /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/.gpx_addon 56 | 57 | echo "success" 58 | -------------------------------------------------------------------------------- /bin/InstallSupportedServer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Install a Supported Game/Voice server 7 | # 8 | # -i: Archive ID 9 | # -f: Installation binary to use 10 | # -c: Complete command(s) to be run for the install. Use double-quotes around these, and use semicolons to run multiple commands. 11 | # -s: Steam Game/Mod name. Examples: "cstrike", "Counter-Strike: Source", etc. 12 | # 13 | # Example typical usage: 14 | # ./InstallSupportedServer -i 22 -f someinstaller.sh -c "./installscript --commands go --here" 15 | # 16 | # Example Steam usage: 17 | # ./InstallSupportedServer -i 22 -s "Counter-Strike Source" 18 | # 19 | archiveid= 20 | install_file= 21 | install_cmd= 22 | steam_game= 23 | admin_email= 24 | 25 | while getopts "i:f:c:s:e:" OPTION 26 | do 27 | case $OPTION in 28 | i) 29 | archiveid=$OPTARG 30 | ;; 31 | f) 32 | install_file=$OPTARG 33 | ;; 34 | c) 35 | install_cmd=$OPTARG 36 | ;; 37 | s) 38 | steam_game=$OPTARG 39 | ;; 40 | e) 41 | admin_email=$OPTARG 42 | ;; 43 | ?) 44 | exit 45 | ;; 46 | esac 47 | done 48 | 49 | if [ "$archiveid" == "" ] 50 | then 51 | echo "InstallSupportedServer: No archive ID provided. Exiting." 52 | exit 53 | fi 54 | 55 | # Normal Games 56 | if [ "$steam_game" == "" ] 57 | then 58 | if [[ "$install_file" == "" || "$install_cmd" == "" ]] 59 | then 60 | echo "InstallSupportedServer: Required settings were left out. Exiting." 61 | exit 62 | fi 63 | 64 | if [ ! -f "/usr/local/gpx/uploads/$install_file" ] 65 | then 66 | echo "InstallSupportedServer: The installer file '/usr/local/gpx/uploads/$install_file' does not exist. Exiting." 67 | exit 68 | fi 69 | # Steam Games 70 | else 71 | # Check for hldsupdatetool 72 | if [ ! -f "/usr/local/gpx/uploads/hldsupdatetool.bin" ] 73 | then 74 | echo "InstallSupportedServer: The 'hldsupdatetool.bin' file must be placed in /usr/local/gpx/uploads! Exiting." 75 | exit 76 | fi 77 | fi 78 | 79 | mkdir -p /usr/local/gpx/tmp/$archiveid/ 80 | 81 | 82 | if [ "$steam_game" == "" ] 83 | then 84 | echo y | cp /usr/local/gpx/uploads/$install_file /usr/local/gpx/tmp/$archiveid/ 85 | fi 86 | 87 | 88 | cd /usr/local/gpx/tmp/$archiveid/ 89 | 90 | # Steam Games 91 | if [ "$steam_game" ] 92 | then 93 | # Check for SteamInstall script 94 | if [ ! -f /usr/local/gpx/bin/SteamInstall ] 95 | then 96 | echo "ERROR: No SteamInstall script found! Are you running Remote >= v3.0? Exiting." 97 | exit 98 | fi 99 | 100 | if [ "$admin_email" ] 101 | then 102 | /usr/local/gpx/bin/SteamInstall -e "$admin_email" -m "$steam_game" >> /dev/null 2>&1 & 103 | pid=$! 104 | else 105 | /usr/local/gpx/bin/SteamInstall -m "$steam_game" >> /dev/null 2>&1 & 106 | pid=$! 107 | fi 108 | 109 | echo $pid > /usr/local/gpx/tmp/$archiveid/.gpxpid 110 | # Other Games 111 | else 112 | 113 | # Setup installer shell script 114 | echo "#!/bin/bash" > .gpxinstall 115 | echo -e $install_cmd >> .gpxinstall 116 | chmod u+x .gpxinstall 117 | 118 | # Start creation process 119 | nice -n 19 ./.gpxinstall >> /dev/null 2>&1 & 120 | pid=$! 121 | echo $pid > /usr/local/gpx/tmp/$archiveid/.gpxpid 122 | fi 123 | 124 | sleep 2 125 | 126 | # Start checking if PID completed 127 | while true 128 | do 129 | # Completed; create template 130 | if [ "`ps aux | grep $pid | grep -v grep`" == "" ] 131 | then 132 | sleep 1 133 | 134 | # Check for a successful steam install 135 | if [ "`grep '100.00%' .gpxinstall.log | grep downloading`" ] 136 | then 137 | echo "1" > /usr/local/gpx/templates/$archiveid/.gpxsteamresult 138 | else 139 | echo "0" > /usr/local/gpx/templates/$archiveid/.gpxsteamresult 140 | fi 141 | 142 | /usr/local/gpx/bin/CreateTemplate -p /usr/local/gpx/tmp/$archiveid/ -i $archiveid 143 | break 144 | fi 145 | sleep 5 146 | done >> /dev/null 2>&1 & 147 | whilepid=$! 148 | echo $whilepid > /usr/local/gpx/tmp/$archiveid/.gpxinstall.pid 149 | 150 | # Output 151 | echo "success" 152 | -------------------------------------------------------------------------------- /bin/MoveServerLocal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Move a Game/Voice Server locally to a new User/IP/Port 7 | # 8 | # Example usage: 9 | # ./MoveServerLocal -u user123 -i 192.168.10.10 -p 27015 -U user123 -I 192.168.10.11 -P 27015 10 | # 11 | srv_username= 12 | srv_ip= 13 | srv_port= 14 | srv_new_user= 15 | srv_new_ip= 16 | srv_new_port= 17 | 18 | while getopts "u:i:p:U:I:P:" OPTION 19 | do 20 | case $OPTION in 21 | u) 22 | srv_username=$OPTARG 23 | ;; 24 | i) 25 | srv_ip=$OPTARG 26 | ;; 27 | p) 28 | srv_port=$OPTARG 29 | ;; 30 | U) 31 | srv_new_user=$OPTARG 32 | ;; 33 | I) 34 | srv_new_ip=$OPTARG 35 | ;; 36 | P) 37 | srv_new_port=$OPTARG 38 | ;; 39 | ?) 40 | exit 41 | ;; 42 | esac 43 | done 44 | 45 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" || "$srv_new_user" == "" || "$srv_new_ip" == "" || "$srv_new_port" == "" ]] 46 | then 47 | echo "MoveServerLocal: Required settings were left out. Exiting." 48 | exit 49 | fi 50 | 51 | cur_dir="/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port" 52 | new_dir="/usr/local/gpx/users/$srv_new_user" 53 | 54 | if [ -d $cur_dir ] 55 | then 56 | # Create new dir if needed 57 | if [ ! -d $new_dir ] 58 | then 59 | mkdir -p $new_dir 60 | fi 61 | 62 | # Run the move 63 | mv $cur_dir $new_dir/$srv_new_ip:$srv_new_port >> /dev/null 2>&1 & 64 | else 65 | echo "Server directory ($cur_dir) doesnt exist! Exiting." 66 | exit 67 | fi 68 | 69 | echo "success" 70 | -------------------------------------------------------------------------------- /bin/RemoveAddon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Uninstall a Game/Voice server Addon 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./RemoveAddon -u user123 -t game -i 192.168.10.10 -p 27015 -x fa4990f190de97a37abfab9980e8df8e06bbc291 -a / -d cfg/script.cfg test.cfg something/else/script.txt 12 | # 13 | srv_username= 14 | srv_type= 15 | srv_ip= 16 | srv_port= 17 | tpl_hash= 18 | install_target= 19 | remove_dirs= 20 | 21 | while getopts "u:t:i:p:x:a:d:" OPTION 22 | do 23 | case $OPTION in 24 | u) 25 | srv_username=$OPTARG 26 | ;; 27 | t) 28 | srv_type=$OPTARG 29 | ;; 30 | i) 31 | srv_ip=$OPTARG 32 | ;; 33 | p) 34 | srv_port=$OPTARG 35 | ;; 36 | x) 37 | tpl_hash=$OPTARG 38 | ;; 39 | a) 40 | install_target=$OPTARG 41 | ;; 42 | d) 43 | remove_dirs=$OPTARG 44 | ;; 45 | ?) 46 | exit 47 | ;; 48 | esac 49 | done 50 | 51 | if [[ "$srv_username" == "" || "$srv_type" == "" || "$srv_ip" == "" || "$srv_port" == "" || "$tpl_hash" == "" || "$install_target" == "" ]] 52 | then 53 | echo "RemoveAddon: Required settings were left out. Exiting." 54 | exit 55 | fi 56 | 57 | for file in `tar --list --file=/usr/local/gpx/addons/$tpl_hash.tar.gz | sort` 58 | do 59 | rm -f /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/$install_target/$file 60 | done 61 | 62 | if [ -n "$remove_dirs" ] 63 | then 64 | for dir in `echo $remove_dirs` 65 | do 66 | rm -fr /usr/local/gpx/users/$srv_username/$srv_type/$srv_ip\.$srv_port/$install_target/$dir 67 | done 68 | fi 69 | 70 | echo "success" 71 | -------------------------------------------------------------------------------- /bin/Restart: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Restart Game/Voice Servers 7 | # 8 | # -u: Client's gpx username 9 | # -i: Server IP Address (x.x.x.x) 10 | # -p: Server Port 11 | # -P: Server PID filename (optional). Use local paths if needed, such as "some/dir/run.pid", not "/home/me/dir/run.pid" 12 | # -w: Server working directory to CD into for the server startup. Again, local paths only. 13 | # -s: Unsuspend Server (optional). Can be "yes" to unsuspend, or left empty to not. 14 | # -o: Complete Command-Line to run. Example: "./srcds_run -game cstrike +ip x.x.x.x ..." 15 | # -c: Taskset CPU number/core to use. (optional) 16 | # 17 | # Example usage: 18 | # ./Restart -u user123 -i 192.168.10.10 -p 27015 -w orangebox -o './srcds_run -game cstrike +ip 192.168.10.10 -port 27015 +map de_dust2 +maxplayers 12' 19 | # 20 | srv_username= 21 | srv_ip= 22 | srv_port= 23 | srv_pidfile= 24 | working_dir= 25 | unsuspend_srv= 26 | srv_cmd_line= 27 | taskset_cpu= 28 | gpx_logging= 29 | 30 | while getopts "u:i:p:P:w:s:o:c:l:" OPTION 31 | do 32 | case $OPTION in 33 | u) 34 | srv_username=$OPTARG 35 | ;; 36 | i) 37 | srv_ip=$OPTARG 38 | ;; 39 | p) 40 | srv_port=$OPTARG 41 | ;; 42 | P) 43 | srv_pidfile=$OPTARG 44 | ;; 45 | w) 46 | working_dir=$OPTARG 47 | ;; 48 | s) 49 | unsuspend_srv=$OPTARG 50 | ;; 51 | o) 52 | srv_cmd_line=$OPTARG 53 | ;; 54 | c) 55 | taskset_cpu=$OPTARG 56 | ;; 57 | l) 58 | gpx_logging=$OPTARG 59 | ;; 60 | ?) 61 | exit 62 | ;; 63 | esac 64 | done 65 | 66 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 67 | then 68 | echo "Restart: Required settings were left out. Exiting." 69 | exit 70 | fi 71 | 72 | # Check for homedir 73 | usrdir=/usr/local/gpx/users/$srv_username 74 | gpxdir=$usrdir/$srv_ip.$srv_port 75 | serverlog=/usr/local/gpx/logs/servers.log 76 | 77 | # Log this 78 | echo "$(date) $(hostname) Restart: Restarting $srv_ip.$srv_port for user $srv_username ..." >> $serverlog 79 | 80 | if [ ! -d $gpxdir ] 81 | then 82 | echo "Restart: Game directory ($gpxdir) doesnt exist! Exiting." 83 | echo "$(date) $(hostname) Restart: Game directory ($gpxdir) doesnt exist! Exiting." >> $serverlog 84 | exit 85 | fi 86 | 87 | 88 | if [ "$unsuspend_srv" == "yes" ] 89 | then 90 | if [ -d /usr/local/gpx/users/$srv_username/.$srv_ip\.$srv_port/ ] 91 | then 92 | echo "$(date) $(hostname) Restart: Unsuspending $srv_ip.$srv_port for user $srv_username ..." >> $serverlog 93 | echo y | mv /usr/local/gpx/users/$srv_username/.$srv_ip\.$srv_port $gpxdir 94 | else 95 | echo "$(date) $(hostname) Restart: Unsuspend: Directory not found, NOT unsuspending." >> $serverlog 96 | fi 97 | fi 98 | 99 | if [ -f $gpxdir/.gpxpid ] 100 | then 101 | # Use the proper current script PID 102 | if [ "$BASHPID" ] 103 | then 104 | script_pid=$BASHPID 105 | else 106 | script_pid=$$ 107 | fi 108 | 109 | # Stop server if running 110 | parent_pid=$(cat $gpxdir/.gpxpid) 111 | # if [[ "$parent_pid" && "$(ps -ef | awk '{print $2}' | grep \"$parent_pid\" | grep -v grep)" ]] 112 | if [[ "$parent_pid" && -e /proc/$parent_pid ]] 113 | then 114 | /usr/local/gpx/bin/Stop -u $srv_username -i $srv_ip -p $srv_port -r $script_pid >> /dev/null 115 | sleep 1 116 | fi 117 | fi 118 | 119 | while true 120 | do 121 | parent_pid=$(cat $gpxdir/.gpxpid) 122 | 123 | # Not running currently 124 | # if [ "$(ps -ef | awk '{print $2}' | grep \"$parent_pid\" | grep -v grep)" == "" ] 125 | if [[ "$parent_pid" && ! -e /proc/$parent_pid || "$parent_pid" == "" ]] 126 | then 127 | if [ -n "$working_dir" ] 128 | then 129 | if [ -d $gpxdir/$working_dir/ ] 130 | then 131 | cd $gpxdir/$working_dir/ 132 | else 133 | echo "Restart: Working directory \"$working_dir\" specified, but does not exist! Exiting." 134 | echo "$(date) $(hostname) Restart: Working directory \"$working_dir\" specified, but does not exist! Exiting." >> $serverlog 135 | #cd $gpxdir/ 136 | 137 | exit 138 | fi 139 | else 140 | cd $gpxdir/ 141 | fi 142 | 143 | # Taskset Support 144 | if [ "$taskset_cpu" ] 145 | then 146 | hash taskset 2>&- || { echo >&2 "Taskset is not available on this system. Exiting."; exit; } 147 | # taskset -c $taskset_cpu $srv_cmd_line >> /dev/null 2>&1 & 148 | # pid=$! 149 | srv_cmd_line="taskset -c $taskset_cpu "$srv_cmd_line 150 | else 151 | gpx_logging="1" # for now, remove later 152 | 153 | # !! Start Server 154 | if [ "$gpx_logging" ] 155 | then 156 | # No GNU Screen 157 | if [ "$(which screen 2>&1 | grep 'no screen in')" ] 158 | then 159 | echo "$(date) $(hostname) Restart: Warning: No GNU Screen found! Please install screen to use all server features." >> $serverlog 160 | 161 | $srv_cmd_line 2>&1 > $gpxdir/.gpxsrv.log & 162 | pid=$! 163 | # Screen support 164 | else 165 | # Clean up first 166 | screen -wipe 2>&1 >> /dev/null 167 | 168 | # Start screen 169 | screen -d -m -S "$srv_ip.$srv_port" $srv_cmd_line 2>&1 >> $serverlog 170 | screen_pid="$(screen -list | grep "$srv_ip.$srv_port" | awk '{print $1}' | awk -F. '{print $1}')" 171 | 172 | # Ensure screen started... 173 | sleep 1 174 | if [ "$screen_pid" == "" ]; then 175 | echo "$(date) $(hostname) Restart: Failed to start GNU Screen, no PID! Exiting." >> $serverlog 176 | exit 177 | fi 178 | 179 | if [[ "$screen_pid" && ! -e /proc/$screen_pid ]]; then 180 | echo "$(date) $(hostname) Restart: Screen failed to start, check your server settings. Exiting." >> $serverlog 181 | exit 182 | fi 183 | 184 | pid=$(ps -ef | awk '{print $2,$3}' | grep "$screen_pid" | sort -n | tail -1 | awk '{print $1}') 185 | echo $screen_pid > $gpxdir/.gpxscreen.pid 186 | fi 187 | else 188 | $srv_cmd_line >> /dev/null 2>&1 & 189 | pid=$! 190 | fi 191 | # !! End start server 192 | fi 193 | 194 | # Save PID 195 | echo $pid > $gpxdir/.gpxpid 196 | 197 | # If server has it's own PID, save that to ours 198 | if [ "$srv_pidfile" ] 199 | then 200 | if [ -f $gpxdir/$srv_pidfile ] 201 | then 202 | echo y | cp $gpxdir/$srv_pidfile $gpxdir/.gpxpid 203 | parent_pid=$(cat $gpxdir/.gpxpid) 204 | fi 205 | fi 206 | fi 207 | 208 | # Sleep the check if server has died 209 | sleep 3 210 | 211 | # Fork off this loop so this script can exit and continue checking for a dead server 212 | done >> /dev/null 2>&1 & 213 | res_pid=$! 214 | 215 | # Make sure restart PID file exists 216 | if [ ! -f $gpxdir/.gpxrespid ] 217 | then 218 | touch $gpxdir/.gpxrespid 219 | fi 220 | 221 | if [ "$res_pid" ] 222 | then 223 | echo $res_pid > $gpxdir/.gpxrespid 224 | fi 225 | 226 | # Write this info to srv.d so this server restarts on reboot 227 | if [ -d /usr/local/gpx/srv.d ]; then 228 | echo "user: $srv_username 229 | ip: $srv_ip 230 | port: $srv_port 231 | pid: $srv_pidfile 232 | workingdir: $working_dir 233 | gpxcmd: $srv_cmd_line 234 | taskset: $taskset_cpu" > /usr/local/gpx/srv.d/$srv_ip.$srv_port 235 | fi 236 | 237 | echo "success" 238 | -------------------------------------------------------------------------------- /bin/ServerOutput: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Print last x lines of server log 7 | # 8 | # -u: Client's gpx username 9 | # -i: Server IP Address (x.x.x.x) 10 | # -p: Server Port 11 | # -w: Server working directory to CD into for the server startup. Again, local paths only. 12 | # 13 | # Example usage: 14 | # ./ServerOutput -u user123 -i 192.168.10.10 -p 27015 -w orangebox 15 | # 16 | srv_username= 17 | srv_ip= 18 | srv_port= 19 | working_dir= 20 | srv_cmd_line= 21 | 22 | while getopts "u:i:p:w:" OPTION 23 | do 24 | case $OPTION in 25 | u) 26 | srv_username=$OPTARG 27 | ;; 28 | i) 29 | srv_ip=$OPTARG 30 | ;; 31 | p) 32 | srv_port=$OPTARG 33 | ;; 34 | w) 35 | working_dir=$OPTARG 36 | ;; 37 | ?) 38 | exit 39 | ;; 40 | esac 41 | done 42 | 43 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 44 | then 45 | echo "ServerOutput: Required settings were left out. Exiting." 46 | exit 47 | fi 48 | 49 | # Check for homedir 50 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 51 | 52 | if [ ! -d $gpxdir ] 53 | then 54 | echo "ServerOutput: Game directory ($gpxdir) doesnt exist! Exiting." 55 | exit 56 | fi 57 | 58 | if [[ ! -f $gpxdir/.gpxsrv.log && ! -f $gpxdir/.gpxscreen.pid ]] 59 | then 60 | echo "ServerOutput: Sorry, server log doesnt exist." 61 | exit 62 | fi 63 | 64 | ######################################################################## 65 | 66 | # No screen 67 | if [ "$(which screen 2>&1 | grep 'no screen in')" ] 68 | then 69 | tail -n40 $gpxdir/.gpxsrv.log 70 | # Screen 71 | else 72 | if [ -f $gpxdir/.gpxscreen.pid ] 73 | then 74 | screen_pid="$(cat $gpxdir/.gpxscreen.pid)" 75 | else 76 | echo "No screen found. Is the server offline?" 77 | exit 78 | fi 79 | 80 | # Dump full screen (outputs to working dir) 81 | screen -r -S $screen_pid -X -p0 hardcopy .gpxscreen.out 82 | 83 | # Working Dir? 84 | if [ -f $gpxdir/$working_dir/.gpxscreen.out ] 85 | then 86 | tail -n40 $gpxdir/$working_dir/.gpxscreen.out 87 | rm -f $gpxdir/$working_dir/.gpxscreen.out 88 | # Probably an update. No working dir. 89 | elif [ -f $gpxdir/.gpxscreen.out ] 90 | then 91 | tail -n40 $gpxdir/.gpxscreen.out 92 | rm -f $gpxdir/.gpxscreen.out 93 | # No file... 94 | else 95 | #echo "No screen found. Is the server offline?" 96 | exit 97 | fi 98 | fi 99 | 100 | -------------------------------------------------------------------------------- /bin/ServerSendCMD: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Send a command to a server's GNU Screen session 7 | # 8 | # -u: Client's gpx username 9 | # -i: Server IP Address (x.x.x.x) 10 | # -p: Server Port 11 | # -w: Server working directory to CD into for the server startup. Again, local paths only. 12 | # 13 | # Example usage: 14 | # ./ServerSendCMD -u user123 -i 192.168.10.10 -p 27015 -w orangebox -c "status" 15 | # 16 | srv_username= 17 | srv_ip= 18 | srv_port= 19 | working_dir= 20 | srv_cmd_line= 21 | run_cmd= 22 | 23 | while getopts "u:i:p:w:c:" OPTION 24 | do 25 | case $OPTION in 26 | u) 27 | srv_username=$OPTARG 28 | ;; 29 | i) 30 | srv_ip=$OPTARG 31 | ;; 32 | p) 33 | srv_port=$OPTARG 34 | ;; 35 | w) 36 | working_dir=$OPTARG 37 | ;; 38 | c) 39 | run_cmd=$OPTARG 40 | ;; 41 | ?) 42 | exit 43 | ;; 44 | esac 45 | done 46 | 47 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 48 | then 49 | echo "ServerSendCMD: Required settings were left out. Exiting." 50 | exit 51 | fi 52 | 53 | # Check for homedir 54 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 55 | 56 | if [ ! -d $gpxdir ] 57 | then 58 | echo "ServerSendCMD: Game directory ($gpxdir) doesnt exist! Exiting." 59 | exit 60 | fi 61 | 62 | if [[ ! -f $gpxdir/.gpxsrv.log && ! -f $gpxdir/.gpxscreen.pid ]] 63 | then 64 | echo "ServerSendCMD: Sorry, server log doesnt exist." 65 | exit 66 | fi 67 | 68 | # Ensure this is a screen setup 69 | if [ -f $gpxdir/.gpxscreen.pid ] 70 | then 71 | screen_pid="$(cat $gpxdir/.gpxscreen.pid)" 72 | screen -r -S $screen_pid -p0 -X stuff "$run_cmd"`echo -ne '\015'` 73 | else 74 | echo "Sorry, screen is unavailable." 75 | exit 76 | fi 77 | 78 | echo "success" 79 | -------------------------------------------------------------------------------- /bin/SteamCMDFunctions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## 3 | ## GamePanelX 4 | ## Remote scripts v3.0.15 5 | ## 6 | ## Steam Install Script (for newer SteamCMD) 7 | ## Steam(c) is a trademark owned by VALVe Corporation, and is in no way affiliated with GamePanelX. These are simply scripts to work alongside their provided server tools. 8 | ## 9 | ## Using a function so we don't repeat code 10 | steamcmd_update() { 11 | ################### 12 | steam_log=/usr/local/gpx/logs/steam.log 13 | 14 | # Start logging 15 | echo "SteamCMDInstall: ($(date)) Starting SteamCMD install on dir ($steam_tmp) for game ($steam_game) ..." >> $steam_log 16 | 17 | ################################################################################### 18 | 19 | # Fetch steamcmd 20 | steamcmd_tar="steamcmd_linux.tar.gz" 21 | echo "SteamCMDInstall: ($(date)) Downloading $steamcmd_tar ..." >> $steam_log 22 | wget -q "http://media.steampowered.com/client/steamcmd_linux.tar.gz" -O ./$steamcmd_tar 23 | 24 | if [ ! -f $steamcmd_tar ] 25 | then 26 | echo "SteamCMDInstall: Failed to fetch $steamcmd_tar, exiting." 27 | echo "SteamCMDInstall: Failed to fetch $steamcmd_tar, exiting." >> $steam_log 28 | exit 29 | fi 30 | 31 | tar -zxf $steamcmd_tar 32 | rm -f $steamcmd_tar 33 | chmod u+x ./steamcmd.sh 34 | 35 | # Run an initial test 36 | steam_auth="$(echo quit | ./steamcmd.sh 2>&1)" 37 | 38 | # Check missing libstdc++ (Usually CentOS 5) 39 | if [ "$(echo $steam_auth | grep "GLIBCXX_3.4.10' not found")" ] 40 | then 41 | echo "SteamCMDInstall: ($(date)) Downloading libstdc++.so.6 ..." >> $steam_log 42 | wget -q "http://gamepanelx.com/files/libstdc++.so.6" -O linux32/libstdc++.so.6 43 | 44 | if [ ! -f $steam_tmp/linux32/libstdc++.so.6 ] 45 | then 46 | echo "SteamCMDInstall: Failed to fetch libstdc++.so.6, please install it manually (https://developer.valvesoftware.com/wiki/SteamCMD#32-bit_libraries_on_64-bit_Linux_systems). Exiting." 47 | echo "SteamCMDInstall: Failed to fetch libstdc++.so.6, please install it manually. Exiting." >> $steam_log 48 | exit 49 | fi 50 | 51 | export LD_LIBRARY_PATH=linux32/ 52 | fi 53 | 54 | if [ "$LD_LIBRARY_PATH" == "" ]; then 55 | export LD_LIBRARY_PATH=linux32/ 56 | fi 57 | 58 | ############################################################ 59 | 60 | ## 61 | ## Initial login test (check for steam guard) 62 | ## 63 | echo "SteamCMDInstall: ($(date)) Starting SteamCMD authentication check ..." >> $steam_log 64 | 65 | # Provide full path to steam install dir 66 | full_install_dir=$(pwd)"/$steam_game" 67 | 68 | # Allow anonymous Steam logins 69 | if [[ "$steam_login_user" == "anonymous" || "$steam_login_user" == "" ]] 70 | then 71 | echo "SteamCMDInstall: ($(date)) Steam: force_install_dir: $full_install_dir, app_update: $steam_game" >> $steam_log 72 | 73 | # Setup steam install 74 | echo "login anonymous 75 | force_install_dir $full_install_dir 76 | app_update $steam_game -validate 77 | quit" > .gpxsteamupdate.txt 78 | 79 | # Test for errors 80 | if [ "$(echo $steam_auth | grep 'error while loading shared libraries')" ] 81 | then 82 | echo "SteamCMDInstall: Error: $steam_auth" 83 | echo "SteamCMDInstall: Error: $steam_auth" >> $steam_log 84 | exit 85 | fi 86 | 87 | # Normal Steam login 88 | else 89 | echo "login $steam_login_user $steam_login_pass 90 | quit" > .gpxsteamupdate.txt 91 | 92 | # Initial run through (re-run test since they want to login) 93 | steam_auth= 94 | steam_auth="$(echo quit | ./steamcmd.sh +runscript .gpxsteamupdate.txt 2>&1)" 95 | 96 | # Error loading libraries 97 | if [ "$(echo $steam_auth | grep 'error while loading shared libraries')" ] 98 | then 99 | echo "SteamCMDInstall: Error: $steam_auth" 100 | echo "SteamCMDInstall: Error: $steam_auth" >> $steam_log 101 | exit 102 | 103 | # Has Steam Guard 104 | elif [ "$(echo $steam_auth | grep 'not been authenticated for your account using Steam Guard')" ] 105 | then 106 | # Check if we have a code 107 | if [ "$steam_login_code" ] 108 | then 109 | echo "set_steam_guard_code $steam_login_code 110 | login $steam_login_user $steam_login_pass 111 | quit" > .gpxsteamupdate.txt 112 | # No code, exit 113 | else 114 | echo "SteamCMDInstall: This Steam account has Steam Guard active. Enter the Steam Guard code on the Settings page and try again. Exiting." 115 | echo "SteamCMDInstall: This Steam account has Steam Guard active. Enter the Steam Guard code on the Settings page and try again. Exiting." >> $steam_log 116 | exit 117 | fi 118 | # Bad password 119 | elif [ "$(echo $steam_auth | grep 'Login Failure: Invalid Password')" ] 120 | then 121 | echo "SteamCMDInstall: Bad password for this Steam account. Please check the Steam password in Settings and try again. Exiting." 122 | echo "SteamCMDInstall: Bad password for this Steam account. Please check the Steam password in Settings and try again. Exiting." >> $steam_log 123 | exit 124 | # Check successful login 125 | elif [ "$(echo $steam_auth | grep 'Steam Public...Success')" ] 126 | then 127 | echo "SteamCMDInstall: ($(date)) Steam: force_install_dir: $full_install_dir, app_update: $steam_game" >> $steam_log 128 | 129 | # Setup update file without steam guard 130 | echo "login $steam_login_user $steam_login_pass 131 | force_install_dir $full_install_dir 132 | app_update $steam_game 133 | quit" > .gpxsteamupdate.txt 134 | 135 | fi 136 | fi 137 | 138 | ######################################################################## 139 | 140 | ## 141 | ## All authenticated, begin game installation 142 | ## 143 | echo "SteamCMDInstall: ($(date)) SteamCMD is authed and ready, starting game $steam_game update ..." >> $steam_log 144 | 145 | # Log specific to game install 146 | #steamcmd_log=/usr/local/gpx/logs/steamcmdgame.log 147 | steamcmd_log=/usr/local/gpx/tmp/steam_$tpl_id.log 148 | 149 | ######################################################################## 150 | 151 | # Updating a server, use Screen if possible 152 | if [ "$update_cmd" ]; then 153 | # No GNU Screen support 154 | if [ "$(which screen 2>&1 | grep 'no screen in')" ] 155 | then 156 | echo "$(date) $(hostname) Update: Warning: No GNU Screen found! Please install screen to use all server features." >> $serverlog 157 | 158 | # Screen is broken, since env vars aren't pulling in....fix this later 159 | ./steamcmd.sh +runscript .gpxsteamupdate.txt >> $serverlog 2>&1 & 160 | steam_pid=$! 161 | pid=$steam_pid 162 | touch .gpxsteam.pid 163 | echo $steam_pid > .gpxsteam.pid 164 | 165 | echo "$(date) $(hostname) Update: Starting on IP: $srv_ip, port: $srv_port, PID: $pid, NOT using GNU Screen" >> $serverlog 166 | # Start update in GNU Screen so we can see console output 167 | else 168 | # Make new steam script to export lib path 169 | touch ./.gpxsteam.sh 170 | echo '#!/bin/bash' > ./.gpxsteam.sh 171 | echo 'export LD_LIBRARY_PATH=linux32/' >> ./.gpxsteam.sh 172 | echo './steamcmd.sh +runscript .gpxsteamupdate.txt' >> ./.gpxsteam.sh 173 | chmod u+x ./.gpxsteam.sh 174 | 175 | screen -wipe >> /dev/null 2>&1 176 | # screen -d -m -S "$srv_ip.$srv_port" ./steamcmd.sh +runscript .gpxsteamupdate.txt 177 | screen -d -m -S "$srv_ip.$srv_port" ./.gpxsteam.sh 178 | 179 | screen_pid="$(screen -list | grep "$srv_ip.$srv_port" | awk '{print $1}' | awk -F. '{print $1}')" 180 | pid="$(ps -ef | awk '{print $2,$3}' | grep "$screen_pid" | sort -n | tail -1 | awk '{print $1}')" 181 | echo $screen_pid > $gpxdir/.gpxscreen.pid 182 | 183 | echo "$(date) $(hostname) Update: Starting on IP: $srv_ip, port: $srv_port, Screen PID: $screen_pid, PID: $pid" >> $serverlog 184 | fi 185 | 186 | echo $pid > $gpxdir/.gpxupdatepid 187 | # Normal initial steam install 188 | else 189 | ./steamcmd.sh +runscript .gpxsteamupdate.txt >> $steamcmd_log 2>&1 & 190 | steam_pid=$! 191 | pid=$steam_pid 192 | touch .gpxsteam.pid 193 | echo $steam_pid > .gpxsteam.pid 194 | fi 195 | 196 | 197 | echo "SteamCMDInstall: ($(date)) Game installation began on PID ($steam_pid)" >> $steam_log 198 | 199 | ########### 200 | } 201 | -------------------------------------------------------------------------------- /bin/SteamCMDInstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Steam Install Script (for newer SteamCMD) 7 | # Steam(c) is a trademark owned by VALVe Corporation, and is in no way affiliated with GamePanelX. These are simply scripts to work alongside their provided server tools. 8 | # 9 | # You only need -c to provide the code given by SteamGuard(c). Turn SteamGuard off on your account to simplify things; you should have a dedicated steam account for this anyways. 10 | # 11 | # Example: ./SteamCMDInstall -g 740 -i 24 -l steamusr22 -p steampass1234 -c aBc3 12 | # 13 | tpl_id= 14 | callback_url= 15 | cback="wget -qO-" 16 | steam_game= 17 | steam_tmp= 18 | steam_login_user= 19 | steam_login_pass= 20 | steam_login_code= 21 | debug_on= 22 | 23 | while getopts "i:u:g:l:p:c:d:" OPTION 24 | do 25 | case $OPTION in 26 | i) 27 | tpl_id=$OPTARG 28 | ;; 29 | u) 30 | callback_url=$OPTARG 31 | ;; 32 | g) 33 | steam_game=$OPTARG 34 | ;; 35 | l) 36 | steam_login_user=$OPTARG 37 | ;; 38 | p) 39 | steam_login_pass=$OPTARG 40 | ;; 41 | c) 42 | steam_login_code=$OPTARG 43 | ;; 44 | d) 45 | debug_on=$OPTARG 46 | ;; 47 | ?) 48 | exit 49 | ;; 50 | esac 51 | done 52 | 53 | if [ "$tpl_id" == "" ] 54 | then 55 | echo "SteamCMDInstall: No template ID provided. Exiting." 56 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 57 | exit 58 | elif [ "$steam_game" == "" ] 59 | then 60 | echo "SteamCMDInstall: No Steam app ID (-g) provided. Exiting." 61 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 62 | exit 63 | elif [[ "$steam_login_user" && "$steam_login_pass" == "" ]] 64 | then 65 | # Don't care about user since they can always try anon. 66 | echo "SteamCMDInstall: No Steam password provided!" 67 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 68 | exit 69 | fi 70 | 71 | # Get to the right directory 72 | steam_tmp=/usr/local/gpx/tmp/$tpl_id 73 | if [ ! -d $steam_tmp ] 74 | then 75 | mkdir -p $steam_tmp 76 | else 77 | rm -fr $steam_tmp 78 | mkdir -p $steam_tmp 79 | fi 80 | 81 | # Move to steam path 82 | cd $steam_tmp 83 | 84 | ################################ 85 | 86 | # Begin SteamCMD install/update 87 | . /usr/local/gpx/bin/SteamCMDFunctions 88 | steamcmd_update $steam_game 89 | 90 | ################################# 91 | 92 | # Fork the checking on installation status, once done start template creation 93 | while [ true ] 94 | do 95 | # Check completed 96 | if [ "$(grep 'fully installed.' $steamcmd_log)" ] 97 | then 98 | # Remote update script so clients dont have our steam details 99 | # rm -f $steam_tmp/.gpxsteamupdate.txt 100 | 101 | # Give path without /usr/local/gpx, since CreateTemplate adds /usr/local/gpx to what we give it 102 | this_path="tmp/$tpl_id" 103 | 104 | # Done, start template creation process ("success" will output from this so no need to echo again) 105 | echo "SteamCMDInstall: tpl_create_start" >> $steam_log 106 | echo "SteamCMDInstall: ($(date)) Beginning template creation process (Path: $this_path, TplID: $tpl_id ..." >> $steam_log 107 | 108 | if [ "$debug_on" ]; then add_debug=" -d yes"; else add_debug=""; fi 109 | 110 | /usr/local/gpx/bin/CreateTemplate -p $this_path -i $tpl_id -s yes -u "$callback_url" $add_debug 111 | 112 | break 113 | exit 114 | # Check failed 115 | elif [ "$(grep 'Failed' $steamcmd_log | grep -v 'Assertion Failed: m_unRequestsOutstanding')" ] 116 | then 117 | failed_info="$(grep 'Failed' $steamcmd_log)" 118 | 119 | echo "SteamCMDInstall: Steam install failed ($failed_info)" >> $steam_log 120 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 121 | exit 122 | # Not complete. Update callback with steam install percentage every x seconds 123 | else 124 | # (this expects a modern `grep` which can handle basic regex) 125 | if [ "$callback_url" ] 126 | then 127 | cur_perc=$(tail $steamcmd_log | awk '{print $6}' | grep '[0-9]\.[0-9]' | tail -1) 128 | 129 | if [ "$last_perc" != "$cur_perc" ] 130 | then 131 | last_perc=$cur_perc 132 | $cback "$callback_url&do=steam_progress&percent=$cur_perc" >> /dev/null 133 | fi 134 | 135 | fi 136 | fi 137 | 138 | sleep 5 139 | done >> /dev/null 2>&1 & 140 | check_tpl_pid=$! 141 | 142 | echo "SteamCMDInstall: ($(date)) While loop forked off to PID ($check_tpl_pid)" >> $steam_log 143 | 144 | touch .gpxtplcheck.pid 145 | echo $check_tpl_pid > .gpxtplcheck.pid 146 | 147 | 148 | echo "success" 149 | -------------------------------------------------------------------------------- /bin/SteamInstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Steam Install Script 7 | # Fetch hldsupdatetool, install steam in current dir, install game, then start template creation process 8 | # 9 | # Steam(c) is a trademark owned by VALVe Corporation, and is in no way affiliated with GamePanelX. These are simply scripts to work alongside their provided server tools. 10 | # 11 | steam_game= 12 | tpl_id= 13 | callback_url= 14 | cback="wget -qO-" 15 | debug_on= 16 | 17 | while getopts "g:i:u:d:" OPTION 18 | do 19 | case $OPTION in 20 | g) 21 | steam_game=$OPTARG 22 | ;; 23 | i) 24 | tpl_id=$OPTARG 25 | ;; 26 | u) 27 | callback_url=$OPTARG 28 | ;; 29 | d) 30 | debug_on=$OPTARG 31 | ;; 32 | ?) 33 | exit 34 | ;; 35 | esac 36 | done 37 | 38 | # Setup path 39 | steam_tmp=/usr/local/gpx/tmp/$tpl_id/ 40 | 41 | # Get to the right directory 42 | if [ ! -d $steam_tmp ] 43 | then 44 | mkdir -p $steam_tmp 45 | fi 46 | 47 | # Move to steam dir 48 | cd $steam_tmp 49 | 50 | # Steam log 51 | steam_log=/usr/local/gpx/logs/steam.log 52 | 53 | if [ "$steam_game" == "" ] 54 | then 55 | echo "SteamInstall: No game provided!" 56 | echo "SteamInstall: ($(date)) No game provided. Use the -g option to set a game, and try again." >> $steam_log 57 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 58 | exit 59 | elif [ "$tpl_id" == "" ] 60 | then 61 | echo "SteamInstall: No template ID provided!" 62 | echo "SteamInstall: ($(date)) No template ID provided. Use the -i option to set, and try again." >> $steam_log 63 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 64 | exit 65 | fi 66 | 67 | # Remove ./steam to start fresh 68 | if [ -f ./steam ] 69 | then 70 | echo "SteamInstall: ($(date)) Removing old steam binary ..." >> $steam_log 71 | rm -f ./steam 72 | fi 73 | 74 | if [ ! -f ./hldsupdatetool.bin ] 75 | then 76 | echo "SteamInstall: ($(date)) Downloading hldsupdatetool.bin ..." >> $steam_log 77 | wget -q http://storefront.steampowered.com/download/hldsupdatetool.bin 78 | if [ ! -f ./hldsupdatetool.bin ] 79 | then 80 | echo "SteamInstall: ($(date)) Steam client download failed! Please try again later." 81 | echo "SteamInstall: ($(date)) Steam client download failed! Please try again later." >> $steam_log 82 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 83 | exit 84 | fi 85 | fi 86 | 87 | if [[ ! -f /usr/bin/uncompress && ! -f /usr/sbin/uncompress && ! -f /usr/local/bin/uncompress && ! -f /bin/uncompress ]] 88 | then 89 | echo "SteamInstall: ($(date)) The 'uncompress' command (/usr/bin/uncompress) was not found! Install it and try again." 90 | echo "SteamInstall: ($(date)) The 'uncompress' command (/usr/bin/uncompress) was not found! Install it and try again." >> $steam_log 91 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 92 | exit 93 | fi 94 | 95 | ################################################################################# 96 | 97 | # Check hldsupdatetool extracts properly 98 | echo "SteamInstall: ($(date)) Running hldsupdatetool.bin ..." >> $steam_log 99 | chmod u+x ./hldsupdatetool.bin 100 | check_hldsupd="$(echo yes | ./hldsupdatetool.bin)" 101 | 102 | if [ ! "$(echo $check_hldsupd | grep 'extracting steam')" ] 103 | then 104 | echo "SteamInstall: ($(date)) Failed to extract Steam client: $check_hldsupd" 105 | echo "SteamInstall: ($(date)) Failed to extract Steam client: $check_hldsupd" >> $steam_log 106 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 107 | exit 108 | fi 109 | 110 | # Setup steam client 111 | sleep 1 112 | chmod u+x ./steam 113 | 114 | echo "SteamInstall: ($(date)) Finished hldsupdatetool.bin. Running ./steam ..." >> $steam_log 115 | 116 | # (send stderr to /dev/null) 117 | if [ ! "$(./steam 2>>/dev/null | grep 'Steam Linux Client updated, please retry the command')" ] 118 | then 119 | bad_steam_out="$(./steam 2>&1)" 120 | echo "SteamInstall: ($(date)) Steam client update failed: $bad_steam_out" 121 | echo "SteamInstall: ($(date)) Steam client update failed: $bad_steam_out" >> $steam_log 122 | 123 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 124 | exit 125 | fi 126 | 127 | # Final run, ensure client is working normally by checking for usage info 128 | if [ ! "$(./steam 2>>/dev/null | grep 'Optional parameters for all commands')" ] 129 | then 130 | echo -e "SteamInstall: ($(date)) Did not receive proper output, trying again in 3 seconds ..." >> $steam_log 131 | 132 | sleep 3 133 | 134 | # Try one last time if Steam servers were busy... 135 | if [ ! "$(./steam 2>>/dev/null | grep 'Optional parameters for all commands')" ] 136 | then 137 | # Failed. Get real output 138 | bad_steam_out="$(./steam 2>&1)" 139 | echo "SteamInstall: ($(date)) Steam Failed: $bad_steam_out" 140 | echo "SteamInstall: ($(date)) Steam Failed: $bad_steam_out" >> $steam_log 141 | 142 | $cback "$callback_url&do=tpl_status&update=failed" >> /dev/null 143 | exit 144 | fi 145 | fi 146 | 147 | echo "SteamInstall: ($(date)) Steam is ready, starting game $steam_game update ..." >> $steam_log 148 | 149 | ########################################################################## 150 | 151 | # Unique Steam log for game install progress 152 | touch /usr/local/gpx/tmp/steam_$tpl_id.log 153 | steam_game_log=/usr/local/gpx/tmp/steam_$tpl_id.log 154 | 155 | # Run steam install in background, and save PID 156 | ./steam -command update -game "$steam_game" -dir . >> $steam_game_log 2>&1 & 157 | steam_pid=$! 158 | 159 | # Save PID 160 | touch $steam_tmp/.gpxsteam.pid 161 | echo $steam_pid > $steam_tmp/.gpxsteam.pid 162 | 163 | # Fork the checking on installation status, once done start template creation 164 | while [ true ] 165 | do 166 | # Check completed 167 | # if [ "$(tail ./.gpxsteam.log | grep 'HLDS installation up to date')" ] 168 | if [ "$(grep 'HLDS installation up to date' $steam_game_log)" ] 169 | then 170 | # Give path without /usr/local/gpx, since CreateTemplate adds /usr/local/gpx to what we give it 171 | this_path="tmp/$tpl_id" 172 | 173 | # Done, start template creation process ("success" will output from this so no need to echo again) 174 | echo "SteamInstall: tpl_create_start" >> $steam_log 175 | echo "SteamInstall: ($(date)) Beginning template creation process (Path: $this_path, TplID: $tpl_id ..." >> $steam_log 176 | 177 | #cd 178 | #this_path=/usr/local/gpx/tmp/$tpl_id 179 | 180 | if [ "$debug_on" ]; then add_debug=" -d yes"; else add_debug=""; fi 181 | 182 | /usr/local/gpx/bin/CreateTemplate -p $this_path -i $tpl_id -s yes -u "$callback_url" $add_debug 183 | 184 | break 185 | exit 186 | # Not complete. Update callback with steam install percentage every x seconds 187 | else 188 | # (this expects a modern `grep` which can handle regex) 189 | if [ "$callback_url" ] 190 | then 191 | cur_perc=$(tail $steam_game_log | awk '{print $2}' | grep '[0-9]%' | tail -1) 192 | 193 | if [ "$last_perc" != "$cur_perc" ] 194 | then 195 | last_perc=$cur_perc 196 | $cback "$callback_url&do=steam_progress&percent=$cur_perc" >> /dev/null 197 | fi 198 | 199 | fi 200 | fi 201 | 202 | sleep 5 203 | done >> /dev/null 2>&1 & 204 | check_tpl_pid=$! 205 | 206 | touch $steam_tmp/.gpxtplcheck.pid 207 | echo $check_tpl_pid > $steam_tmp/.gpxtplcheck.pid 208 | 209 | echo "success" 210 | -------------------------------------------------------------------------------- /bin/Stop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Stop Game/Voice Servers 7 | # 8 | # -u: Client's gpx username 9 | # -i: Server IP Address (x.x.x.x) 10 | # -p: Server Port 11 | # -s: Suspend Server (optional). Can be "yes" to suspend, or left empty to not. 12 | # -r: PID of the "Restart" script (optional). Used if it needs to stop a server first and calls this script. 13 | # 14 | # Example usage: 15 | # ./Stop -u user123 -i 192.168.10.10 -p 27015 16 | # 17 | srv_username= 18 | srv_ip= 19 | srv_port= 20 | suspend_srv= 21 | restart_pid= 22 | working_dir= 23 | #pid_file= 24 | srv_pid_file= 25 | debug= 26 | 27 | while getopts "u:i:p:s:r:w:P:d:n:" OPTION 28 | do 29 | case $OPTION in 30 | u) 31 | srv_username=$OPTARG 32 | ;; 33 | i) 34 | srv_ip=$OPTARG 35 | ;; 36 | p) 37 | srv_port=$OPTARG 38 | ;; 39 | s) 40 | suspend_srv=$OPTARG 41 | ;; 42 | r) 43 | restart_pid=$OPTARG 44 | ;; 45 | w) 46 | working_dir=$OPTARG 47 | ;; 48 | P) 49 | srv_pid_file=$OPTARG 50 | ;; 51 | d) 52 | debug=$OPTARG 53 | ;; 54 | n) 55 | noremove_srvd=$OPTARG 56 | ;; 57 | ?) 58 | exit 59 | ;; 60 | esac 61 | done 62 | # pid_file=$OPTARG 63 | 64 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" ]] 65 | then 66 | echo "Stop: Required settings were left out. Exiting." 67 | exit 68 | fi 69 | 70 | # Check for homedir 71 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip.$srv_port 72 | gpxsuspdir=/usr/local/gpx/users/$srv_username/.$srv_ip.$srv_port 73 | 74 | if [ ! -d $gpxdir ] 75 | then 76 | echo "Stop: Game directory ($gpxdir) doesnt exist! Exiting." 77 | exit 78 | fi 79 | 80 | # Kill main process if the server has it's own PID file 81 | if [ "$srv_pid_file" ] 82 | then 83 | if [ -f $gpxdir/$srv_pid_file ] 84 | then 85 | pid_file_pid="$(cat $gpxdir/$srv_pid_file)" 86 | 87 | if [[ "$pid_file_pid" && -e /proc/$pid_file_pid ]]; then 88 | kill $pid_file_pid 89 | fi 90 | fi 91 | fi 92 | 93 | if [ -f $gpxdir/.gpxpid ] 94 | then 95 | # First try killing the actual PID's found by GPX. 96 | # At the end, manually kill all found PID's by `ps` 97 | if [ -f $gpxdir/.gpxrespid ] 98 | then 99 | res_pid=$(cat $gpxdir/.gpxrespid) 100 | fi 101 | 102 | # Kill if running 103 | # if [[ "$res_pid" && "$(ps aux | grep \"$res_pid\" | grep -v grep)" && "$restart_pid" != "$res_pid" ]] 104 | if [[ "$res_pid" && -e /proc/$res_pid && "$restart_pid" != "$res_pid" ]] 105 | then 106 | if [ "$debug" ] ; then echo "Killing Restart PID: $res_pid ..."; fi 107 | 108 | if [ "$res_pid" ]; then kill -9 $res_pid; fi 109 | fi 110 | 111 | if [ -f $gpxdir/.gpxpid ] 112 | then 113 | parent_pid=$(cat $gpxdir/.gpxpid) 114 | fi 115 | 116 | # Kill screen if there 117 | if [ -f $gpxdir/.gpxscreen.pid ] 118 | then 119 | screen -d -S "$srv_ip.$srv_port" -X quit >> /dev/null 2>&1 120 | 121 | scr_pid="$(cat $gpxdir/.gpxscreen.pid)" 122 | 123 | if [[ "$scr_pid" && -e /proc/$scr_pid ]]; then kill $scr_pid; fi 124 | 125 | rm -f $gpxdir/.gpxscreen.pid 126 | fi 127 | 128 | # Kill PID if server actually gave us one 129 | # if [ "$srv_pid_file" ] 130 | # then 131 | # echo "PID FILE: $srv_pid_file" 132 | 133 | # if [ -e $srv_pid_file ] 134 | # then 135 | # pid_file_pid="$(cat $srv_pid_file)" 136 | 137 | # echo "PID : $pid_file_pid" 138 | 139 | # if [[ "$pid_file_pid" && -e /proc/$pid_file_pid ]]; then kill $pid_file_pid; fi 140 | # fi 141 | # fi 142 | 143 | # Kill all server processes 144 | if [ -f $gpxdir/.gpxpid ] 145 | then 146 | parent_pid=$(cat $gpxdir/.gpxpid) 147 | fi 148 | 149 | if [ "$parent_pid" ] 150 | then 151 | for srvr_pid in $(ps -ef | grep "$parent_pid" | grep -v grep | awk '{print $2}') 152 | do 153 | if [ "$debug" ] ; then echo "Killing server PID: $srvr_pid ..."; fi 154 | 155 | if [[ "$srvr_pid" && -e /proc/$srvr_pid ]]; then kill -9 $srvr_pid; fi 156 | done 157 | fi 158 | 159 | ##################################################################################################################### 160 | 161 | # Processes still running other than the stored PIDs; kill manually 162 | if [ "$(ps aux | grep \"$srv_ip\" | grep \"$srv_port\" | grep -v Stop | grep -v \"$restart_pid\" | grep -v grep)" ] 163 | then 164 | # Try manually killing all Restart script PIDs for this server 165 | for res_pid_try in $(ps aux | grep Restart | grep "$srv_ip" | grep "$srv_port" | grep -v grep | awk '{print $2}') 166 | do 167 | # Don't kill our spawning process if it's trying to currently restart 168 | if [ "$restart_pid" != "$res_pid_try" ] 169 | then 170 | if [[ "$res_pid_try" && -e /proc/$res_pid_try ]]; then kill -9 $res_pid_try; fi 171 | fi 172 | done 173 | 174 | # Try manually killing PID's for all the gameserver processes 175 | for srv_pid_try in $(ps aux | grep "$srv_ip" | grep "$srv_port" | grep -v Restart | grep -v Stop | grep -v grep | awk '{print $2}') 176 | do 177 | if [ "$srv_pid_try" ]; then kill -9 $srv_pid_try; fi 178 | done 179 | 180 | # Check one last time if it's running, if it is, exit the script...something is very wrong 181 | if [ "$(ps aux | grep \"$srv_ip\" | grep \"$srv_port\" | grep -v Stop | grep -v Restart | grep -v grep)" ] 182 | then 183 | bad_pid=$(ps aux | grep "$srv_ip" | grep "$srv_port" | grep -v Stop | grep -v Restart | grep -v grep | awk '{print $2}') 184 | bad_proc=$(ps aux | grep "$srv_ip" | grep "$srv_port" | grep -v Stop | grep -v Restart | grep -v grep | awk '{print $11}') 185 | echo "Unable to kill the server process $bad_pid ($bad_proc). Exiting." 186 | exit 187 | fi 188 | fi 189 | 190 | # Remove the PID files 191 | rm -f $gpxdir/.gpxpid $gpxdir/.gpxrespid 192 | fi 193 | 194 | # Kill any updating processes - Callback should then set status to complete 195 | if [ -f $gpxdir/.gpxupdatepid ] 196 | then 197 | update_pid=$(cat $gpxdir/.gpxupdatepid) 198 | 199 | if [ "$update_pid" ] 200 | then 201 | # Kill known update processes 202 | for ps_pid in $(ps -ef | grep "$update_pid" | grep -v Stop | grep -v grep | awk '{print $2}') 203 | do 204 | if [[ "$ps_pid" && -e /proc/$ps_pid ]]; then kill -9 $ps_pid; fi 205 | done 206 | 207 | # Kill any others 208 | if [ "$(ps -ef | grep \"$srv_ip\" | grep \"$srv_port\" | grep -v Stop | grep -v grep | awk '{print $2}')" ] 209 | then 210 | for last_pid in $(ps -ef | grep "$srv_ip" | grep "$srv_port" | grep -v Stop | grep -v grep | awk '{print $2}') 211 | do 212 | if [[ "$last_pid" && -e /proc/$last_pid ]]; then kill -9 $last_pid; fi 213 | done 214 | fi 215 | 216 | # Remove PID file 217 | rm -f $gpxdir/.gpxupdatepid 218 | fi 219 | fi 220 | 221 | # Suspend Server 222 | if [ "$suspend_srv" == "yes" ] 223 | then 224 | if [ -d $gpxdir ] 225 | then 226 | echo y | mv $gpxdir $gpxsuspdir 227 | fi 228 | fi 229 | 230 | # Remove srv.d file so this does not start on reboot 231 | if [[ -d /usr/local/gpx/srv.d && -f /usr/local/gpx/srv.d/$srv_ip.$srv_port && "$noremove_srvd" == "" ]]; then 232 | rm -f /usr/local/gpx/srv.d/$srv_ip.$srv_port 233 | fi 234 | 235 | echo "success" 236 | 237 | -------------------------------------------------------------------------------- /bin/UpdateServer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Update a Game/Voice server 7 | # 8 | 9 | # 10 | # Example usage: 11 | # ./UpdateServer -u user123 -t game -i 192.168.10.10 -p 27015 -o './steam -command update ...' 12 | # 13 | srv_username= 14 | srv_ip= 15 | srv_port= 16 | srv_pidfile= 17 | update_cmd= 18 | callback_url= 19 | cback="wget -qO-" 20 | steam_game= 21 | steam_login_user= 22 | steam_login_pass= 23 | steam_login_code= 24 | 25 | while getopts "u:i:p:P:o:c:g:d:e:f:" OPTION 26 | do 27 | case $OPTION in 28 | u) 29 | srv_username=$OPTARG 30 | ;; 31 | i) 32 | srv_ip=$OPTARG 33 | ;; 34 | p) 35 | srv_port=$OPTARG 36 | ;; 37 | P) 38 | srv_pidfile=$OPTARG 39 | ;; 40 | o) 41 | update_cmd=$OPTARG 42 | ;; 43 | c) 44 | callback_url=$OPTARG 45 | ;; 46 | g) 47 | steam_game=$OPTARG 48 | ;; 49 | d) 50 | steam_login_user=$OPTARG 51 | ;; 52 | e) 53 | steam_login_pass=$OPTARG 54 | ;; 55 | f) 56 | steam_login_code=$OPTARG 57 | ;; 58 | ?) 59 | exit 60 | ;; 61 | esac 62 | done 63 | 64 | if [[ "$srv_username" == "" || "$srv_ip" == "" || "$srv_port" == "" || "$update_cmd" == "" ]] 65 | then 66 | echo "UpdateServer: Required settings were left out. Exiting." 67 | exit 68 | fi 69 | 70 | # Stop server, suppress "success" message 71 | /usr/local/gpx/bin/Stop -u $srv_username -i $srv_ip -p $srv_port 2>&1 >> /dev/null 72 | 73 | # Update callback 74 | if [ "$callback_url" ]; then $cback "$callback_url&do=createsrv_status&status=updating" >> /dev/null; fi 75 | 76 | # Setup 77 | gpxdir=/usr/local/gpx/users/$srv_username/$srv_ip\.$srv_port 78 | serverlog=/usr/local/gpx/logs/servers.log 79 | #updatelog=$gpxdir/.gpxupdate.log 80 | #echo > $updatelog 81 | updatelog=$serverlog 82 | 83 | # Real logging 84 | echo "$(date) $(hostname) Update: Updating server $srv_ip.$srv_port for user $srv_username, in dir $gpxdir ..." >> $serverlog 85 | 86 | # Move to correct directory 87 | cd $gpxdir 88 | 89 | ################################ 90 | 91 | # run update CMD 92 | echo "$(date) $(hostname) Update: `eval $update_cmd 2>&1`" >> $serverlog 93 | 94 | # Begin SteamCMD update 95 | if [[ "$steam_game" != "" ]] 96 | then 97 | echo "$(date) $(hostname) Update: run steam $steam_game" >> $serverlog 98 | . /usr/local/gpx/bin/SteamCMDFunctions 99 | steamcmd_update $steam_game 100 | fi 101 | 102 | ################################# 103 | 104 | # Start checking if update is complete 105 | if [ "$callback_url" ] 106 | then 107 | # Check if complete 108 | while [ true ] 109 | do 110 | # PID doesnt exist? Fail... 111 | if [ "$pid" == "" ] 112 | then 113 | echo "$(date) $(hostname) Update failed: No PID for update process found. Screen PID was: $screen_pid. Exiting. ($(date))" >> $updatelog 114 | $cback "$callback_url&do=createsrv_status&status=failed" >> /dev/null 115 | break 116 | # Completed 117 | elif [[ "$pid" && ! -e /proc/$pid ]] 118 | then 119 | echo "$(date) $(hostname) Update: Success: Update completed. ($(date))" >> $updatelog 120 | $cback "$callback_url&do=createsrv_status&status=complete" >> /dev/null 121 | 122 | echo "$(date) $(hostname) Update: Server update completed on $srv_ip.$srv_port for user $srv_username." >> $serverlog 123 | 124 | break 125 | # Still running, wait... 126 | elif [[ "$pid" && -e /proc/$pid ]] 127 | then 128 | sleep 5 129 | # Something else happened 130 | else 131 | echo "$(date) $(hostname) Update failed: Something odd happened. Screen PID was: $screen_pid, update PID was: $pid. Exiting. ($(date))" >> $updatelog 132 | echo "$(date) $(hostname) Update: Failed on $srv_ip.$srv_port for user $srv_username: Something odd happened. Screen PID was: $screen_pid, update PID was: $pid. Exiting." >> $serverlog 133 | 134 | $cback "$callback_url&do=createsrv_status&status=failed" >> /dev/null 135 | break 136 | fi 137 | done >> /dev/null 2>&1 & 138 | fi 139 | 140 | echo "success" 141 | -------------------------------------------------------------------------------- /bin/UsernameChange: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote scripts v3.0.15 5 | # 6 | # Change a username - move all servers to new user dir 7 | # 8 | # Example usage: 9 | # ./UsernameChange -o olduser -n newuser 10 | # 11 | old_user= 12 | new_user= 13 | tmp_dir="/usr/local/gpx/tmp" 14 | queue_dir="/usr/local/gpx/queue" 15 | rand_str="$(date +%s | sha256sum | base64 | head -c 24 ; echo)" 16 | 17 | while getopts "o:n:" OPTION 18 | do 19 | case $OPTION in 20 | o) 21 | old_user=$OPTARG 22 | ;; 23 | n) 24 | new_user=$OPTARG 25 | ;; 26 | ?) 27 | exit 28 | ;; 29 | esac 30 | done 31 | 32 | if [[ "$old_user" == "" || "$new_user" == "" ]] 33 | then 34 | echo "Insufficient info given! Exiting." 35 | exit 36 | fi 37 | 38 | # Check if user already exists 39 | if [ "$(grep "^gpx$new_user:" /etc/passwd)" ] 40 | then 41 | echo "That system user already exists, exiting." 42 | exit 43 | fi 44 | 45 | # Send to tmp file so manager doesn't read before we're done writing 46 | echo "type: changeusername" > $tmp_dir/queue_$rand_str 47 | echo "username: $old_user" >> $tmp_dir/queue_$rand_str 48 | echo "newusername: $new_user" >> $tmp_dir/queue_$rand_str 49 | 50 | # Move to queue dir 51 | mv $tmp_dir/queue_$rand_str $queue_dir/$rand_str 52 | 53 | echo "success" 54 | -------------------------------------------------------------------------------- /bin/VERSION: -------------------------------------------------------------------------------- 1 | 3.0.15 2 | -------------------------------------------------------------------------------- /ftp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # FTP Install v3.0.15 5 | # 6 | # This script supports dependency detection on RedHat/CentOS/Fedora, Debian/Ubuntu, and Gentoo 7 | # Note: As of 3.0.14, MySQL is no longer needed. System users only; e.g. basic install. 8 | # 9 | # Usage: ./ftp.sh -u someuser 10 | # 11 | # Licensed under the GPL (GNU General Public License V3) 12 | # 13 | if [ "$UID" -ne "0" ] 14 | then 15 | echo "ERROR: You must be the root user to run this script. Exiting." 16 | exit 17 | fi 18 | 19 | while getopts "u:" OPTION 20 | do 21 | case $OPTION in 22 | u) 23 | gpx_user=$OPTARG 24 | ;; 25 | ?) 26 | exit 27 | ;; 28 | esac 29 | done 30 | 31 | if [ "$gpx_user" == "" ] 32 | then 33 | echo "FTP ERROR: No username specified! Exiting." 34 | exit 35 | fi 36 | 37 | ############################################################## 38 | 39 | # Check for a running FTP server 40 | ftp_out="$(netstat -an | grep ':21 ' | grep LISTEN)" 41 | 42 | if [ "$ftp_out" ] 43 | then 44 | echo 45 | echo 46 | echo -e "\e[00;31mFTP ERROR: There is already a running FTP server on port 21:\e[00m" 47 | echo "$ftp_out" 48 | echo -e "\e[00;31mYou must manually stop the other FTP server first. SKIPPING FTP server installation.\e[00m" 49 | exit 50 | fi 51 | 52 | # Function to check required 53 | gpx_checkreq () { 54 | yum_cmd= 55 | apt_cmd= 56 | 57 | # Check GCC Compiler 58 | if [[ ! -f /usr/bin/make && ! -f /usr/local/bin/make && ! -f /bin/make ]]; then 59 | yum_cmd="gcc kernel-headers make" 60 | apt_cmd="build-essential" 61 | gentoo_cmd="sys-devel/gcc" 62 | elif [[ ! -f /usr/bin/gcc && ! -f /usr/local/bin/gcc && ! -f /bin/gcc ]]; then 63 | yum_cmd="gcc kernel-headers make" 64 | apt_cmd="build-essential" 65 | gentoo_cmd="sys-devel/gcc" 66 | fi 67 | } 68 | 69 | # Check required 70 | gpx_checkreq 71 | 72 | # CentOS / RedHat 73 | if [ -f /etc/redhat-release ] 74 | then 75 | if [ "$yum_cmd" ] 76 | then 77 | echo 78 | read -p "(RedHat) Missing requirements! Is it OK to install packages via Yum (yum install $yum_cmd)? (y/n): " gpx_ok_yum 79 | 80 | if [[ "$gpx_ok_yum" == "y" || "$gpx_ok_yum" == "yes" || "$gpx_ok_yum" == "Y" ]] 81 | then 82 | yum -y install $yum_cmd 83 | fi 84 | fi 85 | # Debian / Ubuntu 86 | elif [ -f /etc/debian_version ] 87 | then 88 | if [ "$apt_cmd" ] 89 | then 90 | echo 91 | read -p "(Debian) Missing requirements! Is it OK to install packages via APT (apt-get install $apt_cmd)? (y/n): " gpx_ok_apt 92 | 93 | if [[ "$gpx_ok_apt" == "y" || "$gpx_ok_apt" == "yes" || "$gpx_ok_apt" == "Y" ]] 94 | then 95 | apt-get --yes install $apt_cmd 96 | fi 97 | fi 98 | # Gentoo 99 | elif [ -f /etc/gentoo-release ] 100 | then 101 | if [ "$gentoo_cmd" ] 102 | then 103 | echo 104 | read -p "(Gentoo) Missing requirements! Is it OK to install packages via Portage (emerge $gentoo_cmd)? (y/n): " gpx_ok_gentoo 105 | 106 | if [[ "$gpx_ok_gentoo" == "y" || "$gpx_ok_gentoo" == "yes" || "$gpx_ok_gentoo" == "Y" ]] 107 | then 108 | emerge $gentoo_cmd 109 | fi 110 | fi 111 | fi 112 | 113 | # Check again 114 | gpx_checkreq 115 | 116 | if [ "$yum_cmd" ] 117 | then 118 | echo "ERROR: Unable to install the required packages! Please make sure GCC is installed and try again." 119 | exit 120 | fi 121 | 122 | echo 123 | echo -e "\e[00;32mRequirements passed! Installing FTP Server ...\e[00m" 124 | echo 125 | sleep 1 126 | 127 | ############################################################## 128 | 129 | # Prepare FTP Server 130 | rm -fr /usr/local/gpx/ftpd/src 131 | mkdir -p /usr/local/gpx/ftpd/src 132 | cd /usr/local/gpx/ftpd/src 133 | 134 | # Only download if needed 135 | if [ ! -f ./ftpd-latest.tar.gz ] 136 | then 137 | wget http://gamepanelx.com/files/ftpd-latest.tar.gz 138 | fi 139 | 140 | if [ ! -f ./ftpd-latest.tar.gz ] 141 | then 142 | echo "ERROR: Failed to download the latest FTP Server files! Exiting." 143 | exit 144 | fi 145 | 146 | # Compile FTP Server 147 | tar -zxf ftpd-latest.tar.gz 148 | cd ftpd-latest 149 | ./configure --prefix=/usr/local/gpx/ftpd 150 | sleep 1 151 | make 152 | sleep 1 153 | make install 154 | 155 | ################ 156 | 157 | if [ ! -f "/usr/local/gpx/ftpd/sbin/pure-ftpd" ] 158 | then 159 | echo 160 | echo -e "\e[00;31mERROR: The FTP Server installation failed (no binary). Check the output above for why the FTP installation failed. Exiting.\e[00m" 161 | exit 162 | fi 163 | 164 | ################ 165 | 166 | # Create startup script 167 | echo '#!/bin/bash' > /usr/local/gpx/ftpd/start.sh 168 | echo "/usr/local/gpx/ftpd/sbin/pure-ftpd -A -B -C 5 -c 150 -E -H -R -x -X -d -j" >> /usr/local/gpx/ftpd/start.sh 169 | chmod u+x /usr/local/gpx/ftpd/start.sh 170 | 171 | # Security 172 | chown root: /usr/local/gpx/ftpd -R 173 | chmod 600 /usr/local/gpx/ftpd 174 | 175 | # Start the FTP Server 176 | /usr/local/gpx/ftpd/start.sh 177 | sleep 2 178 | 179 | # Check if server is running 180 | ftp_pid="$(ps -ef | grep 'pure-ftpd (SERVER)' | grep -v grep | awk '{print $2}')" 181 | 182 | if [ "$ftp_pid" ] 183 | then 184 | # Save PID 185 | echo $ftp_pid > /usr/local/gpx/ftpd/pure-ftpd.pid 186 | 187 | echo -e "\e[00;32mFTP Server started successfully with PID $ftp_pid! \e[00m" 188 | else 189 | rm -f /usr/local/gpx/ftpd/pure-ftpd.pid 190 | 191 | echo -e "\e[00;31mFTP Server failed to start, no running PID found! \e[00m" 192 | fi 193 | 194 | ################ 195 | 196 | echo 197 | echo 198 | echo 199 | echo 200 | echo -e "\e[00;32mFinished Installing the FTP Server.\e[00m" 201 | echo 202 | -------------------------------------------------------------------------------- /gpx-remote-latest.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devryan/GamePanelX-V3-Remote/ff1ae57dd41c3c04110c8219bfaaaf559734b30b/gpx-remote-latest.tar.gz -------------------------------------------------------------------------------- /initscripts/daemon-start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | serverlog=/usr/local/gpx/logs/servers.log 3 | 4 | # Start manager 5 | /usr/local/gpx/bin/GPXManager 6 | 7 | # Start FTP server 8 | if [ -f /usr/local/gpx/ftpd/start.sh ]; then 9 | /usr/local/gpx/ftpd/start.sh 10 | fi 11 | 12 | # Start all previously running game servers 13 | if [ -d /usr/local/gpx/srv.d ]; then 14 | for gamesrv in $(ls /usr/local/gpx/srv.d); do 15 | if [ "$gamesrv" ]; then 16 | if [ -f /usr/local/gpx/srv.d/$gamesrv ]; then 17 | this_srvfile=/usr/local/gpx/srv.d/$gamesrv 18 | srv_user=$(grep '^user\:\ ' $this_srvfile | awk '{print $2}') 19 | srv_ip=$(grep '^ip\:\ ' $this_srvfile | awk '{print $2}') 20 | srv_port=$(grep '^port\:\ ' $this_srvfile | awk '{print $2}') 21 | srv_pid=$(grep '^pid\:\ ' $this_srvfile | awk '{print $2}') 22 | srv_workingdir=$(grep '^workingdir\:\ ' $this_srvfile | awk '{print $2}') 23 | srv_cmd=$(grep '^gpxcmd\:\ ' $this_srvfile | awk '{$1=""; print $0}') 24 | srv_taskset=$(grep '^taskset\:\ ' $this_srvfile | awk '{print $2}') 25 | 26 | # Ensure user exists 27 | if [ "$(grep "^gpx$srv_user:" /etc/passwd)" ]; then 28 | # Start up gameserver 29 | echo "$(date) $(hostname) initscript: Starting server $srv_ip:$srv_port for user $srv_user ..." >> $serverlog 30 | su - gpx$srv_user -c "/usr/local/gpx/bin/Restart -u $srv_user -i $srv_ip -p $srv_port -P \"$srv_pid\" -w \"$srv_workingdir\" -o '$srv_cmd'" >> /dev/null 2>&1 & 31 | else 32 | echo "$(date) $(hostname) initscript: Found srv.d/$gamesrv for startup, but user did not exist. Skipping." >> $serverlog 33 | fi 34 | fi 35 | fi 36 | done 37 | fi 38 | -------------------------------------------------------------------------------- /initscripts/daemon-stop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Stop manager 4 | if [ -f /usr/local/gpx/gpxmanager.pid ]; then 5 | pid_gpxman=$(cat /usr/local/gpx/gpxmanager.pid) 6 | 7 | if [ -e /proc/$pid_gpxman ]; then 8 | kill $(cat /usr/local/gpx/gpxmanager.pid) 9 | fi 10 | fi 11 | 12 | # Stop FTP server 13 | if [ -f /usr/local/gpx/ftpd/start.sh ]; then 14 | if [ "$(ps -ef | grep 'pure-ftpd (SERVER)' | grep -v grep)" ]; then 15 | killall pure-ftpd 16 | fi 17 | fi 18 | 19 | # Stop all previously running game servers 20 | if [ -d /usr/local/gpx/srv.d ]; then 21 | for gamesrv in $(ls /usr/local/gpx/srv.d); do 22 | if [ "$gamesrv" ]; then 23 | if [ -f /usr/local/gpx/srv.d/$gamesrv ]; then 24 | this_srvfile=/usr/local/gpx/srv.d/$gamesrv 25 | srv_user=$(grep '^user\:\ ' $this_srvfile | awk '{print $2}') 26 | srv_ip=$(grep '^ip\:\ ' $this_srvfile | awk '{print $2}') 27 | srv_port=$(grep '^port\:\ ' $this_srvfile | awk '{print $2}') 28 | srv_pid=$(grep '^pid\:\ ' $this_srvfile | awk '{print $2}') 29 | srv_workingdir=$(grep '^workingdir\:\ ' $this_srvfile | awk '{print $2}') 30 | srv_cmd=$(grep '^gpxcmd\:\ ' $this_srvfile | awk '{$1=""; print $0}') 31 | srv_taskset=$(grep '^taskset\:\ ' $this_srvfile | awk '{print $2}') 32 | 33 | # Ensure user exists 34 | if [ "$(grep "^gpx$srv_user:" /etc/passwd)" ]; then 35 | # Use the proper current script PID 36 | if [ "$BASHPID" ] 37 | then 38 | script_pid=$BASHPID 39 | else 40 | script_pid=$$ 41 | fi 42 | 43 | # Stop gameserver 44 | echo "$(date) $(hostname) initscript: Stopping server $srv_ip:$srv_port for user $srv_user ..." >> $serverlog 45 | su - gpx$srv_user -c "/usr/local/gpx/bin/Stop -u $srv_user -i $srv_ip -p $srv_port -r $script_pid -n yes" >> /dev/null 2>&1 & 46 | else 47 | echo "$(date) $(hostname) initscript: Found srv.d/$gamesrv file, but user did not exist. Skipping." >> $serverlog 48 | fi 49 | fi 50 | fi 51 | done 52 | fi 53 | -------------------------------------------------------------------------------- /initscripts/debian-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: gpx 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Start GamePanelX Remote at boot time 9 | # Description: GamePanelX Remote 10 | ### END INIT INFO 11 | 12 | set -e 13 | 14 | # /etc/init.d/gpx: start and stop the GamePanelX Remote daemon(s) 15 | 16 | test -x /usr/local/gpx/bin/GPXManager || exit 0 17 | umask 022 18 | . /lib/lsb/init-functions 19 | 20 | case "$1" in 21 | start) 22 | log_daemon_msg "Starting GamePanelX Remote" "gpx" || true 23 | if start-stop-daemon --start --quiet --oknodo --pid /usr/local/gpx/gpxmanager.pid --exec /usr/local/gpx/bin/daemon-start; then 24 | log_end_msg 0 || true 25 | else 26 | log_end_msg 1 || true 27 | fi 28 | ;; 29 | stop) 30 | log_daemon_msg "Stopping GamePanelX Remote" "gpx" || true 31 | if start-stop-daemon --start --quiet --oknodo --pid /usr/local/gpx/gpxmanager.pid --exec /usr/local/gpx/bin/daemon-stop; then 32 | log_end_msg 0 || true 33 | else 34 | log_end_msg 1 || true 35 | fi 36 | ;; 37 | restart) 38 | log_daemon_msg "Restarting GamePanelX Remote" "gpx" || true 39 | start-stop-daemon --start --quiet --oknodo --retry 30 --pid /usr/local/gpx/gpxmanager.pid --exec /usr/local/gpx/bin/daemon-stop 40 | if start-stop-daemon --start --quiet --oknodo --exec /usr/local/gpx/bin/daemon-start; then 41 | log_end_msg 0 || true 42 | else 43 | log_end_msg 1 || true 44 | fi 45 | ;; 46 | *) 47 | log_action_msg "Usage: /etc/init.d/gpx {start|stop|restart}" || true 48 | exit 1 49 | esac 50 | exit 0 51 | -------------------------------------------------------------------------------- /initscripts/gentoo-init.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/runscript 2 | # GamePanelX Remote 3 | 4 | depend() { 5 | need net 6 | } 7 | 8 | start() { 9 | ebegin "Starting GamePanelX Remote" 10 | start-stop-daemon --start --quiet --oknodo --pid /usr/local/gpx/gpxmanager.pid --exec /usr/local/gpx/bin/daemon-start 11 | eend $? 12 | } 13 | 14 | stop() { 15 | ebegin "Stopping GamePanelX Remote" 16 | start-stop-daemon --start --quiet --oknodo --pid /usr/local/gpx/gpxmanager.pid --exec /usr/local/gpx/bin/daemon-stop 17 | eend $? 18 | } 19 | -------------------------------------------------------------------------------- /initscripts/redhat-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## 3 | # GamePanelX V3 4 | # RedHat/CentOS/Fedora initscript 5 | # chkconfig: 345 55 25 6 | # description: GamePanelX Remote 7 | # 8 | if [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions; fi 9 | serverlog=/usr/local/gpx/logs/servers.log 10 | 11 | case "$1" in 12 | start) 13 | echo -n "Starting GamePanelX Manager:" 14 | 15 | # Start manager 16 | /usr/local/gpx/bin/GPXManager 17 | 18 | # Start FTP server 19 | if [ -f /usr/local/gpx/ftpd/start.sh ]; then 20 | /usr/local/gpx/ftpd/start.sh 21 | fi 22 | 23 | # Start all previously running game servers 24 | if [ -d /usr/local/gpx/srv.d ]; then 25 | for gamesrv in $(ls /usr/local/gpx/srv.d); do 26 | if [ "$gamesrv" ]; then 27 | if [ -f /usr/local/gpx/srv.d/$gamesrv ]; then 28 | this_srvfile=/usr/local/gpx/srv.d/$gamesrv 29 | srv_user=$(grep '^user\:\ ' $this_srvfile | awk '{print $2}') 30 | srv_ip=$(grep '^ip\:\ ' $this_srvfile | awk '{print $2}') 31 | srv_port=$(grep '^port\:\ ' $this_srvfile | awk '{print $2}') 32 | srv_pid=$(grep '^pid\:\ ' $this_srvfile | awk '{print $2}') 33 | srv_workingdir=$(grep '^workingdir\:\ ' $this_srvfile | awk '{print $2}') 34 | srv_cmd=$(grep '^gpxcmd\:\ ' $this_srvfile | awk '{$1=""; print $0}') 35 | srv_taskset=$(grep '^taskset\:\ ' $this_srvfile | awk '{print $2}') 36 | 37 | # Ensure user exists 38 | if [ "$(grep "^gpx$srv_user:" /etc/passwd)" ]; then 39 | # Start up gameserver 40 | echo "$(date) $(hostname) initscript: Starting server $srv_ip:$srv_port for user $srv_user ..." >> $serverlog 41 | su - gpx$srv_user -c "/usr/local/gpx/bin/Restart -u $srv_user -i $srv_ip -p $srv_port -P \"$srv_pid\" -w \"$srv_workingdir\" -o '$srv_cmd'" >> /dev/null 2>&1 & 42 | else 43 | echo "$(date) $(hostname) initscript: Found srv.d/$gamesrv for startup, but user did not exist. Skipping." >> $serverlog 44 | fi 45 | fi 46 | fi 47 | done 48 | fi 49 | 50 | echo_success 51 | echo 52 | ;; 53 | stop) 54 | echo -n "Stopping GamePanelX Manager:" 55 | 56 | # Stop manager 57 | if [ -f /usr/local/gpx/gpxmanager.pid ]; then 58 | pid_gpxman=$(cat /usr/local/gpx/gpxmanager.pid) 59 | 60 | if [ -e /proc/$pid_gpxman ]; then 61 | kill $(cat /usr/local/gpx/gpxmanager.pid) 62 | fi 63 | fi 64 | 65 | # Stop FTP server 66 | if [ -f /usr/local/gpx/ftpd/start.sh ]; then 67 | if [ "$(ps -ef | grep 'pure-ftpd (SERVER)' | grep -v grep)" ]; then 68 | killall pure-ftpd 69 | fi 70 | fi 71 | 72 | # Stop all previously running game servers 73 | if [ -d /usr/local/gpx/srv.d ]; then 74 | for gamesrv in $(ls /usr/local/gpx/srv.d); do 75 | if [ "$gamesrv" ]; then 76 | if [ -f /usr/local/gpx/srv.d/$gamesrv ]; then 77 | this_srvfile=/usr/local/gpx/srv.d/$gamesrv 78 | srv_user=$(grep '^user\:\ ' $this_srvfile | awk '{print $2}') 79 | srv_ip=$(grep '^ip\:\ ' $this_srvfile | awk '{print $2}') 80 | srv_port=$(grep '^port\:\ ' $this_srvfile | awk '{print $2}') 81 | srv_pid=$(grep '^pid\:\ ' $this_srvfile | awk '{print $2}') 82 | srv_workingdir=$(grep '^workingdir\:\ ' $this_srvfile | awk '{print $2}') 83 | srv_cmd=$(grep '^gpxcmd\:\ ' $this_srvfile | awk '{$1=""; print $0}') 84 | srv_taskset=$(grep '^taskset\:\ ' $this_srvfile | awk '{print $2}') 85 | 86 | # Ensure user exists 87 | if [ "$(grep "^gpx$srv_user:" /etc/passwd)" ]; then 88 | # Use the proper current script PID 89 | if [ "$BASHPID" ] 90 | then 91 | script_pid=$BASHPID 92 | else 93 | script_pid=$$ 94 | fi 95 | 96 | # Stop gameserver 97 | echo "$(date) $(hostname) initscript: Stopping server $srv_ip:$srv_port for user $srv_user ..." >> $serverlog 98 | su - gpx$srv_user -c "/usr/local/gpx/bin/Stop -u $srv_user -i $srv_ip -p $srv_port -r $script_pid -n yes" >> /dev/null 2>&1 & 99 | else 100 | echo "$(date) $(hostname) initscript: Found srv.d/$gamesrv file, but user did not exist. Skipping." >> $serverlog 101 | fi 102 | fi 103 | fi 104 | done 105 | fi 106 | 107 | echo_success 108 | echo 109 | ;; 110 | restart) 111 | $0 stop 112 | $0 start 113 | ;; 114 | *) 115 | echo "usage: $0 [start|stop|restart|condrestart]" 116 | esac 117 | exit 0 118 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote Scripts v3.0.15 5 | # 6 | # Installation Script 7 | # NOTE: These scripts should work on RedHat, Debian, and Gentoo Linux distributions. 8 | # 9 | # Licensed under the GPL (GNU General Public License V3) 10 | # 11 | remote_version="3.0.15" 12 | echo -e "\e[00;34m##################################################################" 13 | echo " " 14 | echo " GamePanelX " 15 | echo " " 16 | echo " Welcome to the Remote Server installer (v$remote_version)" 17 | echo " " 18 | echo -e "##################################################################\e[00m" 19 | echo 20 | 21 | if [ "$UID" -ne "0" ] 22 | then 23 | echo "ERROR: You must be the root user to run this script. Exiting." 24 | exit 25 | fi 26 | 27 | ## Detect Linux OS 28 | # CentOS / RedHat 29 | if [ -f /etc/redhat-release ]; then 30 | os="redhat" 31 | # Debian / Ubuntu 32 | elif [ -f /etc/debian_version ]; then 33 | os="debian" 34 | # Gentoo 35 | elif [ -f /etc/gentoo-release ]; then 36 | os="gentoo" 37 | else 38 | os="unknown" 39 | echo 'WARNING: You are using an unsupported Linux version! Continue at your own risk!' 40 | echo 41 | fi 42 | 43 | # Check for GNU Screen 44 | if [ "$(which screen 2>&1 | grep 'no screen in')" ] 45 | then 46 | # CentOS / RedHat 47 | if [ $os == "redhat" ]; then 48 | echo 49 | read -p "(RedHat) Missing requirements. Is it OK to install packages via Yum (yum install screen)? (y/n): " gpx_ok_yum 50 | 51 | if [[ "$gpx_ok_yum" == "y" || "$gpx_ok_yum" == "yes" || "$gpx_ok_yum" == "Y" ]] 52 | then 53 | yum -y install screen 54 | fi 55 | # Debian / Ubuntu 56 | elif [ $os == "debian" ]; then 57 | echo 58 | read -p "(Debian) Missing requirements. Is it OK to install packages via APT (apt-get install screen)? (y/n): " gpx_ok_apt 59 | 60 | if [[ "$gpx_ok_apt" == "y" || "$gpx_ok_apt" == "yes" || "$gpx_ok_apt" == "Y" ]] 61 | then 62 | apt-get --yes install screen 63 | fi 64 | # Gentoo 65 | elif [ $os == "gentoo" ]; then 66 | echo 67 | read -p "(Gentoo) Missing requirements. Is it OK to install packages via Portage (emerge screen)? (y/n): " gpx_ok_gentoo 68 | 69 | if [[ "$gpx_ok_gentoo" == "y" || "$gpx_ok_gentoo" == "yes" || "$gpx_ok_gentoo" == "Y" ]] 70 | then 71 | emerge screen 72 | fi 73 | fi 74 | fi 75 | 76 | ############################################################## 77 | 78 | # User input 79 | read -p "Create this Linux user for game/voice servers (default: gpx): " gpx_user 80 | echo 81 | 82 | # Check required 83 | if [ "$gpx_user" == "" ]; then 84 | gpx_user="gpx" 85 | fi 86 | 87 | # Check if user already exists 88 | if [ "$(grep "^$gpx_user:" /etc/passwd)" ] 89 | then 90 | echo "ERROR: That user ($gpx_user) already exists. Please choose a different username and try again. Exiting." 91 | exit 92 | fi 93 | 94 | # Create the main /usr/local/gpx 95 | if [ -d /usr/local/gpx ] 96 | then 97 | echo "GPX directory (/usr/local/gpx) already exists. Please uninstall first if you wish to start over. Exiting." 98 | exit 99 | else 100 | mkdir /usr/local/gpx 101 | fi 102 | 103 | # Create the gpx user 104 | useradd -m -c "GamePanelX" -s /bin/bash $gpx_user 105 | gpx_user_home="/usr/local/gpx" 106 | 107 | # Log this username 108 | echo $gpx_user > $gpx_user_home/.gpx_lastuser 109 | 110 | # Make sure homedir exists 111 | if [ ! -d "$gpx_user_home" ] 112 | then 113 | echo "ERROR: Failed to find the users homedir. Exiting." 114 | exit 115 | fi 116 | 117 | # Untar the Remote files 118 | if [ -f "./gpx-remote-latest.tar.gz" ] 119 | then 120 | tar -zxf ./gpx-remote-latest.tar.gz -C $gpx_user_home/ 121 | else 122 | echo "ERROR: Latest remote server files (./gpx-remote-latest.tar.gz) not found. Try re-downloading the remote files and try again. Exiting." 123 | exit 124 | fi 125 | 126 | # Change ownership of all the new files 127 | chown $gpx_user: $gpx_user_home -R 128 | chown root:$gpx_user $gpx_user_home/users -R 129 | chown root: $gpx_user_home/ftpd -R 130 | chmod 0660 $gpx_user_home/users -R 131 | chmod 0750 $gpx_user_home/{logs,templates} -R 132 | chmod 0660 $gpx_user_home/logs/* 133 | chmod 0700 $gpx_user_home/{addons,queue,tmp,etc,uploads,users} -R 134 | chmod 0760 $gpx_user_home/queue $gpx_user_home/tmp 135 | chmod 0774 $gpx_user_home/users 136 | chmod 0555 $gpx_user_home/bin 137 | chmod 0754 $gpx_user_home/bin/* 138 | 139 | # Setup config 140 | touch $gpx_user_home/etc/config.cfg 141 | echo > $gpx_user_home/etc/config.cfg 142 | > $gpx_user_home/etc/config.cfg 143 | echo "username: $gpx_user" >> $gpx_user_home/etc/config.cfg 144 | echo "version: $remote_version" >> $gpx_user_home/etc/config.cfg 145 | 146 | # Set system password 147 | echo 148 | echo "-- Enter a password for GamePanelX user \"$gpx_user\" " 149 | passwd $gpx_user 150 | 151 | ############################################################################################################# 152 | 153 | # Only allow gpx* users to login from the master 154 | if [ "$gpx_master_ip" ] 155 | then 156 | read -p "Modify SSH config to only allow GPX SSH logins from the Master server network? (Highly Recommended) (y/n): " gpx_ssh_answer 157 | 158 | if [[ "$gpx_ssh_answer" == "y" || "$gpx_ssh_answer" == "yes" || "$gpx_ssh_answer" == "Y" ]] 159 | then 160 | read -p "Primary Master Server IP: " gpx_master_ip 161 | 162 | # Split up IP for wildcards 163 | ip_net="$(echo $gpx_master_ip | awk -F'.' '{print $1"."$2"."$3}')" 164 | 165 | # Comment any current AllowUsers lines 166 | sed -i 's/^AllowUsers/\# Old\: AllowUsers/g' /etc/ssh/sshd_config 167 | 168 | # Add our new line 169 | echo >> /etc/ssh/sshd_config 170 | echo '# Automatically added by GamePanelX' >> /etc/ssh/sshd_config 171 | echo "AllowUsers root $gpx_user gpx*@$ip_net* gpx*@127.0.0.1" >> /etc/ssh/sshd_config 172 | 173 | # Restart SSHD 174 | if [ -f /sbin/service ]; then 175 | /sbin/service sshd restart 176 | elif [ -f /etc/init.d/sshd ]; then 177 | /etc/init.d/sshd restart 178 | elif [ -f /etc/init.d/ssh ]; then 179 | /etc/init.d/ssh restart 180 | elif [ -f /etc/rc.d/sshd ]; then 181 | /etc/rc.d/sshd restart 182 | else 183 | echo "Failed to find the SSH server location. Please manually restart the SSH server." 184 | fi 185 | 186 | echo 187 | echo "Modified and restarted the SSH server. Make sure to edit /etc/ssh/sshd_config if you need any more users allowed." 188 | else 189 | echo "NOT modifying SSH config." 190 | fi 191 | fi 192 | 193 | # Kill old manager processes 194 | if [ "$(ps -ef | grep GPXManager | grep -v grep)" ]; then 195 | killall GPXManager 196 | fi 197 | 198 | # Start the manager daemon 199 | /usr/local/gpx/bin/GPXManager 200 | 201 | # Setup initscript 202 | 203 | # RedHat / CentOS / Fedora 204 | if [ $os == "redhat" ]; then 205 | echo "Adding RedHat system GamePanelX service ..." 206 | cp ./initscripts/redhat-init.sh /etc/init.d/gpx 207 | chmod u+x /etc/init.d/gpx 208 | chkconfig gpx on 209 | # Ubuntu / Debian 210 | elif [ $os == "debian" ]; then 211 | echo "Adding Debian/Ubuntu system GamePanelX service ..." 212 | cp ./initscripts/debian-init.sh /etc/init.d/gpx 213 | cp ./initscripts/daemon-st* $gpx_user_home/bin/ 214 | chown root:root $gpx_user_home/bin/daemon-st* 215 | chmod 0700 $gpx_user_home/bin/daemon-st* 216 | chmod u+x /etc/init.d/gpx 217 | update-rc.d gpx defaults 218 | # Gentoo 219 | elif [ $os == "gentoo" ]; then 220 | echo "Adding Gentoo system GamePanelX service ..." 221 | cp ./initscripts/gentoo-init.sh /etc/init.d/gpx 222 | cp ./initscripts/daemon-st* $gpx_user_home/bin/ 223 | chown root:root $gpx_user_home/bin/daemon-st* 224 | chmod 0700 $gpx_user_home/bin/daemon-st* 225 | chmod u+x /etc/init.d/gpx 226 | rc-update add gpx default 227 | fi 228 | 229 | ############################################################################################################# 230 | 231 | # Gameserver dependencies 232 | if [ $os == "debian" ]; then 233 | pkg_list= 234 | 235 | if [ "$(dpkg --get-selections | grep lib32gcc1 | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" lib32gcc1"; fi 236 | if [ "$(dpkg --get-selections | grep lib32bz2 | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" lib32bz2-1.0"; fi 237 | if [ "$(dpkg --get-selections | grep lib32ncurses5 | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" lib32ncurses5"; fi 238 | if [ "$(dpkg --get-selections | grep lib32tinfo5 | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" lib32tinfo5"; fi 239 | if [ "$(dpkg --get-selections | grep lib32z1 | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" lib32z1"; fi 240 | if [ "$(dpkg --get-selections | grep libc6 | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" libc6"; fi 241 | if [ "$(dpkg --get-selections | grep 'libstdc++6' | grep -v deinstall)" == "" ]; then pkg_list=$pkg_list" libstdc++6"; fi 242 | 243 | if [ "$pkg_list" ]; then 244 | echo 245 | echo "There are some missing packages that are required for certain gameservers." 246 | echo "Packages required: $pkg_list" 247 | read -p "Install these now? (y/n): " install_gs_pkgs 248 | 249 | if [[ "$install_gs_pkgs" == "y" || "$install_gs_pkgs" == "yes" || "$install_gs_pkgs" == "Y" ]]; then 250 | apt-get -y install $pkg_list 251 | fi 252 | fi 253 | elif [ $os == "redhat" ]; then 254 | if [ "$(yum list installed | grep 'glibc.i686')" == "" ]; then pkg_list=$pkg_list" glibc.i686"; fi 255 | if [ "$(yum list installed | grep 'libstdc++.i686')" == "" ]; then pkg_list=$pkg_list" libstdc++.i686"; fi 256 | if [ "$(yum list installed | grep 'libgcc_s.so.1')" == "" ]; then pkg_list=$pkg_list" libgcc_s.so.1"; fi 257 | if [ "$(yum list installed | grep 'libgcc.i686')" == "" ]; then pkg_list=$pkg_list" libgcc.i686"; fi 258 | if [ "$(yum list installed | grep 'java-')" == "" ]; then pkg_list=$pkg_list" java"; fi 259 | 260 | if [ "$pkg_list" ]; then 261 | echo 262 | echo "There are some missing packages that are required for certain gameservers." 263 | echo "Packages required: $pkg_list" 264 | read -p "Install these now? (y/n): " install_gs_pkgs 265 | 266 | if [[ "$install_gs_pkgs" == "y" || "$install_gs_pkgs" == "yes" || "$install_gs_pkgs" == "Y" ]]; then 267 | yum -y install $pkg_list 268 | fi 269 | fi 270 | fi 271 | 272 | ############################################################################################################# 273 | 274 | # FTP Server Installation 275 | echo;echo 276 | read -p "Install GamePanelX FTP server? (y/n): " gpx_ftp_ans 277 | 278 | if [[ "$gpx_ftp_ans" == "y" || "$gpx_ftp_ans" == "yes" || "$gpx_ftp_ans" == "Y" ]] 279 | then 280 | if [ ! -f ./ftp.sh ] 281 | then 282 | echo 'No FTP script (./ftp.sh) found! Exiting.' 283 | exit 284 | fi 285 | 286 | chmod u+x ftp.sh 287 | ./ftp.sh -u $gpx_user 288 | fi 289 | 290 | echo 291 | echo 292 | echo "##################################################################" 293 | echo 294 | echo -e "\e[00;32mCompleted GamePanelX Remote Server Installation. \e[00m" 295 | echo 296 | exit 297 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote Scripts v3.0.15 5 | # 6 | # Removal Script (Remove last known gpx system user if available) 7 | # 8 | # Licensed under the GPL (GNU General Public License V3) 9 | # 10 | echo -e "\e[00;34mWelcome to the GamePanelX uninstaller!" 11 | echo -e "This will attempt to remove any GamePanelX-related files.\e[00m" 12 | echo 13 | 14 | ## Detect Linux OS 15 | # CentOS / RedHat 16 | if [ -f /etc/redhat-release ]; then 17 | os="redhat" 18 | # Debian / Ubuntu 19 | elif [ -f /etc/debian_version ]; then 20 | os="debian" 21 | # Gentoo 22 | elif [ -f /etc/gentoo-release ]; then 23 | os="gentoo" 24 | else 25 | os="unknown" 26 | echo 'WARNING: You are using an unsupported Linux version! Continue at your own risk!' 27 | echo 28 | fi 29 | 30 | read -p "Are you sure? Remove ALL GamePanelX Remote files? (y/n): " gpx_sure_remove 31 | 32 | if [[ "$gpx_sure_remove" == "y" || "$gpx_sure_remove" == "yes" || "$gpx_sure_remove" == "Y" ]] 33 | then 34 | # Optionally remove client system accounts 35 | echo 36 | total_clients=$(grep -c ':GamePanelX User:' /etc/passwd) 37 | 38 | if [ $total_clients -gt 0 ]; then 39 | read -p "Also remove ALL GamePanelX client system accounts (e.g. gpxuser123) from this server? (y/n): " gpx_sure_rm_clients 40 | 41 | if [[ "$gpx_sure_rm_clients" == "y" || "$gpx_sure_rm_clients" == "yes" || "$gpx_sure_rm_clients" == "Y" ]]; then 42 | echo "OK, removing ALL GamePanelX client system accounts ($total_clients total) in 4 seconds (CTRL+C to stop) ..." 43 | sleep 4 44 | 45 | for gpxclient in $(grep ':GamePanelX User:' /etc/passwd | awk -F':' '{print $1}' | grep -E '^gpx') 46 | do 47 | if [[ "$gpxclient" && "$gpxclient" != "root" ]]; then 48 | echo "Removing system account $gpxclient and their homedir ..." 49 | userdel -r $gpxclient 50 | fi 51 | done 52 | else 53 | echo "We will NOT be removing any GamePanelX client system accounts." 54 | fi 55 | fi 56 | 57 | # Remove main user account 58 | if [ -f .gpx_lastuser ] 59 | then 60 | last_user="$(cat /usr/local/gpx/.gpx_lastuser)" 61 | else 62 | # Get last system GPX user in /etc/passwd 63 | last_user="$(grep ':GamePanelX:' /etc/passwd | tail -1 | awk -F: '{print $1}')" 64 | fi 65 | 66 | if [ "$last_user" == "" ] 67 | then 68 | echo -e "\e[00;31mUnable to determine the last known GamePanelX User!\e[00m" 69 | echo "If you know the system username, you can manually run:" 70 | echo 71 | echo "pkill pure-ftpd" 72 | echo "userdel someuser" 73 | echo 74 | echo "Otherwise, /usr/local/gpx has been removed. Exiting." 75 | exit 76 | fi 77 | 78 | echo "Found '$last_user' to be the most recent GamePanelX User." 79 | read -p "Remove this user? (y/n): " gpx_accept 80 | 81 | if [[ "$gpx_accept" == "y" || "$gpx_accept" == "yes" || "$gpx_accept" == "Y" ]] 82 | then 83 | echo "Removing $last_user and their homedir ..." 84 | userdel -r $last_user 85 | 86 | echo "Stopping FTP server ..." 87 | pkill pure-ftpd 88 | fi 89 | 90 | # Remove main directory 91 | echo "Removing /usr/local/gpx in 4 seconds (CTRL+C to stop) ..." 92 | sleep 4 93 | rm -fr /usr/local/gpx 94 | 95 | ## Stop services 96 | /etc/init.d/gpx stop 97 | 98 | ## Remove from boot 99 | 100 | # CentOS / RedHat 101 | if [ $os == "redhat" ]; then 102 | echo "Removing RedHat system GamePanelX service ..." 103 | chkconfig gpx off 104 | # Debian / Ubuntu 105 | elif [ $os == "debian" ]; then 106 | echo "Removing Debian system GamePanelX service ..." 107 | update-rc.d -f gpx remove 108 | # Gentoo 109 | elif [ $os == "gentoo" ]; then 110 | echo "Removing Gentoo system GamePanelX service ..." 111 | rc-update del gpx default 112 | fi 113 | rm -f /etc/init.d/gpx 114 | 115 | echo 116 | echo "Successfully removed GamePanelX Remote." 117 | fi 118 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote Scripts v3.0.15 5 | # 6 | # Update Script 7 | # 8 | # Licensed under the GPL (GNU General Public License V3) 9 | # 10 | remote_version="3.0.15" 11 | 12 | echo -e "\e[00;34m##################################################################" 13 | echo " " 14 | echo " GamePanelX " 15 | echo " " 16 | echo " Welcome to the Remote Update Script (v$remote_version) " 17 | echo " " 18 | echo -e "##################################################################\e[00m" 19 | echo 20 | 21 | if [ "$UID" -ne "0" ] 22 | then 23 | echo "ERROR: You must be the root user to run this script. Exiting." 24 | exit 25 | fi 26 | 27 | echo 28 | read -p "This will update the remote scripts to the latest. Continue? (y/n): " sure_upd 29 | 30 | if [[ "$sure_upd" == "y" || "$sure_upd" == "yes" || "$sure_upd" == "Y" ]] 31 | then 32 | if [ ! -f ./gpx-remote-latest.tar.gz ]; then 33 | echo "No file ./gpx-remote-latest.tar.gz found, exiting." 34 | exit 35 | fi 36 | 37 | tar -zxf ./gpx-remote-latest.tar.gz -C /usr/local/gpx bin/* 38 | else 39 | echo "Not updating, exiting." 40 | exit 41 | fi 42 | 43 | sleep 1 44 | 45 | ################################################################## 46 | 47 | # Stop manager 48 | if [ "$(ps -ef | grep 'GPXManager' | grep -v grep)" ]; then 49 | killall GPXManager 50 | fi 51 | 52 | # Start manager 53 | /usr/local/gpx/bin/GPXManager 54 | 55 | ################################################################## 56 | 57 | # Set permissions 58 | if [ -f .gpx_lastuser ] 59 | then 60 | gpx_user="$(cat /usr/local/gpx/.gpx_lastuser)" 61 | else 62 | # Get last system GPX user in /etc/passwd 63 | gpx_user="$(grep ':GamePanelX:' /etc/passwd | tail -1 | awk -F: '{print $1}')" 64 | fi 65 | 66 | if [ "$gpx_user" == "" ]; then 67 | echo "No gpx user found, exiting." 68 | exit 69 | fi 70 | 71 | #chown $gpx_user: /usr/local/gpx -R 72 | #chown root:$gpx_user /usr/local/gpx/users -R 73 | chown root: /usr/local/gpx/ftpd -R 74 | #chmod 0660 /usr/local/gpx/users -R 75 | chmod 0750 /usr/local/gpx/{logs,templates} -R 76 | chmod 0660 /usr/local/gpx/logs/* 77 | #chmod 0700 /usr/local/gpx/{addons,queue,tmp,etc,uploads,users} -R 78 | chmod 0700 /usr/local/gpx/{addons,queue,tmp,etc,uploads} -R 79 | chmod 0760 /usr/local/gpx/queue /usr/local/gpx/tmp 80 | chmod 0774 /usr/local/gpx/users 81 | chmod 0555 /usr/local/gpx/bin 82 | chmod 0754 /usr/local/gpx/bin/* 83 | 84 | ################################################################## 85 | 86 | # Run this update script 87 | upd_file="updates/$remote_version.sh" 88 | if [ -f $upd_file ]; then 89 | echo "Running ./$upd_file ..." 90 | chmod +x ./$upd_file 91 | ./$upd_file 92 | fi 93 | 94 | ################################################################## 95 | 96 | echo 97 | echo "...done" 98 | -------------------------------------------------------------------------------- /updates/3.0.15.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # GamePanelX 4 | # Remote Scripts v3.0.15 5 | # 6 | # Update Script 7 | # 8 | # Licensed under the GPL (GNU General Public License V3) 9 | # 10 | has_old_dirs= 11 | 12 | # Move ip:port accounts directories to ip.port, to fix games that dont like that : character 13 | for user in /usr/local/gpx/users/*; do 14 | for gamedir in $user/*; do 15 | # Only dirs names ip:port 16 | if [ "$(echo $gamedir | grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\:[0-9]+')" ]; then 17 | new_dir=$(echo $gamedir | sed 's/\:/\./g') 18 | 19 | echo "Found dir $gamedir, moving to $new_dir ..." 20 | mv -v $gamedir $new_dir 21 | has_old_dirs="y" 22 | fi 23 | #echo "Game Dir: $gamedir" 24 | done 25 | done 26 | 27 | if [ -z "$has_old_dirs" ]; then 28 | echo "No directories to update. Exiting." 29 | exit 1 30 | else 31 | echo 32 | echo "..done." 33 | fi 34 | -------------------------------------------------------------------------------- /upgrade_309_3012.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Upgrade GamePanelX Remote <= 3.0.9 to 3.0.12 3 | # Ryan Gehrig 4 | # 5 | echo 'Welcome to the GamePanelX Remote upgrade script!' 6 | echo 7 | read -p "Old GamePanelX System User? " gpxuser 8 | usr_exist="$(grep "^$gpxuser:" /etc/passwd)" 9 | 10 | if [[ "$gpxuser" == "" || "$usr_exist" == "" ]]; then 11 | echo "Empty user or that user account does not exist. Exiting." 12 | exit 13 | fi 14 | 15 | # Ensure old user had a gpx setup 16 | if [[ ! -d /home/$gpxuser/accounts || ! -d /home/$gpxuser/templates ]]; then 17 | echo "There does not appear to be a GamePanelX accounts or templates directory for that user ($gpxuser), exiting." 18 | exit 19 | fi 20 | 21 | # They must install 3.0.12 first (since it won't conflict, it's best to have it already done) 22 | if [ ! -d /usr/local/gpx ]; then 23 | echo "Please install GamePanelX Remote 3.0.12 first, then run this script!" 24 | exit 25 | fi 26 | 27 | for gpxnew_user in $(ls /home/$gpxuser/accounts); do 28 | # Generate random password (they can change it later) 29 | rand_pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo) 30 | 31 | # Create system user 32 | useradd -m -p "$rand_pass" -d /usr/local/gpx/users/$gpxnew_user -s /bin/bash -c "GamePanelX User" gpx$gpxnew_user 33 | gpasswd -a gpx$gpxnew_user $gpxuser 34 | gpasswd -d gpx$gpxnew_user wheel 2>&1 >> /dev/null 35 | 36 | # Check 37 | if [ ! -d /usr/local/gpx/users/$gpxnew_user ]; then 38 | echo "User ($user) account directory (/usr/local/gpx/users/$gpxnew_user) not created! Exiting." 39 | exit 40 | fi 41 | 42 | # Move old files over 43 | mv /home/$gpxuser/accounts/$gpxnew_user/* /usr/local/gpx/users/$gpxnew_user/ 44 | chown gpx$gpxnew_user: /usr/local/gpx/users/$gpxnew_user -R 45 | done 46 | 47 | # Move old templates over 48 | mv /home/$gpxuser/templates/* /usr/local/gpx/templates/ 49 | 50 | echo 51 | echo 52 | echo 'Successfully upgraded to 3.0.12!' 53 | echo 54 | echo 55 | 56 | read -p "Remove old gamepanelx directories? (y/n): " rm_old 57 | 58 | if [[ "$rm_old" == "y" || "$rm_old" == "yes" || "$rm_old" == "Y" || "$rm_old" == "YES" ]]; then 59 | rm -fr /home/$gpxuser/* 60 | fi 61 | 62 | echo 63 | echo 64 | echo 'Complete!' 65 | 66 | --------------------------------------------------------------------------------