This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
phpci-installer.sh
99 lines (82 loc) · 2.62 KB
/
phpci-installer.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
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
#!/bin/bash
#------------------------------------------------------------------------------
# PHPCI Installer for Laravel Homestead
#------------------------------------------------------------------------------
#
# Project URL: https://github.com/irazasyed/phpci-installer
#
##################
# Default Config #
##################
DEFAULT_DOMAIN=phpci.app
DEFAULT_DIRNAME=phpci
DB_NAME=phpci
MYSQL_CONF=~/.my.cnf
##################
# PHPCI Defaults #
##################
ADMIN_EMAIL=phpci@homestead.vm
ADMIN_PASSWORD=secret
[[ "$1" ]] && DEFAULT_DOMAIN=$1
[[ "$2" ]] && ADMIN_EMAIL=$2
[[ "$3" ]] && ADMIN_PASSWORD=$3
[[ "$4" ]] && DEFAULT_DIRNAME=$4
DEFAULT_URL=http://$DEFAULT_DOMAIN
DEFAULT_PATH=$PWD/$DEFAULT_DIRNAME
#
# Helper function to output in color
#
coloredEcho() {
tput setaf $2;
echo "$1";
tput sgr0;
}
info() {
coloredEcho "$1" 2;
}
note() {
coloredEcho "$1" 3;
}
info "****************************"
info " Welcome to PHPCI Installer"
info "****************************"
# Download PHPCI & Run Composer Install
info "Downloading and Installing PHPCI Dependencies."
composer create-project block8/phpci $DEFAULT_PATH --keep-vcs --no-dev --prefer-dist
cd $DEFAULT_PATH && composer du -o
# Increase PHP Memory Limit
info "Increasing PHP Memory Limit."
sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php5/cli/php.ini
# Setup Database - Uses Homestead's standard create MySQL script.
info "Setting up MySQL Database."
sudo bash /vagrant/scripts/create-mysql.sh $DB_NAME
info "Adding MySQL Config."
touch $MYSQL_CONF
cat >$MYSQL_CONF <<EOF
[mysqld]
max_allowed_packet=64M
innodb_log_file_size=512M
innodb_log_buffer_size=768M
EOF
sudo service mysql restart
# Run PHPCI Install
info "Starting PHPCI Console Install."
php ./console phpci:install --url=$DEFAULT_URL --db-host=localhost --db-name=$DB_NAME --db-user=homestead --db-pass=secret --admin-name=homestead --admin-pass=$ADMIN_PASSWORD --admin-mail=$ADMIN_EMAIL
# Setup Cron - Makes sure there is no cron job already set.
info "Setting up Cron Job!"
croncmd="php ${DEFAULT_PATH}/console phpci:run-builds"
cronjob="* * * * * $croncmd"
cat <(fgrep -i -v "${croncmd}" <(crontab -l)) <(echo "${cronjob}") | crontab -
sudo service cron restart
# Provision
info "Provisioning PHPCI"
sudo bash /vagrant/scripts/serve.sh $DEFAULT_DOMAIN $(pwd)/public
info "*********************"
info "Install success."
info "You can access it at:"
note $DEFAULT_URL
info "Login Credentials:"
note "Email: ${ADMIN_EMAIL}"
note "Password: ${ADMIN_PASSWORD}"
info "*********************"
info "Don't forget to add the domain to /etc/hosts file on your main machine!"