diff --git a/README.md b/README.md index 92b3b46..3b22950 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ NB: You may want to change the `bash -s` parameter to fit your steam user if dif This will copy the `arkmanager` script and its daemon to the proper directories and will create an empty log directory in `/var/log` for ARK Server Tools. +To instead perform a user-install of ARK Server Tools as an unprivileged user, run this command: + +```sh +curl -sL http://git.io/vtf5N | bash -s -- --me +``` + ## Configuration Stored in `/etc/arkmanager/arkmanager.cfg` you can find the variables needed to start the server, like the port numbers, the system environment variables and so on. @@ -54,6 +60,12 @@ ark_DifficultyOffset=1 Your session name may not contain special characters (eg. `!![EU]!! Aw&some ARK`) as it could break the startup command. In this case you may want to comment out the `ark_SessionName` variable and define it inside your **GameUserSettings.ini** file instead. +To specify an option without an argument (e.g. `bRawSockets`), specify an empty argument (e.g. `ark_bRawSockets=""`). + +To specify a dash-option without an argument (e.g. `-log`), add the option="" prefixed with `arkflag_` (e.g. `arkflag_log=""`). + +To specify a dash-option with an argument (e.g. `-StructureDestructionTag=DestroySwampSnowStructures`), add the option=value prefixed with `arkopt_` (e.g. `arkopt_StructureDestructionTag=DestroySwampSnowStructures`). + You can override or add variables for a specific system user creating a file called `.arkmanager.cfg` in the home directory of the system user. ## Install ARK Server @@ -80,24 +92,25 @@ Stops ARK server Restarts ARK server #### arkmanager update -Manually updates ARK server if a new version is available +Manually updates ARK server if a new version is available. +This accepts zero or more of the below options. -#### arkmanager update --force +##### arkmanager update --force Apply update without check the current version -#### arkmanager update --safe +##### arkmanager update --safe Waits for server to perform world save and then updates. -#### arkmanager update --warn +##### arkmanager update --warn Warns the players for a configurable amount of time before updating. Should be suitable for adding to a cron job. -#### arkmanager update --validate +##### arkmanager update --validate Validates all ARK server files -#### arkmanager update --update-mods +##### arkmanager update --update-mods Updates installed and requested mods -#### arkmanager update --backup +##### arkmanager update --backup Takes a backup of the save files before updating. #### arkmanager status diff --git a/tools/arkmanager b/tools/arkmanager index 5594214..5321bea 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -311,12 +311,11 @@ function checkForUpdate(){ function isUpdateNeeded(){ getCurrentVersion getAvailableVersion - if [ "$bnumber" -eq "$instver" ]; then + if [ "$bnumber" = "Unknown" -o "$bnumber" -eq "$instver" ]; then return 1 # no update needed else return 0 # update needed fi - } # @@ -365,6 +364,9 @@ function getCurrentVersion(){ function getAvailableVersion(){ rm -f "$steamcmd_appinfocache" bnumber=`$steamcmdroot/$steamcmdexec +@NoPromptForPassword 1 +login ${steamlogin:-anonymous} +app_info_update 1 +app_info_print "$appid" +quit | while read name val; do if [ "${name}" == "{" ]; then parseSteamACF ".depots.branches.public" "buildid"; break; fi; done` + if [ -z "$bnumber" ]; then + bnumber="Unknown" + fi return $bnumber } @@ -393,6 +395,30 @@ function isTheServerRunning(){ function isTheServerUp(){ $lsof -i :"$ark_Port" > /dev/null result=$? + if [ $result -ne 0 ]; then + perl -MSocket -MFcntl -e ' + my $port = int($ARGV[0]); + socket(my $socket, PF_INET, SOCK_DGRAM, 0); + setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack("i4", 1, 0, 0, 0)); + my $sockaddr = pack_sockaddr_in($port, inet_aton("127.0.0.1")); + send($socket, "\xff\xff\xff\xffTSource Engine Query\x00", 0, $sockaddr); + my $flags = fcntl($socket, F_GETFL, 0) or exit(1); + fcntl($socket, F_SETFL, $flags | O_NONBLOCK) or exit(1); + my $data = ""; + my $rin = ""; + vec($rin, fileno($socket), 1) = 1; + if (select($rin, undef, undef, 0.25) >= 0) { + recv($socket, $data, 1400, 0) or exit(1); + my ($servername, $mapname, $game, $fullname, $rest) = split(/\x00/, substr($data, 6), 5); + my $maxplayers = ord(substr($rest, 3, 1)); + if ($maxplayers == 0) { exit(1); } + exit(0); + } else { + exit(1); + } + ' "${ark_QueryPort}" + result=$? + fi # In this case, the result is: # 1 if the command fail. The port is not listenning # 0 if the command succeed. The port is listenning @@ -1013,6 +1039,10 @@ doExtractMod(){ doInstallMod(){ local modid=$1 + if [ -f "$steamcmdroot/steamapps/workshop/appworkshop_${mod_appid}.acf" ]; then + sed -i "/^\\t\\t\"${modid}\"/,/^\\t\\t}/d" "$steamcmdroot/steamapps/workshop/appworkshop_${mod_appid}.acf" + fi + if doDownloadMod $modid; then doExtractMod $modid echo "Mod $modid installed"