I have a service script in CentOS 6.10 that needs to touch a file when service myservice stop is called by the user or process, but not when stop() in the script is invoked by shutdown or reboot by initd. The service script is based on the template found on any CentOS system.
I imagine the best way of doing that is to have an if statement in the stop() method that checks whether or not the system is going down, but what would I check to find that out? runlevel 0 or 6 perhaps? Is there a better way of doing this than checking the system runlevel?