Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 9005  / 1 Year ago, sat, january 14, 2023, 4:18:49

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]
Version=1.0
Type=Application
Terminal=false
Icon=xinput_calibrator
Name=Calibraion
Exec=env /usr/bin/xinput_calibrator
");' > /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]
Version=1.0
Type=Application
Terminal=false
Icon=xinput_calibrator
Name=Calibraion
Exec=env /usr/bin/xinput_calibrator
");' > /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


More From » live-cd

 Answers
1

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?


[#36640] Sunday, January 15, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
llael

Total Points: 209
Total Questions: 102
Total Answers: 118

Location: Rwanda
Member since Fri, May 5, 2023
1 Year ago
;