60 lines
1.5 KiB
Bash
Executable File
60 lines
1.5 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
|
|
|
|
#
|
|
# module exist
|
|
#
|
|
../vendor/drush/drush/drush pml --fields=name,status | grep "endpoint_get_${NODE}"
|
|
if [ $? -ne 0 ];then
|
|
echo -n " 🌈 Cannot find module ${B}endpoint_get_${NODE}${E}"
|
|
exit
|
|
fi
|
|
echo -e " 🍓 Found module ${B}endpoint_get_${NODE}${E}"
|
|
|
|
#
|
|
# Clear cache
|
|
#
|
|
../vendor/drush/drush/drush cr
|
|
|
|
#
|
|
# if module is enabled, disable it
|
|
#
|
|
../vendor/drush/drush/drush pml --fields=name,status > /tmp/.drush.pml
|
|
cat /tmp/.drush.pml | grep -e "Enabled" | grep "endpoint_get_${NODE}"
|
|
if [ $? -eq 0 ];then
|
|
echo -en "\n 🍓 Disabling module ${B}endpoint_get_${NODE}${E}"
|
|
../vendor/drush/drush/drush pmu "endpoint_get_${NODE}"
|
|
fi
|
|
|
|
#
|
|
# if is not disabled, dont delete it
|
|
#
|
|
../vendor/drush/drush/drush pml --fields=name,status > /tmp/.drush.pml
|
|
cat /tmp/.drush.pml | grep -e "Enabled" | grep "endpoint_get_${NODE}"
|
|
if [ $? -eq 0 ];then
|
|
echo -n "\n 🌈 Cannot delete enabled module ${B}endpoint_get_${NODE}${E}"
|
|
../vendor/drush/drush/drush pml --fields=name,status | grep "endpoint_get_${NODE}"
|
|
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
|
|
|