forked from gusnips/vagrant-yii2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-site.sh
executable file
·37 lines (31 loc) · 927 Bytes
/
remove-site.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
if [ -z "$1" ]; then
echo "You need to specify a domain. F.x. $0 yii2app.dev"
exit
fi
domain="$1"
folder="/var/www/$domain"
echo "This action will remove $folder and all its contents."
read -e -p "It cannot be undone. Are you sure? [y/n] " -i "" confirmation
if [ "$confirmation" != "y" ]; then
echo 'Aborted'
exit
fi
if grep -q "\"$domain\"" /var/www/Vagrantfile; then
#removes domain then fix extra ,
sudo sed -i -e "s/,*\"$domain\",*/,/" \
-e "s/domains= \[,*\(.*\),*\]/domains= [\1]/" \
/var/www/Vagrantfile
echo 'Removed traces from /var/www/Vagrantfile'
fi
if [ -f "/etc/apache2/sites-available/$domain.conf" ]; then
sudo a2dissite "$domain"
sudo rm -rf "/etc/apache2/sites-available/$domain.conf"
sudo service apache2 reload
fi
if [ ! -d "$folder" ]; then
echo "$domain is not a valid domain. Does $folder exist?"
else
sudo rm -rf "$folder"
echo "Directory $folder is now gone"
fi