I have been working on creating a shell script for a while, browsing various forums including this one, and using all sorts of search terms with no luck. I hope I am not creating a duplicate question.
We have a game server and we have to initialize screen manually after a reboot or a crash, but would like to pack our few commands into one script to lower the downtime. What I would like to do is to make a script that creates a screen session, switches to it, and executes the shell script within the new session.
I have tried the code below in the shell script.
#!/bin/sh screen -S tf2 ./startserver.sh
When I execute the script, it creates the screen 'tf2' and enters the session as I wanted. The server does not start where I wanted it to however, it boots up outside of the screen session where I executed it. We need it to be inside the screen session so that our game server can be online without anyone attending the terminal.
I am not the best with shell scripts yet but I am willing to learn, am I doing something wrong? Is there another way I should be going about this?