-
Notifications
You must be signed in to change notification settings - Fork 0
/
.oneshoe
133 lines (108 loc) · 3.34 KB
/
.oneshoe
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
# One Shoe environment variable
export ONESHOE_ENV=development
# Aliases for default scripts in Drupal projects
alias oneshoe-build="bash scripts/build.sh"
alias oneshoe-clean-install="bash scripts/clean-install.sh"
alias oneshoe-deploy="bash scripts/deploy.sh"
alias oneshoe-drush-update="bash scripts/drush-update.sh"
alias oneshoe-maintenance="bash scripts/maintenance.sh"
# - Add usage documentation
function oneshoe-create-project() {
GIT_REPO=$1
PROJECT_NAME=$2
if [ -z $GIT_REPO ]
then
echo "Please provide a Git repository"
return
fi
if [ -z $PROJECT_NAME ]
then
PROJECT_NAME=`echo $GIT_REPO | sed -n 's#.*/\([^.]*\)\.git#\1#p'`
fi
# TODO Add check to see if git is installed
# TODO Add check to see if clone succeeded
# TODO Add functionallity to checkout in a certain branch
echo "Checkout project"
git clone $GIT_REPO $PROJECT_NAME
# TODO Add check to see if valet-plus is installed or create db without valet-plus
# TODO Add check to see if db creation succeeded
echo "Create database"
valet db create $PROJECT_NAME
echo "Go to project root"
cd $PROJECT_NAME
if [ -d "./web/" ]
then
WEBROOT="./web/"
SETTINGS_FILE_PATH="./web/sites/default"
elif [ -d "./docroot/" ]
then
WEBROOT="./web/"
SETTINGS_FILE_PATH="./docroot/sites/default"
elif [ -d "./sites/" ]
then
WEBROOT="./"
SETTINGS_FILE_PATH="./sites/default"
else
echo "${red}Failed to find the settings file location${reset}"
return
fi
SETTINGS_FILE="${SETTINGS_FILE_PATH}/settings.php"
echo "SETTINGS_FILE: $SETTINGS_FILE"
echo "Copy the default settings file"
if [ -f $SETTINGS_FILE ]
then
echo "${yellow}There is a settings file present. Remove it.${reset}"
sudo chmod 777 "$SETTINGS_FILE"
sudo rm "$SETTINGS_FILE"
fi
sudo cp "${SETTINGS_FILE_PATH}/default.settings.php" $SETTINGS_FILE
if [ 0 -eq $? ]
then
echo "Settings file created";
else
echo "${red}Couldn't create a settings file${reset}"
return
fi
sudo chmod 777 $SETTINGS_FILE
echo "" >> $SETTINGS_FILE
if [ 0 -gt $? ]
then
echo "${red}Couldn't write in settings file${reset}"
return
fi
if [ 0 -eq $? ]
then
# TODO make the database details dynamic
echo "\$databases['default']['default'] = array (
'database' => '${PROJECT_NAME}',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'driver' => 'mysql',
);" >> $SETTINGS_FILE
else
echo "${red}Couldn't write in settings file${reset}";
return
fi
echo "Database details have been added to the settings file"
sudo chmod 666 $SETTINGS_FILE;
if [ -f scripts/clean-install.sh ]
then
echo "Run clean install"
bash scripts/clean-install.sh
else
echo "${yellow}No clean install script to run${reset}";
fi
if [ -z $WEBROOT ]
then
echo "Couldn't link the webroot to valet"
else
cd $WEBROOT
valet link $PROJECT_NAME
cd -
VALET_DOMAIN=`valet domain`
echo "Project link set. You can visit the website at http://${PROJECT_NAME}.${VALET_DOMAIN}/"
fi
echo "${green}Project creation finished${reset}"
}