Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating STARTCOMMAND to array with += syntax and allowing spaces in … #124

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

clarkent86
Copy link
Contributor

Updating to using array for STARTCOMMAND due to issues that su steam -c "${STARTCOMMAND}" can have with escaped quotes and spaces, also this will allow for spaces in server names and passwords

Context

Allow users to use spaces in certain environment variables

Choices

  • Better handling of spaces in program arguments that should allow them, such as server name and passwords

Test instructions

  1. Run the server with this change and have spaces in the passwords or in the server name

Checklist before requesting a review

  • I have performed a self-review of my code
  • I've added documentation about this change to the README.
    there is no mention spaces aren't supported, so this will just be helpful overall
  • I've not introduced breaking changes.

@fryfrog
Copy link
Contributor

fryfrog commented Jan 26, 2024

Brilliant!

@fryfrog fryfrog mentioned this pull request Jan 26, 2024
3 tasks
scripts/start.sh Show resolved Hide resolved
Copy link
Owner

@thijsvanloef thijsvanloef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clarkent86 Thank you for creating this PR, however I did find an issue. Changing this to an array while not changing the way the startcommand gets expanded, does not work.
As shellcheck gives the following error on su steam -c "${STARTCOMMAND}":

Expanding an array without an index only gives the first element.shellcheckSC2128

Which I could confirm when running it myself:

palworld-server  | *****CHECKING FOR EXISTING CONFIG*****
palworld-server  | RCON_ENABLED=true
palworld-server  | RCON_PORT=25575
palworld-server  | ./PalServer.sh
palworld-server  | Shutdown handler: initalize.
palworld-server  | Increasing per-process limit of core file size to infinity.
palworld-server  | [S_API] SteamAPI_Init(): Loaded local 'steamclient.so' OK.
palworld-server  | CAppInfoCacheReadFromDiskThread took 1 milliseconds to initialize
palworld-server  | Setting breakpad minidump AppID = 2394010
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.

Only ./PalServer.sh gets called with no parameters

@clarkent86
Copy link
Contributor Author

clarkent86 commented Jan 26, 2024

@clarkent86 Thank you for creating this PR, however I did find an issue. Changing this to an array while not changing the way the startcommand gets expanded, does not work. As shellcheck gives the following error on su steam -c "${STARTCOMMAND}":

Expanding an array without an index only gives the first element.shellcheckSC2128

Which I could confirm when running it myself:

palworld-server  | *****CHECKING FOR EXISTING CONFIG*****
palworld-server  | RCON_ENABLED=true
palworld-server  | RCON_PORT=25575
palworld-server  | ./PalServer.sh
palworld-server  | Shutdown handler: initalize.
palworld-server  | Increasing per-process limit of core file size to infinity.
palworld-server  | [S_API] SteamAPI_Init(): Loaded local 'steamclient.so' OK.
palworld-server  | CAppInfoCacheReadFromDiskThread took 1 milliseconds to initialize
palworld-server  | Setting breakpad minidump AppID = 2394010
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.

Only ./PalServer.sh gets called with no parameters

@thijsvanloef Apologies! I was testing with a local script and forgot to expand the array correctly when applying it to this code base. I should've noticed with the other comment!

Should be fixed now, can you try again?

scripts/start.sh Outdated Show resolved Hide resolved
@clarkent86
Copy link
Contributor Author

@Dashboy1998 thanks! It looks like I missed the echo command as well, updated. Also, expanding with the @ instead of the * preserves the spaces as we want for the command.

@thijsvanloef
Copy link
Owner

@clarkent86 Awesome work, ready to merge :)

@thijsvanloef thijsvanloef merged commit 243420f into thijsvanloef:main Jan 26, 2024
4 checks passed
@thijsvanloef
Copy link
Owner

thijsvanloef commented Jan 26, 2024

Needed to revert the changes, I've done some more testing and it seems like it won't start:

palworld-server  | Connecting anonymously to Steam Public...OK
palworld-server  | Waiting for client config...OK
palworld-server  | Waiting for user info...OK
palworld-server  |  Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
palworld-server  |  Update state (0x5) verifying install, progress: 3.45 (77589729 / 2248053389)
palworld-server  |  Update state (0x5) verifying install, progress: 16.11 (362079510 / 2248053389)
palworld-server  |  Update state (0x5) verifying install, progress: 34.05 (765465170 / 2248053389)
palworld-server  |  Update state (0x5) verifying install, progress: 51.43 (1156196222 / 2248053389)
palworld-server  |  Update state (0x5) verifying install, progress: 69.41 (1560371980 / 2248053389)
palworld-server  |  Update state (0x5) verifying install, progress: 88.65 (1993011775 / 2248053389)
palworld-server  | Success! App '2394010' fully installed.
palworld-server  | *****CHECKING FOR EXISTING CONFIG*****
palworld-server  | RCON_ENABLED=true
palworld-server  | RCON_PORT=25575
palworld-server  | *****STARTING SERVER*****
palworld-server  | ./PalServer.sh -port=8211 -players=16 -servername="WorldofPals" -serverpassword="worldofpals" -adminpassword="adminPasswordHere" -queryport=27015 -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS
palworld-server  | su: invalid option -- 'o'
palworld-server  | Try 'su --help' for more information.

@thijsvanloef
Copy link
Owner

@clarkent86 ☝️

@clarkent86
Copy link
Contributor Author

Got it. Seems like there's something unexpected happening, I'll need to figure out how to source a custom image on my NAS. Sorry about that.

@thijsvanloef
Copy link
Owner

@clarkent86 No worries, shit happens, nothing was deployed 🙂

@clarkent86
Copy link
Contributor Author

Got it working and fully tested now instead of just printing the startcmd in a script, PR incoming!

MusclePr pushed a commit to MusclePr/palworld-server-docker that referenced this pull request Jun 19, 2024
updating STARTCOMMAND to array with += syntax and allowing spaces in …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants