dev/endpoints/endpoint-get-delete.sh
2024-02-19 12:25:53 +02:00

45 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
SITE=${1}
NODE=${2}
BASE_DIR="/var/www/sites"
MODULES="modules/custom"
[ "$#" -lt 2 ] && echo "Argument missing" && exit
[ ! -d ${SITE} ] && echo "Directory ${SITE} does not exist" && exit
[ -d ${SITE}/web ] && SITE=${SITE}/web
cd /var/www/sites/${SITE}
echo
# if module does not exist
../vendor/drush/drush/drush pml | grep "(endpoint_get_${NODE})"
if [ $? -ne 0 ];then
echo -n " 🌈 Cannot found module ${B}endpoint_get_${NODE}${E}"
exit
fi
echo -e " 🍓 Found module ${B}endpoint_get_${NODE}${E}"
# if is enabled, disable it
../vendor/drush/drush/drush pml | grep -e "Enabled" | grep "(endpoint_get_${NODE})" &> /dev/null
if [ $? -eq 0 ];then
echo -n " 🍓 Disabling module ${B}endpoint_get_${NODE}${E}"
../vendor/drush/drush/drush pmu "endpoint_get_${NODE}"
../vendor/drush/drush/drush pml | grep "(endpoint_get_${NODE})"
fi
# if is not disabled, dont delete it
../vendor/drush/drush/drush pml | grep -e "Disabled" | grep "(endpoint_get_${NODE})" &> /dev/null
if [ $? -ne 0 ];then
echo -n " 🌈 Cannot deleting enabled module ${B}endpoint_get_${NODE}${E}"
exit
fi
# delete the damn thing
rm "/var/www/sites/${SITE}/modules/custom/endpoint_get_${NODE}" -rf
if [ $? -eq 0 ];then
echo -e " 🍓 Directory ${B}${SITE}/modules/custom/endpoint_get_${NODE}${E} deleted"
fi