LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-14-2021, 01:32 PM   #1
mikedelo
Member
 
Registered: Mar 2004
Location: Staten Island, NY
Distribution: MX Linux
Posts: 63

Rep: Reputation: 0
Batch Script


Hi! I have a desktop computer (running Ubuntu) with Pi-Hole running on a VM. I would like to have the pi-hole VM automatically ran when the desktop computer reboots. Here are the commands I would like to be automatically ran. How do I create a script to run when the desktop boots up?

vboxmanage startvm "pi-hole" --type headless

Then after a short period of time, run the command to update gravity as I notice this needs to be done each time I start the VM.
 
Old 11-14-2021, 02:03 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Very simply, place that line into a file, make the file executable, and you're done.

Yes there are other things which can be done, examine other bash scripts to see some examples.

Reference link in my signature for bash, and that link has more standard references.

Last edited by rtmistler; 11-14-2021 at 02:05 PM.
 
1 members found this post helpful.
Old 11-15-2021, 12:02 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by mikedelo View Post
I would like to have the pi-hole VM automatically ran when the desktop computer reboots. Here are the commands I would like to be automatically ran.
Code:
vboxmanage startvm "pi-hole" --type headless
Assuming you want this run when you log into the GUI: most desktop environments provide an autostart/startup mechanism you can use. Look around your settings/menus.

If you want it to start earlier, things are trickier.

Quote:
Originally Posted by mikedelo View Post
Then after a short period of time, run the command to update gravity
Where, inside the vm?
 
Old 11-15-2021, 12:52 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,949

Rep: Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326
in virtualbox you can configure a VM to auto start during boot (if I remember well). You do not need to re-implement it.
Also you can configure pi-hole to update gravity automatically at the start (of that VM).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Batch Script to Shell Script sandeep.gcet@gmail.com Linux - Newbie 10 10-17-2013 11:36 AM
[SOLVED] how to write a batch file in linux?and what are batch(.bat) file benefits? karthilin Linux - Newbie 8 10-15-2012 02:10 PM
Change batch script to shell script alan.belizario Programming 5 03-31-2005 12:41 AM
Change batch script to shell script alan.belizario Linux - Software 1 03-30-2005 01:49 AM
Batch mv and tr script ... OrangeWarp Linux - General 1 12-11-2002 05:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration