Adrian Moya's picture

Hi guys, I'm giving the final touchs to an appliance, and copied a script to /usr/lib/inithooks/firstboot.d/myscript

myscript reads information from the user to finish configuring the system. 

The problem is that when the systems boots the first time, the scripts get executed, but when it ask the first question, it doesn't receive any input. So the appliance hangs there. I'm not getting input from the keyboard. The script works normally if I execute manually in the console. Any ideas?

Forum: 
Adrian Moya's picture

I've just confirmed that on firstboot of an appliance in virtualbox, at the time those scripts are being executed, there is no keyboard input! 

This affects those using virtualbox as hypervisor. Let me check with vmware if this happens...

Liraz Siri's picture

You should have keyboard input in firstboot. We used that to allow users to opt out of installing security updates on the first boot.

However you should keep in mind there isn't always a user behind the console ready to answer your questions. So for the script that installs security updates we implemented a 5 second timeout. If you don't answer by then it defaults to installing them.

cat /usr/lib/inithooks/firstboot.d/95cronapt

...
# allow cancellation (ask again if not blank/Y/y/N/n)
while true; do
    echo -e "\n================================================================="
    TEXT="First boot detected: Install security updates? (timeout: 5) [Y/n] "
    read -t 5 -p "$TEXT" VAL || true
    [ $VAL ] || VAL=Y
    case "$VAL" in
        y|Y) echo -e "\nAttempting to install security updates" && break ;;
        n|N) echo -e "\nNot installing security updates" && exit 3 ;;
    esac
done
When there is no "reasonable" default what we've done instead is either created a di-live installer hook or added a configuration script to /usr/local/bin...

Add new comment