I wrote my first shell script yesterday. It seems to work well, but I thought I'd post it up in case someone could suggest "It would work better if you..."
I wanted my teamspeak
server to always be running on my PC.
I've put this short script in my ~/.bash_profile file to check if the server is already running, and if it is not, to start it.
I find it useful because I sometimes reboot linux, and often log into linux remotely. If the server was started without checking if it was already running, I would get various issues.
This is my first attempt at shell scripting, it seems to work well, but I'd appreciate any comments!
if test $? -eq 1
echo tsserver2.pid not found, tsserver started!
echo tsserver.pid found. tsserver is assumed to be running.
Obviously, replace ~/Documents/downloads... with the path to your own teamspeak install directory.
One thing that I'd like to do to improve it is in the case of tsserver.pid not existing,
cat: /home/toby/Documents/downloads/teamspeak/tss2_rc2/tsserver2.pid: No such file or directory
It would be nice if this was silent. I've tried adding "> /dev/null" to no avail. Any suggestions? Something like "echo off"?