I am making some service and I have a setup.sh file which must be exectued first time (or on update). This script should create some kind of alias which will be accessible from this or new terminal (also after system restart). This alias should point to another executable sh file.
The setup.sh file:
#!/bin/bash
alias customservice='./customservice.sh "$@"'
As you can see this customservice.sh script is ready to accept multiple arguments. With this customservice alias I want to call this script like this:
customservice //show help
customservice start
customservice stop
customservice exec bash
...
My customservice.sh fil:
if [ $# -eq 1 ] && [ $1 = "start" ]; then
//do something
elif [ $# -eq 1 ] && [ $1 = "stop" ]; then
//do something
elif [ $# > 1 ] && [ $1 = "exec" ]; then
//do stuff with ${@:2}
else
echo "help"
fi
Maybe customscript kill command would be nice too. It should remove this alias entirely.
Maybe, if this approach is deprecated, I am open for better solutions.