MineOS won’t start the server because it believes the server is already up.
The server is considered to be “up” if the process ID of Java is still alive; this PID is captured when MineOS starts the server (through any of MineOS’ methods, console or webui).
This restart script looks to me simply like a start script.
MineOS doesn’t maintain state like that; strictly whether the PID is alive is the test and it’ll be tested on each command (won’t get cached between calls in the same script, etc.)
I recommend you kill all Minecraft processes and try this from the start, tracing to see if you can create a simple ‘stop’ and ‘start’ script (not yet a restart).
When you know each component works, blend them together.