1

My problem is as follows: I want to to modify my Ubuntu LiveCD to run several commands at startup, but I'm new to Ubuntu development and don't know how to do this. What is the proper way to run these commands every time I boot Ubuntu?

Here are ex. commands:

sudo rm /home/ubuntu/Desktop/examples.desktop
sudo perl -e 'print("[DesktopEntry]\nVersion=1.0\nType=Application\nTerminal=false\nIcon=xinput_calibrator\nName=Calibraion\nExec=env /usr/bin/xinput_calibrator\n");' > /home/ubuntu/Desktop/Calibrate.desktop
sudo /home/ubuntu/Desktop/Calibrate.desktop

EDIT!!!

I've actually tried modifying rc.local file and it looks like this now:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

sudo rm /home/ubuntu/Desktop/examples.desktop
sudo perl -e 'print("[DesktopEntry]\nVersion=1.0\nType=Application\nTerminal=false\nIcon=xinput_calibrator\nName=Calibraion\nExec=env /usr/bin/xinput_calibrator\n");' > /home/ubuntu/Desktop/Calibrate.desktop
sudo /home/ubuntu/Desktop/Calibrate.desktop

exit 0

But still I don't know if it is going to work. I want to be sure before I'll build iso.

EDIT 2!!!

I've build iso file using this tutorial: https://help.ubuntu.com/community/LiveCDCustomization I've done steps:

  1. Extract the CD .iso contents
  2. Extract the Desktop system
  3. then I've edited the rc.local file and saved
  4. Assembling the file system ( I've ommited "Regenerate manifest" point)

and now I get error

No init found. Try passing init= bootarg

while booting my LiveCD.

passing init= bootarg results in:

/bin/sh: bootarg: not found

What am I doing wrong?

Thanks

4
  • you don't need sudo in rc.local. remove them other wise it won't work
    – Web-E
    Jul 23, 2012 at 8:24
  • I've edited the question again
    – Sayid
    Jul 23, 2012 at 9:33
  • Would it be easier to create a live usb with persistence, so you can store your settings, and then boot off of that?
    – user76204
    Jul 23, 2012 at 11:33
  • I'm sorry but it is not possible. The build must be read only.
    – Sayid
    Jul 24, 2012 at 6:26

2 Answers 2

4

To execute a script at startup of Ubuntu

Edit /etc/rc.local and add your commands
The script must always end with exit 0 

To execute a script upon rebooting Ubuntu

Put your script in /etc/rc0.d
Make it executable (sudo chmod +x myscript)
Note: The scripts in this directory are executed in alphabetical order 

The name of your script must begin with K99 to run at the right time.

I'm not sure if this will help you in your situation but I will look some more and see what I can come up with.

To execute a script at shutdown

Put your script in /etc/rc6.d
Make it executable (sudo chmod +x myscript)
Note: The scripts in this directory are executed in alphabetical order 

The name of your script must begin with K99 to run at the right time.

This question has been asked before here is the link. How to run commands at login on ubuntu 12.04?

3
  • I've edited the question
    – Sayid
    Jul 23, 2012 at 8:05
  • Bingothat is the right way to do it. Build your ISO and it should function. Let me know how it turns out.
    – user78723
    Jul 23, 2012 at 8:36
  • EDITED QUESTION AGAIN
    – Sayid
    Jul 23, 2012 at 9:33
0

It is a botched build. In other words it is faulty you need to use another disc. If you decide to use a different disc make sure you use a different type to omit other problems. You need to make sure that you do this so we can continue troubleshooting. That is the first step. Botched builds are quite frequent and should always be a first step towards troubleshooting when trying to do something like this. If you attempt this and you still get the same error get back to me I have a friend who does this kind of thing on the regular and I am going to pass this on to him and see what he thinks. But in the meantime get busy.

Very Respectfully,

Matthew Kaulfers

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .