#!/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 --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}" ../vendor/drush/drush/drush cr # if 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}" # cat ./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}" fi # if is not disabled, dont delete it ../vendor/drush/drush/drush pml --fields=name,status > /tmp/.drush.pml cat ./drush.pml | grep -e "Enabled" | grep "endpoint_get_${NODE}" if [ $? -eq 0 ];then echo -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