Skip to content

Commit

Permalink
Proposal: user-specific after.sh files (laravel#932)
Browse files Browse the repository at this point in the history
* Update the Vagrantfile(s) to run an after.local.sh script, if present

* Add a second line to the default after.sh, informing users about after.local.sh

* Block an after.local.sh from being commited to this repo

* Instead of focusing on the fact that this is a script that runs *after* `after.sh`, help assign more meaning to it with the name `user-customizations.sh`
  • Loading branch information
stevegrunwell authored and svpernova09 committed Sep 2, 2018
1 parent d429879 commit c123d98
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ phpunit.xml
/mysqldump.sql.gz
/mysql_backup
/postgres_backup
/user-customizations.sh
5 changes: 5 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))
homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Expand Down Expand Up @@ -38,6 +39,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
end

if File.exist? customizationScriptPath then
config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
end

if Vagrant.has_plugin?('vagrant-hostsupdater')
config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
elsif Vagrant.has_plugin?('vagrant-hostmanager')
Expand Down
4 changes: 4 additions & 0 deletions resources/after.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
# 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.
#
# If you have user-specific configurations you would like
# to apply, you may also create user-customizations.sh,
# which will be run after this script.
5 changes: 5 additions & 0 deletions resources/localized/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname
homesteadYamlPath = File.expand_path("Homestead.yaml", File.dirname(__FILE__))
homesteadJsonPath = File.expand_path("Homestead.json", File.dirname(__FILE__))
afterScriptPath = "after.sh"
customizationScriptPath = "user-customizations.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')
Expand Down Expand Up @@ -38,6 +39,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
end

if File.exist? customizationScriptPath then
config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
end

if defined? VagrantPlugins::HostsUpdater
config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
end
Expand Down

0 comments on commit c123d98

Please sign in to comment.