Hello.
Context :
Leap 15.2 with KDE
A main program call some sub-programs in sequence up to the last script.
The main program is started in terminal from runlevel 5 from an app desktop icon
If a sub-program finish without error, it is mark as done and will be not re-run.
If a sub-program finish with error, the main process stop.
Re-running the main process lead to start with the first sub-program not marked as done.
Every things run perfectly (with and without error) but not for step 18
Because the application deal with some system files in /etc, /usr and drivers… the main program is started with elevated privileges.
#
# # ensure running as root
if "$(id -u)" != "0" ]; then
exec sudo -i "$0" "$@"
fi
#
Context of step 18 :
The program of ‘step 18’ start in run level 5, do a first task, reboot in runlevel 3
multiple times. Then for the last step reboot in runlevel 5.
To assume successive reboot, during the first task and before the next reboot command, a folder accessible by the user is created.
A bootstrap is copied in that folder, and user’s .bashrc is modified to call the bootstrap.
All steps up to the last with reboot in runlevel 3 works perfectly.
At each successive login, after user logon, the root password is aked ( because of exec sudo -i “$0” "$@"
at the beginning of the main program ) and the program continue.
What is expected at the end of ‘step 18’ :
When all steps are done, grub is modified to run in level 5 by removing ‘init 3’.
Then grub is updated (“grub2-mkconfig -o /boot/grub2/grub.cfg”)
Then a reboot command is done.
Then after login, the main program is automatically started in a console and by the mechanism in place the step 19 is called.
Problem of step 18 :
After login after a reboot, if we are in run level 3, the bootstrap can directly call the main program ( which ask for the root password ( because of exec ***sudo -i “$0” “$@” ***at the beginning of the main program )
But if we are in run level 5, the bootstrap must open a terminal which will start the main program which will ask for the root password and then continue.
During my tries I get when ‘step_19’ is expected:
- The main program does not start ( the bootstarp is not called)
- The main program start, but no terminal appear ( the bootstrap open a terminal but the main program is not called).
- The main program start in terminal but I cannot type the password.
Any help is welcome.
PS :
Skeleton of main program :
https://paste.opensuse.org/76289304
Skeleton of ‘step_18’ program :
https://paste.opensuse.org/62773284