Acekorneya/Ark-Survival-Ascended-Server

POK-manager.sh emtpies itself

Closed this issue · 3 comments

I run my ARK servers on a PC in my local network but my public IP is changing every day and my internet connection is dropped for a few minutes when it gets renewed. To restart the ARK servers after this I wrote a script which checks every 5 minutes the status of POK-manager.sh -status. When it find the line "Server not found under the current IP" it will stop the ARK instance and then start it again. The issue is, that the file POK-manager.sh is empty (0Bytes) after this.

My guess is that POK-manager.sh wants to update itself somewhere in the process. In the functions check_for_POK_updates() and update_manager_and_instances() you just check if wget or curl is available and if so it will run the command wget -q -O "$temp_file" "$script_url". But when you run this command without internet connection or against a wrong URL it will create an empty /tmp/POK-manager.sh file which later in the process will replace the real POK-manager.sh file.

Can you please add a check to replace the file only when for example the MD5 checksum is verified or if thats too much then maybe a check if the file has at least a certain size or grep something from the file to verify it is not empty?

Thanks for the feedback i added a fix for it hopefully it helps out with the issue

Thanks. Checking if the file is at least 1KB should prevent it. I guess it should also be in the function update_manager_and_instances() .

And just for information. With the MD5 Checksum I meant to check the checksum of the downloaded file against a checksum file on the server like for example Linux updates do this. But I think this is not necessary and more work as you have to change the checksum file on the server after each update. The cmp command to check the local file against the downloaded was good as it was. But the MD5 comparison is also good.

Thanks again for the valuable feedback! I’ve updated the update_manager_and_instances() function to include the 1KB file size check, just like we did in the check_for_POK_updates() function.

I’ve also kept the use of the cmp command to compare the current script with the downloaded version, which should keep things simple and effective.

As I’m still learning, your input is helping me a lot to improve the script.