I would like to make an executable shell-script that once launched execute a certain action, and if launched again in a second time undo the action. I've tried to define an environment variable to determinate if the action has been already executed, but I can't make it work.
#!/bin/bash
if [ -z ${CUSTOM_VARIABLE} ]
then
CUSTOM_VARIABLE=true
export CUSTOM_VARIABLE
# do stuff here
else
# undo stuff here
unset CUSTOM_VARIABLE
fi
Is this a correct approach? How can I fix the code
Thanks in advance