Contextualization run every time boot

Hi All!
My VM created from contextualization Image (Centos 7)
I noticed that dropped my keys which was manually adding after first start my VM.
I think that scripts of contextualization run every time boot (after reboot) and recreated my authorized_keys file.
Is it normal action for contextualization and how it to avoid (Is it have way to disable automatically autostart vmcontext after first boot VM)?

Thank you!
telecast

As far as I know you either need to use contextualization or not. I don’t think you can mix and match. So you’ll need to add the keys via Sunstone, or disable Add SSH contextualization in the Context settings for that VM.

Someone can correct me if I’m wrong

1 Like

you can add or edit existing scripts in /etc/one.context.d/ to achieve what you want

I want to execute the startup scripts to be executed only the first time VM boot. I dont want the init script to be executed everytime VM boot (reboot). How can I achieve this?

1 Like

One of the possible way is to create some file at certain location during first boot and check its existence before execution of startup scripts.

2 Likes

I tried your suggestion. The files is getting created on boot. However for the second boot time, looks like the files is not present. It gets deleted upon boot. Is there any specific folder where the files will be persistent(permanent) across boot.

where you try to write? I think that for ex. /root/ will be fine

I tried creating a file in /root/, even after that its not working. This is my startup script in context:

#!/bin/bash
FILE=\"/root/x.txt\"
if [ -f \"$FILE\" ];
then
   echo \"File $FILE exist.\"
else
   echo \"File $FILE does not exist\" >&2
   sudo echo \"some file content\" > /root/x.txt
   sudo apt-get install cmatrix
fi

Is anything wrong with this script?

Hi. I have tried to create a file in /home/ directory. It works. Is this the right way?

there is no defined way, it’s up to you.

Thank you feldsam:slight_smile: