style: format shell scripts

This commit is contained in:
darksaid98 committed 2025-09-16 16:53:11 +02:00
1 parent 65f79fe387
commit c410367d3b
15 files changed
+32 -48

No files matched your search

+4 -1
View File
@@ -30,7 +30,10 @@ echo -e "${YELLOW}:/home/container${NC} ${MODIFIED_STARTUP}"
echo -e "${BLUE}-------------------------------------------------${NC}" echo -e "${BLUE}-------------------------------------------------${NC}"
echo -e "${YELLOW}starting MongoDB...${NC}" echo -e "${YELLOW}starting MongoDB...${NC}"
echo -e "${BLUE}-------------------------------------------------${NC}" echo -e "${BLUE}-------------------------------------------------${NC}"
mongod --fork --dbpath /home/container/mongodb/ --port 27017 --logpath /home/container/mongod.log --logRotate reopen --logappend && until nc -z -v -w5 127.0.0.1 27017; do echo 'Waiting for mongodb connection...'; sleep 5; done mongod --fork --dbpath /home/container/mongodb/ --port 27017 --logpath /home/container/mongod.log --logRotate reopen --logappend && until nc -z -v -w5 127.0.0.1 27017; do
echo 'Waiting for mongodb connection...'
sleep 5
done
# Run the Server # Run the Server
echo -e "${BLUE}-------------------------------------------------${NC}" echo -e "${BLUE}-------------------------------------------------${NC}"
+1 -1
View File
@@ -6,7 +6,7 @@ INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
export INTERNAL_IP export INTERNAL_IP
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` MODIFIED_STARTUP=$(eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g'))
echo ":/home/container$ ${MODIFIED_STARTUP}" echo ":/home/container$ ${MODIFIED_STARTUP}"
# Run the Server # Run the Server
+1 -2
View File
@@ -5,9 +5,8 @@ cd /home/container
INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
export INTERNAL_IP export INTERNAL_IP
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` MODIFIED_STARTUP=$(eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g'))
echo ":/home/container$ ${MODIFIED_STARTUP}" echo ":/home/container$ ${MODIFIED_STARTUP}"
# Run the Server # Run the Server
+1 -2
View File
@@ -2,8 +2,7 @@
cd /home/container cd /home/container
# Make internal Docker IP address available to processes. # Make internal Docker IP address available to processes.
export INTERNAL_IP=`ip route get 1 | awk '{print $(NF-2);exit}'` export INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g') MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
+1 -3
View File
@@ -15,10 +15,8 @@ cd /home/container || exit 1
printf "\033[1m\033[33mcontainer@pelican~ \033[0mjava -version\n" printf "\033[1m\033[33mcontainer@pelican~ \033[0mjava -version\n"
java -version java -version
# Print Python version # Print Python version
if command -v python &> /dev/null if command -v python &>/dev/null; then
then
printf "\033[1m\033[33mcontainer@pelican~ \033[0mpython --version\n" printf "\033[1m\033[33mcontainer@pelican~ \033[0mpython --version\n"
python --version python --version
else else
+11 -18
View File
@@ -125,7 +125,7 @@ function RunSteamCMD { #[Input: int server=0 mod=1 optional_mod=2; int id]
cp $file ./keys/optional_$2_${filename} cp $file ./keys/optional_$2_${filename}
done; done
echo -e "\tMod with ID $2 is an optional mod. Deleting original mod download folder..." echo -e "\tMod with ID $2 is an optional mod. Deleting original mod download folder..."
rm -r ./@$2 rm -r ./@$2
@@ -154,11 +154,9 @@ function RunSteamCMD { #[Input: int server=0 mod=1 optional_mod=2; int id]
# Takes a directory (string) as input, and recursively makes all files & folders lowercase. # Takes a directory (string) as input, and recursively makes all files & folders lowercase.
function ModsLowercase { function ModsLowercase {
echo -e "\n\tMaking mod ${CYAN}$1${NC} files/folders lowercase..." echo -e "\n\tMaking mod ${CYAN}$1${NC} files/folders lowercase..."
for SRC in `find ./$1 -depth` for SRC in $(find ./$1 -depth); do
do DST=$(dirname "${SRC}")/$(basename "${SRC}" | tr '[A-Z]' '[a-z]')
DST=`dirname "${SRC}"`/`basename "${SRC}" | tr '[A-Z]' '[a-z]'` if [ "${SRC}" != "${DST}" ]; then
if [ "${SRC}" != "${DST}" ]
then
[ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}" [ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}"
fi fi
done done
@@ -255,8 +253,7 @@ if [[ ${UPDATE_SERVER} == 1 ]]; then
## Update mods ## Update mods
if [[ -n $allMods ]] && [[ ${DISABLE_MOD_UPDATES} != 1 ]]; then if [[ -n $allMods ]] && [[ ${DISABLE_MOD_UPDATES} != 1 ]]; then
echo -e "\n${GREEN}[UPDATE]:${NC} Checking all ${CYAN}Steam Workshop mods${NC} for updates..." echo -e "\n${GREEN}[UPDATE]:${NC} Checking all ${CYAN}Steam Workshop mods${NC} for updates..."
for modID in $(echo $allMods | sed -e 's/@//g') for modID in $(echo $allMods | sed -e 's/@//g'); do
do
if [[ $modID =~ ^[0-9]+$ ]]; then # Only check mods that are in ID-form if [[ $modID =~ ^[0-9]+$ ]]; then # Only check mods that are in ID-form
# If a mod is defined in OPTIONALMODS, and is not defined in CLIENT_MODS or SERVERMODS, then treat as an optional mod # If a mod is defined in OPTIONALMODS, and is not defined in CLIENT_MODS or SERVERMODS, then treat as an optional mod
# Optional mods are given a different directory which is checked to see if a new update is available. This is to ensure # Optional mods are given a different directory which is checked to see if a new update is available. This is to ensure
@@ -322,7 +319,7 @@ if [[ ${UPDATE_SERVER} == 1 ]]; then
rmdir ./@${modID}_optional 2>/dev/null rmdir ./@${modID}_optional 2>/dev/null
fi fi
fi fi
done; done
echo -e "${GREEN}[UPDATE]:${NC} Steam Workshop mod update check ${GREEN}complete${NC}!" echo -e "${GREEN}[UPDATE]:${NC} Steam Workshop mod update check ${GREEN}complete${NC}!"
fi fi
@@ -340,8 +337,7 @@ fi
# Make mods lowercase, if specified # Make mods lowercase, if specified
if [[ ${MODS_LOWERCASE} == "1" ]]; then if [[ ${MODS_LOWERCASE} == "1" ]]; then
for modDir in $allMods for modDir in $allMods; do
do
ModsLowercase $modDir ModsLowercase $modDir
done done
fi fi
@@ -355,8 +351,7 @@ mkdir -p /home/container/serverprofile/rpt
# Clear HC cache, if specified # Clear HC cache, if specified
if [[ ${CLEAR_CACHE} == "1" ]]; then if [[ ${CLEAR_CACHE} == "1" ]]; then
echo -e "\n${GREEN}[STARTUP]: ${CYAN}Clearing Headless Client profiles cache...${NC}" echo -e "\n${GREEN}[STARTUP]: ${CYAN}Clearing Headless Client profiles cache...${NC}"
for profileDir in ./serverprofile/home/* for profileDir in ./serverprofile/home/*; do
do
[ "$profileDir" = "./serverprofile/home/Player" ] && continue [ "$profileDir" = "./serverprofile/home/Player" ] && continue
rm -rf $profileDir rm -rf $profileDir
done done
@@ -381,15 +376,13 @@ else
fi fi
# Replace Startup Variables # Replace Startup Variables
modifiedStartup=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` modifiedStartup=$(eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g'))
# Start Headless Clients if applicable # Start Headless Clients if applicable
if [[ ${HC_NUM} > 0 ]]; then if [[ ${HC_NUM} > 0 ]]; then
echo -e "\n${GREEN}[STARTUP]:${NC} Starting ${CYAN}${HC_NUM}${NC} Headless Client(s)." echo -e "\n${GREEN}[STARTUP]:${NC} Starting ${CYAN}${HC_NUM}${NC} Headless Client(s)."
for i in $(seq ${HC_NUM}) for i in $(seq ${HC_NUM}); do
do if [[ ${HC_HIDE} == "1" ]]; then
if [[ ${HC_HIDE} == "1" ]];
then
./${SERVER_BINARY} -client -connect=127.0.0.1 -port=${SERVER_PORT} -password="${SERVER_PASSWORD}" -profiles=./serverprofile -bepath=./battleye -mod="${CLIENT_MODS}" ${STARTUP_PARAMS} >/dev/null 2>&1 & ./${SERVER_BINARY} -client -connect=127.0.0.1 -port=${SERVER_PORT} -password="${SERVER_PASSWORD}" -profiles=./serverprofile -bepath=./battleye -mod="${CLIENT_MODS}" ${STARTUP_PARAMS} >/dev/null 2>&1 &
else else
./${SERVER_BINARY} -client -connect=127.0.0.1 -port=${SERVER_PORT} -password="${SERVER_PASSWORD}" -profiles=./serverprofile -bepath=./battleye -mod="${CLIENT_MODS}" ${STARTUP_PARAMS} & ./${SERVER_BINARY} -client -connect=127.0.0.1 -port=${SERVER_PORT} -password="${SERVER_PASSWORD}" -profiles=./serverprofile -bepath=./battleye -mod="${CLIENT_MODS}" ${STARTUP_PARAMS} &
+6 -10
View File
@@ -133,11 +133,9 @@ function RunSteamCMD { #[Input: int server=0 mod=1; int id]
# Takes a directory (string) as input, and recursively makes all files & folders lowercase. # Takes a directory (string) as input, and recursively makes all files & folders lowercase.
function ModsLowercase { function ModsLowercase {
echo -e "\n\tMaking mod ${CYAN}$1${NC} files/folders lowercase..." echo -e "\n\tMaking mod ${CYAN}$1${NC} files/folders lowercase..."
for SRC in `find ./$1 -depth` for SRC in $(find ./$1 -depth); do
do DST=$(dirname "${SRC}")/$(basename "${SRC}" | tr '[A-Z]' '[a-z]')
DST=`dirname "${SRC}"`/`basename "${SRC}" | tr '[A-Z]' '[a-z]'` if [ "${SRC}" != "${DST}" ]; then
if [ "${SRC}" != "${DST}" ]
then
[ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}" [ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}"
fi fi
done done
@@ -219,8 +217,7 @@ if [[ ${UPDATE_SERVER} == 1 ]]; then
## Update mods ## Update mods
if [[ -n $allMods ]] && [[ ${DISABLE_MOD_UPDATES} != 1 ]]; then if [[ -n $allMods ]] && [[ ${DISABLE_MOD_UPDATES} != 1 ]]; then
echo -e "\n${GREEN}[UPDATE]:${NC} Checking all ${CYAN}Steam Workshop mods${NC} for updates..." echo -e "\n${GREEN}[UPDATE]:${NC} Checking all ${CYAN}Steam Workshop mods${NC} for updates..."
for modID in $(echo $allMods | sed -e 's/@//g') for modID in $(echo $allMods | sed -e 's/@//g'); do
do
if [[ $modID =~ ^[0-9]+$ ]]; then # Only check mods that are in ID-form if [[ $modID =~ ^[0-9]+$ ]]; then # Only check mods that are in ID-form
# Get mod's latest update in epoch time from its Steam Workshop changelog page # Get mod's latest update in epoch time from its Steam Workshop changelog page
latestUpdate=$(curl -sL https://steamcommunity.com/sharedfiles/filedetails/changelog/$modID | grep '<p id=' | head -1 | cut -d'"' -f2) latestUpdate=$(curl -sL https://steamcommunity.com/sharedfiles/filedetails/changelog/$modID | grep '<p id=' | head -1 | cut -d'"' -f2)
@@ -265,8 +262,7 @@ fi
# Make mods lowercase, if specified # Make mods lowercase, if specified
if [[ ${MODS_LOWERCASE} == "1" ]]; then if [[ ${MODS_LOWERCASE} == "1" ]]; then
for modDir in $allMods for modDir in $allMods; do
do
ModsLowercase $modDir ModsLowercase $modDir
done done
fi fi
@@ -278,7 +274,7 @@ envsubst < /passwd.template > ${NSS_WRAPPER_PASSWD}
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libnss_wrapper.so export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libnss_wrapper.so
# Replace Startup Variables # Replace Startup Variables
modifiedStartup=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` modifiedStartup=$(eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g'))
# Start the Server # Start the Server
echo -e "\n${GREEN}[STARTUP]:${NC} Starting server with the following startup command:" echo -e "\n${GREEN}[STARTUP]:${NC} Starting server with the following startup command:"
+1 -1
View File
@@ -5,7 +5,7 @@ cd /home/container
if [ "${GIT_ENABLED}" == "true" ] || [ "${GIT_ENABLED}" == "1" ]; then if [ "${GIT_ENABLED}" == "true" ] || [ "${GIT_ENABLED}" == "1" ]; then
# Pre git stuff # Pre git stuff
echo "Wait, preparing to pull or clone from git."; echo "Wait, preparing to pull or clone from git."
mkdir -p /home/container/resources mkdir -p /home/container/resources
cd /home/container/resources cd /home/container/resources
+2 -2
View File
@@ -2,7 +2,7 @@
cd /home/container cd /home/container
# Make internal Docker IP address available to processes. # Make internal Docker IP address available to processes.
export INTERNAL_IP=`ip route get 1 | awk '{print $(NF-2);exit}'` export INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
## if auto_update is not set or to 1 update ## if auto_update is not set or to 1 update
if [ -z ${AUTO_UPDATE} ] || [ "${AUTO_UPDATE}" == "1" ]; then if [ -z ${AUTO_UPDATE} ] || [ "${AUTO_UPDATE}" == "1" ]; then
@@ -13,7 +13,7 @@ else
fi fi
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` MODIFIED_STARTUP=$(eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g'))
echo ":/home/container$ ${MODIFIED_STARTUP}" echo ":/home/container$ ${MODIFIED_STARTUP}"
if [[ "${FRAMEWORK}" == "carbon" ]]; then if [[ "${FRAMEWORK}" == "carbon" ]]; then
+1 -1
View File
@@ -2,7 +2,7 @@
cd /home/container cd /home/container
# Make internal Docker IP address available to processes. # Make internal Docker IP address available to processes.
export INTERNAL_IP=`ip route get 1 | awk '{print $(NF-2);exit}'` export INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g') MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
-1
View File
@@ -36,7 +36,6 @@ export INTERNAL_IP
# Switch to the container's working directory # Switch to the container's working directory
cd /home/container || exit 1 cd /home/container || exit 1
## just in case someone removed the defaults. ## just in case someone removed the defaults.
if [ "${STEAM_USER}" == "" ]; then if [ "${STEAM_USER}" == "" ]; then
echo -e "steam user is not set.\n" echo -e "steam user is not set.\n"
-2
View File
@@ -5,7 +5,6 @@ cd /home/container
INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
export INTERNAL_IP export INTERNAL_IP
## just in case someone removed the defaults. ## just in case someone removed the defaults.
if [ "${STEAM_USER}" == "" ]; then if [ "${STEAM_USER}" == "" ]; then
echo -e "steam user is not set.\n" echo -e "steam user is not set.\n"
@@ -30,7 +29,6 @@ else
echo -e "Not updating game server as auto update was set to 0. Starting Server" echo -e "Not updating game server as auto update was set to 0. Starting Server"
fi fi
# Setup NSS Wrapper for use ($NSS_WRAPPER_PASSWD and $NSS_WRAPPER_GROUP have been set by the Dockerfile) # Setup NSS Wrapper for use ($NSS_WRAPPER_PASSWD and $NSS_WRAPPER_GROUP have been set by the Dockerfile)
export USER_ID=$(id -u) export USER_ID=$(id -u)
export GROUP_ID=$(id -g) export GROUP_ID=$(id -g)
-1
View File
@@ -43,7 +43,6 @@ if [ ! -z "${SRCDS_APPID}" ]; then
fi fi
fi fi
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=$(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g') MODIFIED_STARTUP=$(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
echo -e ":/home/container$ ${MODIFIED_STARTUP}" echo -e ":/home/container$ ${MODIFIED_STARTUP}"
+1 -1
View File
@@ -9,7 +9,7 @@ INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
export INTERNAL_IP export INTERNAL_IP
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` MODIFIED_STARTUP=$(eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g'))
echo ":/home/container$ ${MODIFIED_STARTUP}" echo ":/home/container$ ${MODIFIED_STARTUP}"
# Run the Server # Run the Server
+2 -2
View File
@@ -50,7 +50,7 @@ mkdir -p $WINEPREFIX
# Check if wine-gecko required and install it if so # Check if wine-gecko required and install it if so
if [[ $WINETRICKS_RUN =~ gecko ]]; then if [[ $WINETRICKS_RUN =~ gecko ]]; then
echo "Installing Gecko" echo "Installing Gecko"
WINETRICKS_RUN=${WINETRICKS_RUN/gecko} WINETRICKS_RUN=${WINETRICKS_RUN/gecko/}
if [ ! -f "$WINEPREFIX/gecko_x86.msi" ]; then if [ ! -f "$WINEPREFIX/gecko_x86.msi" ]; then
wget -q -O $WINEPREFIX/gecko_x86.msi http://dl.winehq.org/wine/wine-gecko/2.47.4/wine_gecko-2.47.4-x86.msi wget -q -O $WINEPREFIX/gecko_x86.msi http://dl.winehq.org/wine/wine-gecko/2.47.4/wine_gecko-2.47.4-x86.msi
@@ -67,7 +67,7 @@ fi
# Check if wine-mono required and install it if so # Check if wine-mono required and install it if so
if [[ $WINETRICKS_RUN =~ mono ]]; then if [[ $WINETRICKS_RUN =~ mono ]]; then
echo "Installing mono" echo "Installing mono"
WINETRICKS_RUN=${WINETRICKS_RUN/mono} WINETRICKS_RUN=${WINETRICKS_RUN/mono/}
if [ ! -f "$WINEPREFIX/mono.msi" ]; then if [ ! -f "$WINEPREFIX/mono.msi" ]; then
wget -q -O $WINEPREFIX/mono.msi https://dl.winehq.org/wine/wine-mono/9.1.0/wine-mono-9.1.0-x86.msi wget -q -O $WINEPREFIX/mono.msi https://dl.winehq.org/wine/wine-mono/9.1.0/wine-mono-9.1.0-x86.msi