From d1a5f0523d3929a8901961c72c9a22f17f7f20e3 Mon Sep 17 00:00:00 2001 From: seokho-son Date: Tue, 4 Jan 2022 11:22:07 +0900 Subject: [PATCH 1/3] Add scripts for FPS game usecase --- scripts/usecases/startServer.sh | 44 ++++++++++++++++++++++++++++++++ scripts/usecases/statusServer.sh | 17 ++++++++++++ scripts/usecases/stopServer.sh | 14 ++++++++++ 3 files changed, 75 insertions(+) create mode 100644 scripts/usecases/startServer.sh create mode 100644 scripts/usecases/statusServer.sh create mode 100644 scripts/usecases/stopServer.sh diff --git a/scripts/usecases/startServer.sh b/scripts/usecases/startServer.sh new file mode 100644 index 000000000..ede996062 --- /dev/null +++ b/scripts/usecases/startServer.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +echo "[Start Xonotic FPS Game Server]" + +SECONDS=0 + +echo "Installing Xonotic to instance..." +FILE="xonotic-0.8.2.zip" + +#InstallFilePath="https://.../$FILE" +InstallFilePath="https://z.xnz.me/xonotic/builds/$FILE" + +if test -f "$FILE"; then + echo "$FILE exists." +else + sudo apt-get update > /dev/null; wget $InstallFilePath +fi + +DIR="Xonotic" + +if test -d "$DIR"; then + echo "$DIR directory exists." +else + sudo apt install unzip -y; unzip $FILE +fi + +echo "" + +echo "Launching Xonotic dedicated server" + +cd Xonotic/; nohup ./xonotic-linux64-dedicated 1>server.log 2>&1 & + +echo "Done! elapsed time: $SECONDS" + +IP=$(curl https://api.ipify.org) + +PID=$(ps -ef | grep [x]onotic | awk '{print $2}') + +cat ~/Xonotic/server.log + +echo "" +echo "[Start Xonotic: complete] PID=$PID" +echo "Access to $IP:26000 by using your Xonotic Client" +echo "" diff --git a/scripts/usecases/statusServer.sh b/scripts/usecases/statusServer.sh new file mode 100644 index 000000000..2621f8525 --- /dev/null +++ b/scripts/usecases/statusServer.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "[Stop Xonotic FPS Game]" + +echo "" +echo "[Current server.log]" +cat ~/Xonotic/server.log +echo "" + +PID=$(ps -ef | grep [x]onotic | awk '{print $2}') +kill $PID +echo "" +echo "[Stop Xonotic] PID=$PID" + +ps -ef | grep [x]onotic + +echo "" diff --git a/scripts/usecases/stopServer.sh b/scripts/usecases/stopServer.sh new file mode 100644 index 000000000..641ee30c2 --- /dev/null +++ b/scripts/usecases/stopServer.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "[Status Xonotic FPS Game]" + +echo "" +echo "[Xonotic Server.log so far]" +cat ~/Xonotic/server.log +echo "" + +PS=$(ps -ef | head -1; ps -ef | grep [x]onotic) +echo "[Process status of Xonotic]" +echo "$PS" + +echo "" From 9447fae826d522c549fc9e56e487d6f20fe7e701 Mon Sep 17 00:00:00 2001 From: seokho-son Date: Tue, 4 Jan 2022 11:46:25 +0900 Subject: [PATCH 2/3] Move game scripts to right dir --- scripts/usecases/startServer.sh | 44 -------------------------------- scripts/usecases/statusServer.sh | 17 ------------ scripts/usecases/stopServer.sh | 14 ---------- 3 files changed, 75 deletions(-) delete mode 100644 scripts/usecases/startServer.sh delete mode 100644 scripts/usecases/statusServer.sh delete mode 100644 scripts/usecases/stopServer.sh diff --git a/scripts/usecases/startServer.sh b/scripts/usecases/startServer.sh deleted file mode 100644 index ede996062..000000000 --- a/scripts/usecases/startServer.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -echo "[Start Xonotic FPS Game Server]" - -SECONDS=0 - -echo "Installing Xonotic to instance..." -FILE="xonotic-0.8.2.zip" - -#InstallFilePath="https://.../$FILE" -InstallFilePath="https://z.xnz.me/xonotic/builds/$FILE" - -if test -f "$FILE"; then - echo "$FILE exists." -else - sudo apt-get update > /dev/null; wget $InstallFilePath -fi - -DIR="Xonotic" - -if test -d "$DIR"; then - echo "$DIR directory exists." -else - sudo apt install unzip -y; unzip $FILE -fi - -echo "" - -echo "Launching Xonotic dedicated server" - -cd Xonotic/; nohup ./xonotic-linux64-dedicated 1>server.log 2>&1 & - -echo "Done! elapsed time: $SECONDS" - -IP=$(curl https://api.ipify.org) - -PID=$(ps -ef | grep [x]onotic | awk '{print $2}') - -cat ~/Xonotic/server.log - -echo "" -echo "[Start Xonotic: complete] PID=$PID" -echo "Access to $IP:26000 by using your Xonotic Client" -echo "" diff --git a/scripts/usecases/statusServer.sh b/scripts/usecases/statusServer.sh deleted file mode 100644 index 2621f8525..000000000 --- a/scripts/usecases/statusServer.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "[Stop Xonotic FPS Game]" - -echo "" -echo "[Current server.log]" -cat ~/Xonotic/server.log -echo "" - -PID=$(ps -ef | grep [x]onotic | awk '{print $2}') -kill $PID -echo "" -echo "[Stop Xonotic] PID=$PID" - -ps -ef | grep [x]onotic - -echo "" diff --git a/scripts/usecases/stopServer.sh b/scripts/usecases/stopServer.sh deleted file mode 100644 index 641ee30c2..000000000 --- a/scripts/usecases/stopServer.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -echo "[Status Xonotic FPS Game]" - -echo "" -echo "[Xonotic Server.log so far]" -cat ~/Xonotic/server.log -echo "" - -PS=$(ps -ef | head -1; ps -ef | grep [x]onotic) -echo "[Process status of Xonotic]" -echo "$PS" - -echo "" From 9a40d76f3a78c9af8e0fa7079b6c998cd8a49b10 Mon Sep 17 00:00:00 2001 From: seokho-son Date: Tue, 4 Jan 2022 13:21:05 +0900 Subject: [PATCH 3/3] Fix wrong switched scripts --- scripts/usecases/xonotic/statusServer.sh | 13 +++++-------- scripts/usecases/xonotic/stopServer.sh | 15 +++++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/usecases/xonotic/statusServer.sh b/scripts/usecases/xonotic/statusServer.sh index 2621f8525..641ee30c2 100644 --- a/scripts/usecases/xonotic/statusServer.sh +++ b/scripts/usecases/xonotic/statusServer.sh @@ -1,17 +1,14 @@ #!/bin/bash -echo "[Stop Xonotic FPS Game]" +echo "[Status Xonotic FPS Game]" echo "" -echo "[Current server.log]" +echo "[Xonotic Server.log so far]" cat ~/Xonotic/server.log echo "" -PID=$(ps -ef | grep [x]onotic | awk '{print $2}') -kill $PID -echo "" -echo "[Stop Xonotic] PID=$PID" - -ps -ef | grep [x]onotic +PS=$(ps -ef | head -1; ps -ef | grep [x]onotic) +echo "[Process status of Xonotic]" +echo "$PS" echo "" diff --git a/scripts/usecases/xonotic/stopServer.sh b/scripts/usecases/xonotic/stopServer.sh index 641ee30c2..27be12c46 100644 --- a/scripts/usecases/xonotic/stopServer.sh +++ b/scripts/usecases/xonotic/stopServer.sh @@ -1,14 +1,17 @@ #!/bin/bash -echo "[Status Xonotic FPS Game]" +echo "[Stop Xonotic FPS Game]" echo "" -echo "[Xonotic Server.log so far]" +echo "[Current server.log]" cat ~/Xonotic/server.log echo "" -PS=$(ps -ef | head -1; ps -ef | grep [x]onotic) -echo "[Process status of Xonotic]" -echo "$PS" - +PID=$(ps -ef | grep [x]onotic | awk '{print $2}') +kill $PID echo "" +echo "[Stop Xonotic] PID=$PID" + +ps -ef | grep [x]onotic + +echo "" \ No newline at end of file