captpete wrote:Now, has anyone any suggestions to this non-programmer on how to do what I want to do.
Ignoring the debate about compression utilities and what the best way to run a service is, the real issue with your script lies in these lines:
Code: Select all
wall Minetest is going down for maintenance shortly. Please logout now.
sleep 3m
skill -KILL /dev/pts/*
sleep 20s
Obviously what you are trying to do here is warn everyone playing on your server that the server is going down, then you're waiting 3 minutes for everyone to log out before forcing them to log out, then you're forcing everyone who's still logged in to log out, then you're waiting another 20 seconds for their logout to complete before stopping the server.
That's not actually what this does. The commands that you're using target users on your Linux system, not the Minetest server. The people logging in to your Minetest server are not users on the computer itself. They won't see the message from the "wall" command and they won't be logged out by the "skill" command.
What you actually need to do is to use a block of code similar to the following in a Minetest mod, within the Minetest game itself:
Code: Select all
minetest.register_chatcommand("shutdown_for_maintenance", {
params = "",
description = "Warns players and then shuts down the server after a delay",
privs = { server = true },
func = function(name, param)
-- warn players
minetest.chat_send_all("Minetest is going down for maintenance shortly. Please log out now.")
-- shut down server after 3 minutes
minetest.request_shutdown("Minetest is going down for maintenance.", false, 3 * 60)
end
})
This registers a chat command to shutdown the server with the appropriate warnings and delays (the command can only be executed by someone with admin privileges on the server). Note that there's no need to explicitly kick the players that are still logged in, they are automatically logged out when the server shuts down and shown the message passed to minetest.request_shutdown. Also I had originally written this to use minetest.after but minetest.request_shutdown includes a delay parameter. Either method is probably fine.
If you want to do this automatically (without logging in to the server to run the command), you will need to pass the command to the server from your script and then wait the three minutes for the server to shut down before continuing. I don't know how to pass the command to the server from a script but maybe someone else can suggest that part. Your script would then look something like this:
Code: Select all
# warn users, stop server
<execute /shutdown_for_maintenance command on server, however that's done>
sleep 3.5m
killall minetestserver
This waits 3 minutes and 30 seconds for the server to shut down, which covers the 3-minute delay and includes a bit of extra time in case it is slow for some reason. Then it kills the server in case it hasn't shut down yet (unlikely but possible if something goes wrong).
joe7575 wrote:gzip is no good idea. If your 'map.sqlite' is larger than 2 GB, gzip fails (as on my server)
I only use "tar -cf ...""
wziard wrote:For the record, it is the first time I hear of this 2GB limit in gzip. And I have never experienced it myself, though I'm quite sure I have gzipped larger (disk-image) files in the past. Maybe it is a filesystem limitation in joe7575's system?
Never heard of it either. Normally I use tar and then manually pipe into gzip, I've never used tar's built-in gzip option. Perhaps that imposes an extra limit. I've gzipped many files larger than 2 GB. Might also depend on if your system is 32-bit or 64-bit (just throwing this out there to experiment with).