Add ResoniteLXCDeployTool.sh
This commit is contained in:
142
ResoniteLXCDeployTool.sh
Normal file
142
ResoniteLXCDeployTool.sh
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Clear the terminal
|
||||||
|
clear
|
||||||
|
|
||||||
|
# Display the title banner
|
||||||
|
echo "\033[35m"
|
||||||
|
echo ' ____ _ _ ____ _ _ _______ _ '
|
||||||
|
echo '| __ \ (_) | | __ \ | | | | |__ __| | |'
|
||||||
|
echo '| |__) |___ ___ ___ _ __ _| |_ ___ | | | | ___ _ __ | | ___ _ _ _ __ ___ ___ _ __ | |_ | | ___ ___ | |'
|
||||||
|
echo '| _ // _ \/ __|/ _ \| `_ \| | __/ _ \ | | | |/ _ \ `_ \| |/ _ \| | | | `_ ` _ \ / _ \ `_ \| __| | |/ _ \ / _ \| |'
|
||||||
|
echo '| | \ \ __/\__ \ (_) | | | | | || __/ | |__| | __/ |_) | | (_) | |_| | | | | | | __/ | | | |_ | | (_) | (_) | |'
|
||||||
|
echo '|_| \_\___||___/\___/|_| |_|_|\__\___| |_____/ \___| .__/|_|\___/ \__, |_| |_| |_|\___|_| |_|\__| |_|\___/ \___/|_|'
|
||||||
|
echo ' | | __/ | '
|
||||||
|
echo ' |_| |___/ '
|
||||||
|
echo "\033[0m"
|
||||||
|
|
||||||
|
# Read user input for steamcmd parameters
|
||||||
|
echo "\033[1;33mPlease enter your Steam Credentials to download the Resonite Headless Client.\033[0m"
|
||||||
|
echo "\033[1;33mHighly recommended to use a dummy account for this.\033[0m"
|
||||||
|
echo "\033[1;33mCredentials will be stored in ""/root/launch.sh"" to update the headless client.\033[0m"
|
||||||
|
echo "\033[1;33m----------------------------------------\033[0m"
|
||||||
|
read -p "Steam Username: " NEW_USERNAME
|
||||||
|
read -p "Steam Password: " NEW_PASSWORD
|
||||||
|
read -p "Resonite Beta Code: " NEW_RESONITE_BETA_CODE
|
||||||
|
echo "\033[1;33m----------------------------------------\033[0m"
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Read user input for Resonite Headless configuration:
|
||||||
|
echo "\033[1;33mPlease enter your Resonite Headless Credentials to download the Resonite Headless Client.\033[0m"
|
||||||
|
echo "\033[1;33mAlso highly recommended to use a Dummy Account.\033[0m"
|
||||||
|
echo "\033[1;33mCredentials will be stored in /root/Resonite/Headless/Config/Config.json.\033[0m"
|
||||||
|
echo "\033[1;33m----------------------------------------\033[0m"
|
||||||
|
read -p "Resonite Headless Username: " LOGIN_CREDENTIAL
|
||||||
|
read -p "Resonite Headless Password: " LOGIN_PASSWORD
|
||||||
|
read -p "World Name: " SESSION_NAME
|
||||||
|
read -p "World Description: " DESCRIPTION
|
||||||
|
read -p "Max Users (default: 16): " MAX_USERS
|
||||||
|
read -p "Access Level (Private, LAN, Contacts, ContactsPlus, RegisteredUsers, Anyone | default: Contacts): " ACCESS_LEVEL
|
||||||
|
read -p "Hide from Public Listing (true or false | default: true): " HIDE_FROM_PUBLIC_LISTING
|
||||||
|
read -p "World Tags (comma-separated, e.g., cheese,world,game): " TAGS
|
||||||
|
read -p "World URL (\"resrec://\" URL | default: Will spawn a fresh gridWorld): " LOAD_WORLD_URL
|
||||||
|
read -p "Auto Kick if Idle (in minutes | default: disabled): " AWAY_KICK_MINUTES
|
||||||
|
read -p "Save As (LocalMachine, CloudUser | default: null): " SAVE_AS_OWNER
|
||||||
|
read -p "World Restart if Idle (in minutes | default: disabled): " IDLE_RESTART_INTERVAL
|
||||||
|
read -p "Save World on Exit (true or false | default: false): " SAVE_ON_EXIT
|
||||||
|
read -p "Automatic World Save (in minutes | default: disabled): " AUTOSAVE_INTERVAL
|
||||||
|
read -p "Auto World Sleep (true or false | default: true): " AUTO_SLEEP
|
||||||
|
echo "\033[1;33m----------------------------------------\033[0m"
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Set default values if no input is provided
|
||||||
|
MAX_USERS=${MAX_USERS:-"16"}
|
||||||
|
ACCESS_LEVEL=${ACCESS_LEVEL:-"Contacts"}
|
||||||
|
HIDE_FROM_PUBLIC_LISTING=${HIDE_FROM_PUBLIC_LISTING:-"True"}
|
||||||
|
AWAY_KICK_MINUTES=${AWAY_KICK_MINUTES:-"-1.0"}
|
||||||
|
SAVE_AS_OWNER=${SAVE_AS_OWNER:-"null"}
|
||||||
|
IDLE_RESTART_INTERVAL=${IDLE_RESTART_INTERVAL:-"-1.0"}
|
||||||
|
SAVE_ON_EXIT=${SAVE_ON_EXIT:-"false"}
|
||||||
|
AUTOSAVE_INTERVAL=${AUTOSAVE_INTERVAL:-"-1.0"}
|
||||||
|
AUTO_SLEEP=${AUTO_SLEEP:-"true"}
|
||||||
|
|
||||||
|
# Convert tags to JSON array format
|
||||||
|
if [ -z "$TAGS" ]; then
|
||||||
|
TAGS_ARRAY="[]"
|
||||||
|
else
|
||||||
|
TAGS_ARRAY=$(echo "$TAGS" | sed 's/,/","/g' | sed 's/.*/["&"]/')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine loadWorldPresetName based on loadWorldURL input
|
||||||
|
if [ -z "$LOAD_WORLD_URL" ]; then
|
||||||
|
LOAD_WORLD_URL='null'
|
||||||
|
LOAD_WORLD_PRESET_NAME='"Grid"'
|
||||||
|
else
|
||||||
|
LOAD_WORLD_URL=$(echo "$LOAD_WORLD_URL" | jq -R .)
|
||||||
|
LOAD_WORLD_PRESET_NAME='null'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parse SAVE_AS_OWNER value for JSON input
|
||||||
|
SAVE_AS_OWNER=$(echo "$SAVE_AS_OWNER" | jq -R .)
|
||||||
|
|
||||||
|
# Modify launch script to use user provided credentials
|
||||||
|
sed -i "s/\(STEAM_USERNAME=\"\).*\(\"\)/\1${NEW_USERNAME}\2/" /root/launch.sh
|
||||||
|
sed -i "s/\(STEAM_PASSWORD=\"\).*\(\"\)/\1${NEW_PASSWORD}\2/" /root/launch.sh
|
||||||
|
sed -i "s/\(RESONITE_BETA_CODE=\"\).*\(\"\)/\1${NEW_RESONITE_BETA_CODE}\2/" /root/launch.sh
|
||||||
|
|
||||||
|
# Update the Resonite Headless config file using jq
|
||||||
|
jq --arg loginCredential "$LOGIN_CREDENTIAL" \
|
||||||
|
--arg loginPassword "$LOGIN_PASSWORD" \
|
||||||
|
--arg sessionName "$SESSION_NAME" \
|
||||||
|
--arg description "$DESCRIPTION" \
|
||||||
|
--arg maxUsers "$MAX_USERS" \
|
||||||
|
--arg accessLevel "$ACCESS_LEVEL" \
|
||||||
|
--arg hideFromPublicListing "$HIDE_FROM_PUBLIC_LISTING" \
|
||||||
|
--argjson tags "$TAGS_ARRAY" \
|
||||||
|
--argjson loadWorldURL "$LOAD_WORLD_URL" \
|
||||||
|
--argjson loadWorldPresetName "$LOAD_WORLD_PRESET_NAME" \
|
||||||
|
--arg awayKickMinutes "$AWAY_KICK_MINUTES" \
|
||||||
|
--argjson saveAsOwner "$SAVE_AS_OWNER" \
|
||||||
|
--arg idleRestartInterval "$IDLE_RESTART_INTERVAL" \
|
||||||
|
--arg saveOnExit "$SAVE_ON_EXIT" \
|
||||||
|
--arg autosaveInterval "$AUTOSAVE_INTERVAL" \
|
||||||
|
--arg autoSleep "$AUTO_SLEEP" \
|
||||||
|
'
|
||||||
|
.loginCredential = $loginCredential |
|
||||||
|
.loginPassword = $loginPassword |
|
||||||
|
.startWorlds[0].sessionName = $sessionName |
|
||||||
|
.startWorlds[0].description = $description |
|
||||||
|
.startWorlds[0].maxUsers = ($maxUsers | tonumber) |
|
||||||
|
.startWorlds[0].accessLevel = $accessLevel |
|
||||||
|
.startWorlds[0].hideFromPublicListing = ($hideFromPublicListing | test("true")) |
|
||||||
|
.startWorlds[0].tags = $tags |
|
||||||
|
.startWorlds[0].loadWorldURL = $loadWorldURL |
|
||||||
|
.startWorlds[0].loadWorldPresetName = $loadWorldPresetName |
|
||||||
|
.startWorlds[0].awayKickMinutes = ($awayKickMinutes | tonumber) |
|
||||||
|
.startWorlds[0].saveAsOwner = $saveAsOwner |
|
||||||
|
.startWorlds[0].idleRestartInterval = ($idleRestartInterval | tonumber) |
|
||||||
|
.startWorlds[0].saveOnExit = ($saveOnExit | test("true")) |
|
||||||
|
.startWorlds[0].autosaveInterval = ($autosaveInterval | tonumber) |
|
||||||
|
.startWorlds[0].autoSleep = ($autoSleep | test("true"))
|
||||||
|
' /root/ResoniteConfigTemplate.json > /root/ResoniteConfig.json
|
||||||
|
|
||||||
|
|
||||||
|
# Install Resonite Headless to /root/Resonite
|
||||||
|
/usr/games/steamcmd +login ${NEW_USERNAME} ${NEW_PASSWORD} +@sSteamCmdForcePlatformType windows +force_install_dir /root/Resonite +app_update 2519830 -beta headless -betapassword ${NEW_RESONITE_BETA_CODE} validate +quit
|
||||||
|
|
||||||
|
# Move generated config file to the Resonite config folder
|
||||||
|
mv /root/ResoniteConfig.json /root/Resonite/Headless/Config/Config.json
|
||||||
|
|
||||||
|
# Adjust .bashrc to auto launch resonite starting from next boot
|
||||||
|
sed -i 's|tmux new-session -d -s "ResoniteSetup"|tmux new-session -d -s "ResoniteHeadless"|' /root/.bashrc
|
||||||
|
sed -i 's|tmux send-keys -t "ResoniteSetup" "./firstlogin.sh" Enter|tmux send-keys -t "ResoniteHeadless" "./launch.sh" Enter|' /root/.bashrc
|
||||||
|
sed -i 's|tmux attach-session -t "ResoniteSetup"|tmux attach-session -t "ResoniteHeadless"|' /root/.bashrc
|
||||||
|
|
||||||
|
# Rename the current tmux session
|
||||||
|
rename-session "ResoniteHeadless"
|
||||||
|
|
||||||
|
# Change Directory to the Resonite Headless software
|
||||||
|
cd /root/Resonite/Headless
|
||||||
|
|
||||||
|
# Run the Resonite Headless Server
|
||||||
|
dotnet Resonite.dll
|
||||||
Reference in New Issue
Block a user