Skip to content

Commit 9b696a6

Browse files
seattaEllie
authored and
Ellie
committed
Rewrote Linux Scripts
1 parent 6a30f3c commit 9b696a6

File tree

5 files changed

+122
-10
lines changed

5 files changed

+122
-10
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Cache/
7272
/run_profiler_support.bat
7373
/compile_windows.bat
7474

75+
# Ignore script logs
76+
/scripts/logs/
77+
7578
#Put any custom git ignore attributes below
7679

7780
hs_err*

scripts/run_linux.sh

-3
This file was deleted.

scripts/run_linux_console.sh

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
11
#!/usr/bin/env bash
22

3+
# Forces the script to relaunch in bash if necessary
4+
if [ -z "$BASH_VERSION" ]; then
5+
exec /bin/bash "$0" "$@"
6+
fi
7+
8+
# Set variables
9+
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
10+
JAVA_VERSION=$(java -version 2>&1 | grep -oP '(?<=version ")[^"]+')
11+
12+
# Check if Java is installed
13+
if ! command -v java &> /dev/null; then
14+
echo "Java is not installed. You need to install Java 1.8."
15+
exit 1
16+
fi
17+
18+
# Check Java version
19+
if [[ "${JAVA_VERSION}" != 1.8* ]]; then
20+
echo "It is recommended to use Java 1.8 for IdleRSC!"
21+
fi
22+
23+
cd "$SCRIPT_DIR/.." || exit
324
java -jar IdleRSC.jar

scripts/run_linux_multiple.sh

+53-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,55 @@
11
#!/usr/bin/env bash
22

3-
gnome-terminal "bash -c './run_linux_no_console.sh; exec bash'"
4-
gnome-terminal "bash -c './run_linux_no_console.sh; exec bash'"
5-
gnome-terminal "bash -c './run_linux_no_console.sh; exec bash'"
6-
gnome-terminal "bash -c './run_linux_no_console.sh; exec bash'"
7-
gnome-terminal "bash -c './run_linux_no_console.sh; exec bash'"
8-
gnome-terminal "bash -c './run_linux_no_console.sh; exec bash'"
3+
# Forces the script to relaunch in bash if necessary
4+
if [ -z "$BASH_VERSION" ]; then
5+
exec /bin/bash "$0" "$@"
6+
fi
7+
8+
# Set variables
9+
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
10+
LOG_DIR="${SCRIPT_DIR}/logs"
11+
JAVA_VERSION=$(java -version 2>&1 | grep -oP '(?<=version ")[^"]+')
12+
declare -A USER_ARRAY
13+
14+
# Check if Java is installed
15+
if ! command -v java &> /dev/null; then
16+
echo "Java is not installed. You need to install Java 1.8."
17+
exit 1
18+
fi
19+
20+
# Check Java version
21+
if [[ "${JAVA_VERSION}" != 1.8* ]]; then
22+
echo "It is recommended to use Java 1.8 for IdleRSC!"
23+
fi
24+
25+
# Add an entry for each account you want to launch a session for
26+
# The 'keys' in USER_ARRAY are used for creating log files per instance, while the 'values' are for passing args to that instance.
27+
# For example, 'USER_ARRAY["USERNAME"]="--auto-start --account testuser"'
28+
# would run an instance with '--auto-start --account testuser' and log output to 'IdleRSC/scripts/logs/instance_USERNAME.log'
29+
30+
USER_ARRAY["USERNAME"]="--auto-start --account USERNAME"
31+
32+
# Delete old log files
33+
if [ -n "${LOG_DIR}" ] && [ -d "${LOG_DIR}" ]; then
34+
if [ -z "$(find "${LOG_DIR}" -maxdepth 0 -type d -empty)" ]; then
35+
rm -r "${LOG_DIR}/instance_"*
36+
fi
37+
fi
38+
39+
# Create new log directory if it doesn't exist
40+
if [ ! -d "${LOG_DIR}" ]; then
41+
mkdir "${LOG_DIR}"
42+
fi
43+
44+
cd "$SCRIPT_DIR/.." || exit
45+
46+
# Loop through the array to open an instance for each index
47+
for user in "${!USER_ARRAY[@]}"; do
48+
LOG_FILE="${LOG_DIR}/instance_${user}.log"
49+
50+
# Log useful information to the top of the instances log file
51+
printf "User: '%s'\nJava Info:\n%s\n" "${user}" "$(java -version 2>&1)" > "${LOG_FILE}"
52+
53+
# Launch an instance and echo the output to logs/instance_username.log.
54+
nohup java -jar ./IdleRSC.jar "${USER_ARRAY[$user]}" >> "${LOG_FILE}" 2>&1 & sleep 0.3
55+
done

scripts/run_linux_no_console.sh

+45-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
11
#!/usr/bin/env bash
2-
screen -dmS IdleRSC java -jar ./IdleRSC.jar
2+
3+
# Set your custom args here
4+
ARGS=""
5+
6+
# Forces the script to relaunch in bash if necessary
7+
if [ -z "$BASH_VERSION" ]; then
8+
exec /bin/bash "$0" "$@"
9+
fi
10+
11+
# Set variables
12+
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
13+
LOG_DIR="${SCRIPT_DIR}/logs"
14+
JAVA_VERSION=$(java -version 2>&1 | grep -oP '(?<=version ")[^"]+')
15+
LOG_FILE="${LOG_DIR}/no_console.log"
16+
17+
# Check if Java is installed
18+
if ! command -v java &> /dev/null; then
19+
echo "Java is not installed. You need to install Java 1.8."
20+
exit 1
21+
fi
22+
23+
# Check Java version
24+
if [[ "${JAVA_VERSION}" != 1.8* ]]; then
25+
echo "It is recommended to use Java 1.8 for IdleRSC!"
26+
fi
27+
28+
# Delete old log files
29+
if [ -n "${LOG_DIR}" ] && [ -d "${LOG_DIR}" ]; then
30+
if [ -z "$(find "${LOG_DIR}" -maxdepth 0 -type d -empty)" ]; then
31+
rm -r "${LOG_DIR}/no_console.log"
32+
fi
33+
fi
34+
35+
# Create new log directory if it doesn't exist
36+
if [ ! -d "${LOG_DIR}" ]; then
37+
mkdir "${LOG_DIR}"
38+
fi
39+
40+
cd "$SCRIPT_DIR/.." || exit
41+
42+
# Log useful information to the top of the instances log file
43+
printf "Java Info:\n%s\n" "$(java -version 2>&1)" > "${LOG_FILE}"
44+
45+
# Launch an instance and echo the output to logs/instance_username.log.
46+
nohup java -jar ./IdleRSC.jar "${ARGS}" >> "${LOG_FILE}" 2>&1 & sleep 0.3

0 commit comments

Comments
 (0)