To check if a file exists (The exclamation ! means "not") :
if [ ! -f ${TOMCAT_DIR}/conf/jobsapp.conf ]
then
echo "Do something"
fi
To check if a script should be run by a specific user:
if [ "$(id -u -n)" != "root" ]; then
echo "This script must be run as root user" 1>&2
exit 1
fi
To prompt a user for an action:
read -p "Deploy on Tomcat (y/n)?" CONT
if [ "$CONT" == "y" ]; then
echo "Deploying on tomcat...";
echo "Finished deploying on tomcat.";
else
echo "Copied files, but didn't deploy on tomcat.";
fi
if [ ! -f ${TOMCAT_DIR}/conf/jobsapp.conf ]
then
echo "Do something"
fi
To check if a script should be run by a specific user:
if [ "$(id -u -n)" != "root" ]; then
echo "This script must be run as root user" 1>&2
exit 1
fi
To prompt a user for an action:
read -p "Deploy on Tomcat (y/n)?" CONT
if [ "$CONT" == "y" ]; then
echo "Deploying on tomcat...";
echo "Finished deploying on tomcat.";
else
echo "Copied files, but didn't deploy on tomcat.";
fi
No comments:
Post a Comment