LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-26-2007, 09:23 AM   #1
lucazorzi
Member
 
Registered: Jul 2006
Location: Italy
Distribution: Ubuntu 11.04, Debian, OS X
Posts: 70

Rep: Reputation: 16
Execute different commands at startup


Hi everyone,
I'd like to know if it's possible to run different commands at startup, choosing them through GRUB.
I mean, I'd like to have a GRUB entry like "Kubuntu - Normal Boot" and another one "Kubuntu - MythTV".
I'd like "Kubuntu - MythTV" not to launch kdm but just mythtv and another command, which I need to enable bluetooth remote controlling.
I thought I could set up a different runlevel to do so, but it seems a bit complicated.

How can I do that?
 
Old 10-26-2007, 09:49 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Check if Ubuntu supports scpm.
 
Old 10-26-2007, 10:15 AM   #3
lucazorzi
Member
 
Registered: Jul 2006
Location: Italy
Distribution: Ubuntu 11.04, Debian, OS X
Posts: 70

Original Poster
Rep: Reputation: 16
It dosn't seem to, as I can't find anything like scpm in the packets.
 
Old 10-26-2007, 02:26 PM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I found this howto posted on one the Ubuntu forum.
http://ubuntuforums.org/showthread.php?t=296808

Another option is to have a variable defined in the "kernel " line of the menu.lst stanza. I think I remember that options not recognized are defined in the environment of the INIT program. Scripts started subsequently may have that variable defined in their environment which could allow for conditional execution in scripts at boot time. I'm not 100% certain. I think there is a howto in the www.tldp.org website on grub or lilo that may verify this, but I wasn't able to find this info scanning the "kernel-parameters.txt" file in the kernel source.

Last edited by jschiwal; 10-26-2007 at 02:42 PM.
 
Old 10-30-2007, 10:22 AM   #5
lucazorzi
Member
 
Registered: Jul 2006
Location: Italy
Distribution: Ubuntu 11.04, Debian, OS X
Posts: 70

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by jschiwal View Post
I found this howto posted on one the Ubuntu forum.
http://ubuntuforums.org/showthread.php?t=296808
Looks a bit too complicated, it hope there's something easiear to do...
Quote:
Originally Posted by jschiwal View Post
Another option is to have a variable defined in the "kernel " line of the menu.lst stanza. I think I remember that options not recognized are defined in the environment of the INIT program. Scripts started subsequently may have that variable defined in their environment which could allow for conditional execution in scripts at boot time. I'm not 100% certain. I think there is a howto in the www.tldp.org website on grub or lilo that may verify this, but I wasn't able to find this info scanning the "kernel-parameters.txt" file in the kernel source.
How can I set it?
 
Old 10-31-2007, 10:08 AM   #6
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 53
Maybe reading /proc/cmdline from a script and acting accordingly?
 
Old 11-01-2007, 06:22 AM   #7
lucazorzi
Member
 
Registered: Jul 2006
Location: Italy
Distribution: Ubuntu 11.04, Debian, OS X
Posts: 70

Original Poster
Rep: Reputation: 16
Great idea! Thank you!
I'm working on that.
 
Old 11-02-2007, 07:46 AM   #8
lucazorzi
Member
 
Registered: Jul 2006
Location: Italy
Distribution: Ubuntu 11.04, Debian, OS X
Posts: 70

Original Poster
Rep: Reputation: 16
It worked!
I added a new OS in /boot/grub/menu.lst with the 'elisa' parameter, then I put this script in /etc/init.d/ and made a symlink in /etc/rc2.d/ (Ubuntu's default runlevel)
Code:
#!/bin/bash
# This scripts checks /proc/cmdline and looks for the 'elisa' parameter
# If it's found, then it changes KDM's and X's config files to the needed options
# if not, it sets the default settings
#
# Author: Luca Zorzi < luca AT tutto e niente [WITHOUT-SPACES] [DOT] net >
# License: GNU/GPL v2
case "$1" in
  start)
    if [[ `grep elisa /proc/cmdline` != '' ]]
        then
         cd /etc/kde3/
         tar xzf kdm.elisa.tar.gz
         cp /etc/X11/xorg.conf.elisa /etc/X11/xorg.conf
         touch /tmp/elisa
        else
         cd /etc/kde3/
         tar xzf kdm.noelisa.tar.gz
         cp /etc/X11/xorg.conf.elisa /etc/X11/xorg
         touch /tmp/noelisa
        fi
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start}" >&2
    exit 2
    ;;
esac

exit 0
I saved in /etc/X11/ 2 xorg.conf, with 2 different settings, with or without the TV enabled, and also tarred the KDM's config dir with and without the autologin for the elisa-only user.

Hope this helps someone.
 
  


Reply

Tags
kubuntu, mythtv, startup


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I execute two commands on exec of a find? eantoranz Programming 3 08-03-2010 04:51 PM
Shell won't execute commands.... frank320 Red Hat 6 03-17-2006 11:12 AM
C -how do i execute linux commands? ocularbob Programming 7 02-29-2004 01:51 PM
how to execute commands on login k4zau Linux - Software 3 10-12-2003 01:52 PM
Written commands hard to execute Rutnut Linux - Newbie 6 02-22-2001 12:19 AM


All times are GMT -5. The time now is 04:51 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration