Re: echo and read shell script functions in post install script doesn't display messages


Alexander Kanavin
 

The postinst scriptlets are script fragments and not standalone scripts. Putting an interpreter to their first line will not work. Also, they are not running on an interactive console, but by a helper executor, so they have to be entirely automated.

What is the problem that you would like to solve?

Alex


On Tue, 14 Dec 2021 at 13:01, <sanjaycvr35412@...> wrote:

Hi All,

 

I am trying to execute a script in “pkg_postinst_ontarget_${PN}” to configure the static IP address of the embedded board. The script executes at first boot, but it doesn’t display echo or read messages. These messages are required to improve user experience with the setup process.

 

Script is as below:

pkg_postinst_ontarget_${PN} () {

    #!/bin/sh -e

    # This will run on first boot

    echo "Starting setup script..."

 

    read -p "Enter the IP address: " ipAddress

    read -p "Enter the netmask: " netmask

    read -p "Enter network gateway: " gateway

 

    cat >> /etc/network/interfaces << EOF

 

iface eth0 inet static

    address $ipAddress

    netmask $netmask

    gateway $gateway

EOF

}

 

Please help me to fix the problem in displaying echo and read messages to improve user experience with the setup process.

 

Thanks,

Sanjay Kumar

 




Join yocto@lists.yoctoproject.org to automatically receive all group messages.