Setting variables and notiying the user - How?

Thomas Lange lange at cs.uni-koeln.de
Mon Oct 2 16:36:57 CEST 2023


>>>>> On Wed, 27 Sep 2023 12:21:15 +0200, Thomas Kloepfer <thomas.kloepfer at iwr.uni-heidelberg.de> said:

    > Problem 1: How do I display a message to the User?
Have you tried to redirect the output to the tty/console?
in class/41-warning.sh we do this
out=$(tty)
dialog ...... > $out


    > Problem 2:

    > Scripts in [ config/scripts/<classname>/ ] have access to environment 
    > variables such as HOST, FAI_ROOT, KEYMAP ... . But how can I set up my 
    > own environment variable in one script and later on read this variable 
    > in an other script.
All shell variables you define in class/*.var are available in the
customization scripts.


    > For my task I need to set up the password for the sudo user. I want to 
    > store this generated password in an environment variable. An I want to 
    > read this environment variable later in my script.

    > The documentation of FAI says, that variables that have been set up in 
    > hooks get sourced.

    > So I tried to set up my own hook ( [ 
    > config/hooks/myvar.<classname> ] ) and set a variable. But the variable 
    > I set up (and I exported) was not accessible later.
Not sure if this still works, but try to name your hook
config/hooks/taskname.classname.sh

    > I found a workaround for this task, but I am not happy with it:
    > I tweaked [ config/hooks/setup.DEFAULT.sh ] added my variable this 
    > worked. I could access this variable later in my scripts.
Oh, that's what I just suggested.
Maybe just add a hook
hooks/configure.DEFAULT.sh containing your variable definitions or just
source /tmp/myvars.sh in this hook.
OR name the hook hooks/defvar.DEFAULT.sh


-- 
regards Thomas


More information about the linux-fai mailing list