Im trying to create my own version of Ubuntu, and I want a command to run on first boot only. Is this possible?
Asked
Active
Viewed 707 times
1
-
P.S. i am new to ubuntu programming – SorensenGaming Jan 05 '18 at 18:55
-
The script that will be executed could delete itself at its end. – pa4080 Jan 05 '18 at 18:57
-
How can I make that script run on first boot ONLY though? Its an install file for GreyHole – SorensenGaming Jan 05 '18 at 18:58
-
I just understood what you said, I can't seem to brain today as I am sick, but what would I need to do to add a file that does this? – SorensenGaming Jan 05 '18 at 19:01
-
The positional parameter `$0` contains the execution path and the name of the script. So IMO you could add `rm "$0"` at the end of the script. Here is an example: https://stackoverflow.com/a/192337/6543935 – pa4080 Jan 05 '18 at 19:05
-
I understand everything you have said so far, but where would I put this file, what would the format be, and what would I name it? (like I said I am new to this sort of thing) – SorensenGaming Jan 05 '18 at 19:08
-
curl -Ls http://bit.ly/greyhole-package | sudo bash (this is the script I am trying to run at first boot) – SorensenGaming Jan 05 '18 at 19:10
-
You could execute the script from `/etc/rc.local`, as it is shown here: https://askubuntu.com/q/9853/566421 In this case you should add into the end of the script line as this: `sed -i "/$0/d" /etc/rc.local && rm "$0"`. An other other way is to place your script in `/etc/init.d/` and link it to `/etc/rcX.d/`, where `X` is a certain runlevel: https://debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian – pa4080 Jan 05 '18 at 19:32
-
Thnx for the reply, but does this work in the server version of ubuntu as well? – SorensenGaming Jan 05 '18 at 19:36
-
Yes: https://askubuntu.com/questions/31081/whats-the-difference-between-the-server-version-and-the-desktop-version – pa4080 Jan 05 '18 at 19:38
-
So where would i finde /etc/rc.local? its not coming up in search. – SorensenGaming Jan 05 '18 at 19:39
-
https://imgur.com/a/PbADH this is all i have – SorensenGaming Jan 05 '18 at 19:48