Error executing startup scripts within script

15 views
Skip to first unread message

Marcus Povey

unread,
Mar 28, 2018, 12:16:28 PM3/28/18
to Vagrant
A head scratcher here...

So, have a vagrant project, and the vagrant file runs a script every boot in order to start various services (e.g. elastic search), as so

Vagrant.configure("2") do |config|

  config.vm.box = "cbednarski/ubuntu-1604"

  ...

  config.vm.provision :shell, path: "vagrant/startup.sh", run: "always"

end

In startup.sh, we have:

echo "Starting elastic search..."
cd /var/www/bin/; 
chmod 755 run_es_vagrant.sh; 
sudo -u www-data DOMAIN='myproject' nohup ./run_es_vagrant.sh &

I have verified these are present in the correct place.

On my machine everything works fine every time, but when my colleague tries (who unfortunately is faaaaar away, so I can't see exactly what they're doing), when it gets to this line they always get:

default: nohup:
default: failed to run command './run_es_vagrant.sh'
default: : No such file or directory

Any thoughts on what my colleague is doing differently that could prevent this from working?

Marcus

Alvaro Miranda Aguilera

unread,
Mar 29, 2018, 5:31:39 AM3/29/18
to vagra...@googlegroups.com
Hello

worth to check they have a copy of all the files.


not sure the internals, but basically on this other person VM, this file:
 /var/www/bin/run_es_vagrant.sh

doesnt exists.

Not sure how those files get there, but maybe a failed provisioning.

alvaro


Marcus Povey

unread,
Mar 30, 2018, 9:12:42 AM3/30/18
to Vagrant
I got to the bottom of it...

It was because the script was being stored on git and checked out on a windows machine. On my linux host, this caused no problems, but on their windows machine git was converting line endings.

Because this was a script called within a script, vagrant wasn't automatically converting line endings, so I had to pass the script through dos2unix before running it on the windows host. Not sure if there's a better way, but this hack got things working for now...

Marcus
Reply all
Reply to author
Forward
0 new messages