-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletesite.sh
executable file
·50 lines (37 loc) · 1009 Bytes
/
deletesite.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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# Shell script to delete a specified Valet site, directory and database.
# Based on https://jeremy.hu/dev-environment-laravel-valet-wp-cli/
#########################################
### USAGE:
###
### deletesite
### deletesite mywebsite
#########################################
# Load config file
SCRIPT=$(readlink -f "$0")
SCRIPT_PATH=$(dirname "$SCRIPT")
CONFIG_FILE=$SCRIPT_PATH"/ssscripts.conf"
if test -f "$CONFIG_FILE"; then
source $CONFIG_FILE
else
echo "Error: Missing ssscripts.conf in script directory: "$SCRIPT_PATH
exit 0
fi
# Ask for site name to delete
if [ -z "$1" ]; then
echo "Which site do you want to delete?"
read site_name
# Or get from first argument
else
site_name=$1
fi
# Change into sites dir
cd $SITES_PATH
echo "Unlinking site from Valet..."
valet unlink $site_name
echo "Deleting site directory..."
rm -rf $site_name
echo "Deleting site database..."
echo "DROP DATABASE IF EXISTS $site_name" | $DATABASE_CMD
echo "Done! Site deleted."
exit 0;