Options via browser to shutdown VM

28 views
Skip to first unread message

Edgar Oliveira

unread,
Jan 13, 2016, 8:52:41 AM1/13/16
to Vagrant
Hello,

Any idea to create an file for when I accessed through browser it execute the code to shutdown my virtual machine? 
E.G. I accessed the IP 192.168.1.50, corresponding the VM, and when access the file something.php and inside this file execute the code which the same execute via terminal "sudo shutdown -h 1".

Which language do you advice to build this option? The vagrant was any option for this?

Thanks

Alvaro Miranda Aguilera

unread,
Jan 14, 2016, 12:46:33 AM1/14/16
to vagra...@googlegroups.com
Hello Edgard.

You can have a web browser, put a cgi file with bash, and run sudo poweroff.


Does that helps?

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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/0dbcfcbe-7e58-41ca-9dbf-84d665eff2eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Edgar Oliveira

unread,
Jan 16, 2016, 7:37:59 PM1/16/16
to Vagrant
Hello Alvaro,

I am always learn with you :) 

Thank you for your advice. 
I am studying this examples "http://www.yolinux.com/TUTORIALS/BashShellCgi.html". Because the article which share with me yet are advanced for me.

Not yet I explored the site but If you can help me, I will appreciate.
When I create folder with name "cgi-bin" I received the error 403 Forbidden. How can I fix that? This erros only happen when I create the folder with this name.

Thanks

Alvaro Miranda Aguilera

unread,
Jan 16, 2016, 10:55:02 PM1/16/16
to vagra...@googlegroups.com
Hello Edgard

Seems I sent an incomplete message.

I did this project for you:

check the provision.sh and the cgi-bin folder


And that will poweroff the machine.

Let me know if that is what you are after.

If you got questions, just le me know, happy to help.

Alvaro.

On Sun, Jan 17, 2016 at 4:22 PM, Alvaro Miranda Aguilera <kik...@gmail.com> wrote:
Hello Edgard.

You need to find out where the cgi-bin directory is.

Seems on ubuntu is here:

/usr/lib/cgi-bin/


(is on the webpage tutorial)


--
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+...@googlegroups.com.

Edgar Oliveira

unread,
Jan 17, 2016, 6:01:25 AM1/17/16
to Vagrant
Hello Alvaro,

Thanks for your help,

I downloaded the archives but I had to do some changes. I change the file "Vagrantfile" to:

Vagrant.configure(2) do |config|
  config.vm.box = "hashicorp/precise32"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "private_network", ip: "192.168.33.48"
  config.vm.provision "shell", path: "provision.sh", privileged: false
  config.vm.synced_folder "cgi-bin", "/usr/lib/cgi-bin",
id: "cgi-bin", :mount_options => ["uid=33,gid=33"]
  config.vm.synced_folder "www", "/var/www/",
id: "www", :mount_options => ["uid=33,gid=33"]
end

And when tried access "http://192.168.33.48/cgi-bin/poweroff.sh" I received this error "500 Internal Server Error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Apache/2.2.22 (Ubuntu) Server at 192.168.33.48 Port 80"

I looked the file error, on /var/log/apache2/error.log" and see this lines:

[Sun Jan 17 10:54:05 2016] [error] (13)Permission denied: exec of '/usr/lib/cgi-bin/poweroff.sh' failed
[Sun Jan 17 10:54:05 2016] [error] [client 192.168.33.1] Premature end of script headers: poweroff.sh

What I got understood which the script, poweroff.sh, has a error or I couldn't permissions to run it.
Thanks

Alvaro Miranda Aguilera

unread,
Jan 17, 2016, 6:46:06 AM1/17/16
to vagra...@googlegroups.com
I tested before uploading.

Does it run for you without any change?



Reply all
Reply to author
Forward
0 new messages