This repository has been archived by the owner on Feb 11, 2019. It is now read-only.
forked from logoscreative/new-wp-mamp-shell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperfect_setup.sh
executable file
·55 lines (52 loc) · 2.48 KB
/
perfect_setup.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
51
52
53
54
55
#!/bin/sh
# perfect_setup.sh v0.0.7
clear
cd ~/Sites
printf "What is your BitBucket username? "
read BBUSERNAME
printf "What is the name of the BitBucket repo?\n(i.e. perfect-setup or example-site) "
read BBREPO
printf "What should the directory be called on your system?\nThis should be another BitBucket repo name.\nPress return/enter for the default. (default $BBREPO)? "
read NEWDIR
NEWDIR=${NEWDIR:-$BBREPO}
git clone https://$BBUSERNAME@bitbucket.org/tribeswell-llc/$BBREPO.git $NEWDIR
cd $NEWDIR
git remote set-url origin https://$BBUSERNAME@bitbucket.org/tribeswell-llc/$NEWDIR.git
git remote add upstream https://$BBUSERNAME@bitbucket.org/tribeswell-llc/perfect-setup.git
echo "" && echo "Remotes set successfully!" && echo ""
git remote -v && echo ""
printf "Generating DB credentials...\n"
NEWDB=`echo $NEWDIR | tr '-' '_'`
NEWDB=${NEWDB:0:16}
MYSQLPWD=`date +%s | md5 | base64 | head -c 16`
if [[ "$OSTYPE" == "msys" ]]; then
echo ""
/c/MAMP/bin/mysql/bin/mysql --host=localhost -uroot -proot -e "CREATE USER '$NEWDB'@'localhost' IDENTIFIED BY '$MYSQLPWD'; CREATE DATABASE $NEWDB; GRANT ALL ON $NEWDB.* TO '$NEWDB'@'localhost';"
/c/MAMP/bin/mysql/bin/mysql --host=localhost -u$NEWDB -p$MYSQLPWD $NEWDB < ./perfect_setup.sql
else
echo ""
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot -e "CREATE USER '$NEWDB'@'localhost' IDENTIFIED BY '$MYSQLPWD'; CREATE DATABASE $NEWDB; GRANT ALL ON $NEWDB.* TO '$NEWDB'@'localhost';"
/Applications/MAMP/Library/bin/mysql --host=localhost -u$NEWDB -p$MYSQLPWD $NEWDB < ./perfect_setup.sql
fi
if [ -f ./wp-config.php ]
then
echo "" && echo "There appears to be a wp-config.php file already." && open http://$NEWDIR:7888/wp-admin/install.php
else
cp -n ./_wp-config-sample.php ./wp-config.php
SECRETKEYS=$(curl -L https://api.wordpress.org/secret-key/1.1/salt/)
EXISTINGKEYS='put your unique phrase here'
printf '%s\n' "g/$EXISTINGKEYS/d" a "$SECRETKEYS" . w | ed -s ./wp-config.php
WPHOME=$"wp_home_here"
DBUSER=$"username_here"
DBPASS=$"password_here"
DBNAME=$"database_name_here"
sed -i '' -e "s/${WPHOME}/http:\/\/${NEWDIR}:7888/g" ./wp-config.php
sed -i '' -e "s/${DBUSER}/${NEWDB}/g" ./wp-config.php
sed -i '' -e "s/${DBPASS}/${MYSQLPWD}/g" ./wp-config.php
sed -i '' -e "s/${DBNAME}/${NEWDB}/g" ./wp-config.php
cd wp-content/themes/scratch-theme/grunt/
cp -n ./Gruntfile-sample.js ./Gruntfile.js
sed -i '' -e "s/${WPHOME}/${NEWDIR}:7888/g" ./Gruntfile.js
npm install
echo "" && echo "Success!" && open http://$NEWDIR:7888/wp-admin/ && grunt
fi