Created
October 20, 2020 17:52
-
-
Save irineujunior/c13b7c9aa8d07e95cf64e447dfc732e1 to your computer and use it in GitHub Desktop.
Homestead Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# If you would like to do some extra provisioning you may | |
# add any commands you wish to this file and they will | |
# be run after the Homestead machine is provisioned. | |
sudo swapoff /swapfile | |
sudo fallocate -l 4G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | |
sudo apt-get install mc -y | |
composer global require hirak/prestissimo --no-progress | |
composer global update --no-progress | |
# Create workers | |
queueSite() { | |
conf=/etc/supervisor/conf.d/[email protected] | |
if sudo [ -f $conf ]; then | |
sudo rm -rf $conf | |
fi | |
if sudo [ ! -f $conf ]; then | |
cat << EOF | sudo tee $conf >/dev/null | |
[program:laravel-worker-$@] | |
process_name=%(program_name)s_%(process_num)02d | |
command=php /home/vagrant/code/$@/artisan queue:work --queue=high,default,low | |
autostart=true | |
autorestart=true | |
user=vagrant | |
numprocs=1 | |
redirect_stderr=true | |
stdout_logfile=/home/vagrant/code/$@/storage/logs/worker-%(process_num)02d.log | |
EOF | |
fi | |
sudo supervisorctl reread | |
sudo supervisorctl update | |
sudo supervisorctl start laravel-worker-$@:* | |
} | |
queueSite helpers.avangard.dev | |
queueSite hyundai-phoenix.dev | |
queueSite mercedes-avangard.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ..="cd .." | |
alias ...="cd ../.." | |
alias h='cd ~' | |
alias c='clear' | |
alias art=artisan | |
alias cr=composerUpdate | |
alias cu='composer update --no-progress' | |
alias da='composer dumpauto' | |
alias cuda='composer self-update --no-progress && composer global update --no-progress && composer update --no-progress' | |
alias composer56=composer56 | |
alias phpspec='vendor/bin/phpspec' | |
alias phpunit='vendor/bin/phpunit' | |
alias serve=serve-laravel | |
alias xoff='sudo phpdismod -s cli xdebug' | |
alias xon='sudo phpenmod -s cli xdebug' | |
function composerUpdate() { | |
composer --no-progress require "$@" | |
} | |
function composer56() { | |
/usr/bin/php5.6 /usr/local/bin/composer $@ --working-dir="$(pwd)" | |
} | |
function artisan() { | |
php artisan "$@" | |
} | |
function dusk() { | |
pids=$(pidof /usr/bin/Xvfb) | |
if [ ! -n "$pids" ]; then | |
Xvfb :0 -screen 0 1280x960x24 & | |
fi | |
php artisan dusk "$@" | |
} | |
function php56() { | |
sudo update-alternatives --set php /usr/bin/php5.6 | |
} | |
function php70() { | |
sudo update-alternatives --set php /usr/bin/php7.0 | |
} | |
function php71() { | |
sudo update-alternatives --set php /usr/bin/php7.1 | |
} | |
function php72() { | |
sudo update-alternatives --set php /usr/bin/php7.2 | |
} | |
function serve-apache() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-apache.sh | |
sudo bash /vagrant/scripts/serve-apache.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-apache domain path" | |
fi | |
} | |
function serve-laravel() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-laravel.sh | |
sudo bash /vagrant/scripts/serve-laravel.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve domain path" | |
fi | |
} | |
function serve-proxy() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo dos2unix /vagrant/scripts/serve-proxy.sh | |
sudo bash /vagrant/scripts/serve-proxy.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-proxy domain port" | |
fi | |
} | |
function serve-silverstripe() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-silverstripe.sh | |
sudo bash /vagrant/scripts/serve-silverstripe.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-silverstripe domain path" | |
fi | |
} | |
function serve-spa() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-spa.sh | |
sudo bash /vagrant/scripts/serve-spa.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-spa domain path" | |
fi | |
} | |
function serve-statamic() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-statamic.sh | |
sudo bash /vagrant/scripts/serve-statamic.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-statamic domain path" | |
fi | |
} | |
function serve-symfony2() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-symfony2.sh | |
sudo bash /vagrant/scripts/serve-symfony2.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-symfony2 domain path" | |
fi | |
} | |
function serve-symfony4() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-symfony4.sh | |
sudo bash /vagrant/scripts/serve-symfony4.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-symfony4 domain path" | |
fi | |
} | |
function serve-pimcore() { | |
if [[ "$1" && "$2" ]] | |
then | |
sudo bash /vagrant/scripts/create-certificate.sh "$1" | |
sudo dos2unix /vagrant/scripts/serve-pimcore.sh | |
sudo bash /vagrant/scripts/serve-pimcore.sh "$1" "$2" 80 443 "${3:-7.1}" | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " serve-pimcore domain path" | |
fi | |
} | |
function share() { | |
if [[ "$1" ]] | |
then | |
ngrok http ${@:2} -host-header="$1" 80 | |
else | |
echo "Error: missing required parameters." | |
echo "Usage: " | |
echo " share domain" | |
echo "Invocation with extra params passed directly to ngrok" | |
echo " share domain -region=eu -subdomain=test1234" | |
fi | |
} | |
function flip() { | |
sudo bash /vagrant/scripts/flip-webserver.sh | |
} | |
function __has_pv() { | |
$(hash pv 2>/dev/null); | |
return $? | |
} | |
function __pv_install_message() { | |
if ! __has_pv; then | |
echo $1 | |
echo "Install pv with \`sudo apt-get install -y pv\` then run this command again." | |
echo "" | |
fi | |
} | |
function dbexport() { | |
FILE=${1:-/vagrant/mysqldump.sql.gz} | |
# This gives an estimate of the size of the SQL file | |
# It appears that 80% is a good approximation of | |
# the ratio of estimated size to actual size | |
SIZE_QUERY="select ceil(sum(data_length) * 0.8) as size from information_schema.TABLES" | |
__pv_install_message "Want to see export progress?" | |
echo "Exporting databases to '$FILE'" | |
if __has_pv; then | |
ADJUSTED_SIZE=$(mysql --vertical -uhomestead -psecret -e "$SIZE_QUERY" 2>/dev/null | grep 'size' | awk '{print $2}') | |
HUMAN_READABLE_SIZE=$(numfmt --to=iec-i --suffix=B --format="%.3f" $ADJUSTED_SIZE) | |
echo "Estimated uncompressed size: $HUMAN_READABLE_SIZE" | |
mysqldump -uhomestead -psecret --all-databases --skip-lock-tables 2>/dev/null | pv --size=$ADJUSTED_SIZE | gzip > "$FILE" | |
else | |
mysqldump -uhomestead -psecret --all-databases --skip-lock-tables 2>/dev/null | gzip > "$FILE" | |
fi | |
echo "Done." | |
} | |
function dbimport() { | |
FILE=${1:-/vagrant/mysqldump.sql.gz} | |
__pv_install_message "Want to see import progress?" | |
echo "Importing databases from '$FILE'" | |
if __has_pv; then | |
pv "$FILE" --progress --eta | zcat | mysql -uhomestead -psecret 2>/dev/null | |
else | |
cat "$FILE" | zcat | mysql -uhomestead -psecret 2>/dev/null | |
fi | |
echo "Done." | |
} | |
function xphp() { | |
(php -m | grep -q xdebug) | |
if [[ $? -eq 0 ]] | |
then | |
XDEBUG_ENABLED=true | |
else | |
XDEBUG_ENABLED=false | |
fi | |
if ! $XDEBUG_ENABLED; then xon; fi | |
php \ | |
-dxdebug.remote_host=192.168.10.1 \ | |
-dxdebug.remote_autostart=1 \ | |
"$@" | |
if ! $XDEBUG_ENABLED; then xoff; fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
ip: "192.168.10.10" | |
memory: 2048 | |
cpus: 1 | |
provider: virtualbox | |
authorize: ~/.ssh/pub | |
keys: | |
- ~/.ssh/private.ppk | |
folders: | |
- map: c:/OpenServer/domains | |
to: /home/vagrant/code | |
- map: e:/_sites/public | |
to: /home/vagrant/code/first.site.loc/storage/app/public | |
- map: e:/_sites/public | |
to: /home/vagrant/code/second.site.loc/storage/app/public | |
sites: | |
- map: first.site.loc | |
to: /home/vagrant/code/first.site.loc/public | |
subdomain: promo.first.site.loc | |
schedule: true | |
- map: second.site.loc | |
to: /home/vagrant/code/second.site.loc/public | |
schedule: true | |
php: "5.6" | |
databases: | |
- helpers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment