How to make a menu on first boot?

I have a disk image that I would like to make a menu on the very first
boot, not every time the computer boots, to copy a few files. The files
are a few configuration files for a lxde build I am working on, the
system gets setup one way or the other.

I used the scripts below as an example to modify, and I know that they
work because I can run the scripts within the build and they work
perfectly. It is when I try to get the very same script to work before
x starts by inserting it into the “custom script” section in the studio
I run into problems.
http://tinyurl.com/oh255dg

I asked the same question at the Suse Studio help boards, and after
waiting a week the only answer I got was to add the script to
/etc/init.d/before.local or /etc/init.d/after.local, and even if this
would work (and it did not) I do not want the script to run every time
the build boots.

If anyone here has any clue how to do this I would be very appreciative,
and please keep in mind while I have made great strides in learning
linux, I am still rather new to linux and have a lot to learn.


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

Into what problems, specifically, are you running? I would not guess that
the after.local scripts are the right place to go, but the place within
SUSE Studio to place custom commands sounds correct per an old memory.
Which build and version (SLE, openSUSE, etc., and 11 SP3, 12.3, 13.1,
etc.) are you using?


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

I am using 13.1, and the problem with the menu is that it does not
display a menu at all. Like I said I know the scripts work, I can add
them to the build as a overlay and they work when running testdrive
after x starts in the terminal. It is when I copy the same working
script code into “custom scripts” section that nothing happens.


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

Ok so I should have provided a little better examples of my script, but
I didnt have any and had to recreate them

This works as menu.sh:
#!/bin/bash
echo “Select default window manager (1)Compiz (2)Openbox:”
read n
case $n in

  1. sudo rm “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo cp “/home/tux/.config/lxsession/LXDE/desktop.comp”
    “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo rm “/usr/bin/lxcc”
    sudo cp “/usr/bin/lxcc-compiz” “/usr/bin/lxcc”
    ;;
  2. sudo rm “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo cp “/home/tux/.config/lxsession/LXDE/desktop.box”
    “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo rm “/usr/bin/lxcc”
    sudo cp “/usr/bin/lxcc-openbox” “/usr/bin/lxcc”
    ;;
    *) invalid option;;
    esac

This does not work as “Run script whenever the appliance boots” section
in custom scripts:
#!/bin/bash

This script is executed whenever your appliance boots. Here you can

add

commands to be executed before the system enters the first runlevel.

This

could include loading kernel modules, starting daemons that aren’t

managed

by init files, asking questions at the console, etc.

The ‘kiwi_type’ variable will contain the format of the appliance (oem

=

disk image, vmx = VMware, iso = CD/DVD, xen = Xen).

read in some variables

… /studio/profile

if [ -f /etc/init.d/suse_studio_firstboot ]
then

Put commands to be run on the first boot of your appliance here

echo “Running SUSE Studio first boot script…”

#!/bin/bash
echo “Select default window manager (1)Compiz (2)Openbox:”
read n
case $n in

  1. sudo rm “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo cp “/home/tux/.config/lxsession/LXDE/desktop.comp”
    “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo rm “/usr/bin/lxcc”
    sudo cp “/usr/bin/lxcc-compiz” “/usr/bin/lxcc”
    ;;
  2. sudo rm “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo cp “/home/tux/.config/lxsession/LXDE/desktop.box”
    “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo rm “/usr/bin/lxcc”
    sudo cp “/usr/bin/lxcc-openbox” “/usr/bin/lxcc”
    ;;
    *) invalid option;;
    esac

fi

If you press up to turn off plymouth the only error it gives is “Failed
to start Execute user-provided boot script, if it exists.”

I have tried every example in the link I provided above with varying
degrees of failure.


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

On 2014-06-26 14:46, thefrayedend wrote:[color=blue]

If anyone here has any clue how to do this I would be very appreciative,
and please keep in mind while I have made great strides in learning
linux, I am still rather new to linux and have a lot to learn.[/color]

I’m not familiar with susestudio. But I know that yast has a package
that only runs once after install, to complete the installation. I have
not examined how it works, but I think that an empty file is created on
the root directory to flag the script that the initial config job was
not done, or that it was.

One way would be:

Install a certain package, that includes a job to run on every boot,
and a flag file on root. When the job succeeds, it removes the flag
file, and possibly uninstalls the package; otherwise, the boot script,
not seeing the flag file, would not bail out.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

So I am not sure if this is exactly what you meant, but I think so.

I created a blank file called /first.boot

and then modified my script to this:
#!/bin/bash

This script is executed whenever your appliance boots. Here you can

add

commands to be executed before the system enters the first runlevel.

This

could include loading kernel modules, starting daemons that aren’t

managed

by init files, asking questions at the console, etc.

The ‘kiwi_type’ variable will contain the format of the appliance (oem

=

disk image, vmx = VMware, iso = CD/DVD, xen = Xen).

read in some variables

… /studio/profile

if [ -f /first.boot ];
then
echo “Select default window manager (1)Compiz (2)Openbox:”
read n
case $n in

  1. sudo rm “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo cp “/home/tux/.config/lxsession/LXDE/desktop.comp”
    “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo rm “/usr/bin/lxcc”
    sudo cp “/usr/bin/lxcc-compiz” “/usr/bin/lxcc”
    ;;
  2. sudo rm “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo cp “/home/tux/.config/lxsession/LXDE/desktop.box”
    “/home/tux/.config/lxsession/LXDE/desktop.conf”
    sudo rm “/usr/bin/lxcc”
    sudo cp “/usr/bin/lxcc-openbox” “/usr/bin/lxcc”
    ;;
    *) invalid option;;
    esac

else
echo “File does not exists”
fi

I figured if that worked I could just have the script delete the
first.boot file, but I still get the same error as I always have. Thank
you though, I believe that is a step in the right direction!


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

On 2014-06-27 02:56, thefrayedend wrote:
[color=blue]

if [ -f /first.boot ];
then
echo “Select default window manager (1)Compiz (2)Openbox:”
read n[/color]

You need a terminal… it is not that easy.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Ok, your going to have to dumb that one down for me, I thought
everything that ran before x starts pretty much ran in the terminal. So
how do I invoke the terminal before x starts?

Thanks again.


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

On 2014-06-27 13:36, thefrayedend wrote:[color=blue]

Ok, your going to have to dumb that one down for me, I thought
everything that ran before x starts pretty much ran in the terminal. So
how do I invoke the terminal before x starts?[/color]

You only have a usable terminal after you log in.

You can redirect a program running as root to print messages on any
terminal it wishes, but in that case you have to stop the logon program
that is usually running on each, so that it does not interfere. That is
what is basically done with tty10, it is used for important log messages
(the warning log, more or less).

But you also need keyboard input, which is a different issue.

I can not give you specific details on how to do it, because I have
never done such a thing myself. However, I did mention before that YaST
has a module that runs automatically on the first boot after install,
and it does it in graphical model. I suggest you locate the module, then
dig out the source code and find out how exactly they do it.

The main installation system also has a graphical mode and starts some
text consoles. One of the install options is to run it in text mode, and
of course it allows entering things. It probably replaces or hooks on init.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Im not trying to be rude, because you have without a doubt pointed me in
the right direction, however if I knew the first thing about source code
I probably wouldnt be in the forums asking how to do anything. I can
not believe I did not see the if then statement or that it was missing
the flag file for the custom script section in Suse Studio.

I have found how to start the Yast first boot module that you speak of,
and it is supose to be able to run scripts once finished, so far I have
not had any luck. I am still playing with this,so maybe it will work.

If I can not figure out how to do what I want in the next few days, I
will probably ask a very similar question in a different/more populated
area of the forums, something along the lines of “how to run a script
before x starts with keyboard input?” I know how to get the script to
run only once, and we know its not a problem with the script, so my
question is no longer strictly Suse Studio related.

But I do want to thank you for your help, and hopefully someone else
will chime in before I have to ask elsewhere . The if then statement
with the flag file is going to be key in whatever direction I take I
believe.


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

An advice not directly related. But when you post computer text (like
your scripts above), please do so between CODE tags (the # button in the
tool bar ofthe post editor). It will preserve the layout you have,
without doubt, added to your script to make it understandable. And
without it, it is, well, unreadable. At least I do not even try to
uncypher such texts.


Henk van Velden

hcvv’s Profile: http://forums.opensuse.org/member.php?userid=180
View this thread: http://forums.opensuse.org/showthread.php?t=499104

I was wondering how you done the code tags, thank you.

And an update, I took a different approach. I went ahead and made
Openbox the default, and used Xdialog to build a nice gui tool to
switch. Not exactly what I wanted, but it looks nice, it is easy to
switch, and it works well enough.

Thank you everyone for your help!


thefrayedend

thefrayedend’s Profile: http://forums.opensuse.org/member.php?userid=84545
View this thread: http://forums.opensuse.org/showthread.php?t=499104

On 2014-07-01 04:46, thefrayedend wrote:[color=blue]

I was wondering how you done the code tags, thank you.[/color]

Use the ‘#’ button in the forum editor).
See photo

[color=blue]

And an update, I took a different approach. I went ahead and made
Openbox the default, and used Xdialog to build a nice gui tool to
switch. Not exactly what I wanted, but it looks nice, it is easy to
switch, and it works well enough.[/color]

Good :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)