Executing shell-script to install api

47 views
Skip to first unread message

Vagrant-Newbie

unread,
Jul 24, 2018, 3:08:58 AM7/24/18
to Vagrant
Hello,

i have the vagrant box "hashicorp/precise64" running on my system.
I work on a Vue.JS-Tutorial and now I have to install a file namend "setup.sh" for accessing an api.
I have no idea, how i could do that. What i have to do, to make it work?
Can somebody help me?

Regards

dan...@hashicorp.com

unread,
Jul 24, 2018, 3:26:13 AM7/24/18
to Vagrant
Hi there,

Depending on what the setup.sh does the answer might change.

Usually when you configure a VM in Vagrant you will have to provision the machine using scripts to install components you need.
That is done by adding one extra line in the VM configuration, something like:

Vagrant.configure("2") do |config| 
 
# ... other configuration

  config
.vm.provision "shell", path: "script.sh"
end


This will make the VM execute the script at startup.

You can read more on this at https://www.vagrantup.com/docs/provisioning/basic_usage.html

In case you were trying to do something different, please share more details in order to better understand what you are trying to achieve.

Cheers

Vagrant-Newbie

unread,
Jul 24, 2018, 3:53:27 AM7/24/18
to Vagrant
Hello,

i tried it this way:
Vagrant.configure("2") do |config|


  config
.vm.box = "hashicorp/precise64"
  config
.vm.provision :shell, path: "bootstrap.sh"
  config
.vm.provision :shell, path: "<Path-to...>/setup.sh"
end

and here what the setup.sh should do:
#!/bin/bash;

composer install
|| {
    php
-r "readfile('https://getcomposer.org/installer');" | php;
   
#mv composer.phar /usr/local/bin/composer -n;
    php composer
.phar install;
}
echo
"Create database";
touch database
/database.sqlite;

echo
"Migrate & Seed";
php artisan migrate
;
php artisan db
:seed;
php artisan serve
--port=3000 --host localhost;

If i start my machine (vagrant up) i get the following message:
default: bash: /tmp/vagrant-shell: /bin/bash;: bad interpreter: No such file or directory
The SSH command responded with a non-zero exit status. Vagrant
assumes that
this means the command failed. The output for this command
should be
in the log above. Please read the output to determine what
went wrong
.

I hope this helps for a better understanding.

Cheers

dan...@hashicorp.com

unread,
Jul 24, 2018, 4:04:00 AM7/24/18
to Vagrant
Hi there,

From the error, and the file attached seems the issue lies on semicolons:
/bin/bash;: bad interpreter: No such file or directory

Bash does not need ; at the end of a command and in some cases using it without spaces it will make bash think that the command actually contains a semicolon in the name.
So in your example in the very first line, when the script gets executed it tries to find a file called bash; in the /bin directory.

Not sure about the php -r argument but all the other semicolon should most probably be removed or, at the very least, you should have a space between them and the previous word.

Hope this helps.

Alvaro Miranda Aguilera

unread,
Jul 24, 2018, 4:07:21 AM7/24/18
to vagra...@googlegroups.com
you can replace

#!/bin/bash;

with

#!/usr/bin/env bash

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/8127ada5-f9dc-4083-af14-8676ded17c47%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Vagrant-Newbie

unread,
Jul 24, 2018, 4:37:41 AM7/24/18
to Vagrant
Thanks for your help!

Now the file ist running, but with some problems:
...    
   
default: Composer (version 1.6.5) successfully installed to: /home/vagrant/composer.phar
   
default: Use it: php composer.phar
   
default: Do not run Composer as root/super user! See https://getcomposer.org/root for details
   
default: Composer could not find a composer.json file in /home/vagrant
   
default: To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
   
default: Create database
   
default: Migrate & Seed
   
default: Could not open input file: artisan
   
default: Could not open input file: artisan
   
default: Could not open input file: artisan
The SSH command responded with a non-zero exit status. Vagrant
assumes that
this means the command failed. The output for this command
should be
in the log above. Please read the output to determine what
went wrong
.

That's so difficult. I thougt i have to run the file and the api works. But nothing...

Cheers

Vagrant-Newbie

unread,
Jul 24, 2018, 4:58:26 AM7/24/18
to Vagrant
Could it be, that i have to install Laravel on Vagrant to make it work (because of the artisan command)?

Am Dienstag, 24. Juli 2018 09:08:58 UTC+2 schrieb Vagrant-Newbie:

Alvaro Miranda Aguilera

unread,
Jul 24, 2018, 5:02:21 AM7/24/18
to vagra...@googlegroups.com
so vagrant is running, and running the script.

from the message seems the script/installation is expecting a file artisan

so i would suggest check the project documentation, or try to get some help from them, as seems something non-vagrant specific


alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages