Reputation: 41
I have been creating an install script that is going to be used for installing proxy and Dev configs on Ubuntu Xenial Desktop only.
I have 2 scripts that are all interactive and require input from the user, my challenge is each script needs a reboot after it is installed and then needs to automatically open another console and become interactive with the next script.
here is a diagram of the flow:
script_1.sh > reboot > script_2.sh
V V
usr input usr input
required required
I have all the scripts completed and working as they should my challenge is trying to configure Systemd so after the reboot it will open a console and begin the next script.
I am new to this but I built something using rc.local then read the magnitude of posts saying it's not good practice to use it for these sorts of installations, I started using upstart then I found out that it is deprecated and I am required to use Systemd.
Obviously, I would have these scripts built and just copy them in and delete them out when done during the process, here is an attempt earlier any help on how to do this would be fantastic as I have lost 2 days this.
previous atempt:
description "install script"
start on local-filesystems or runlevel [2345]
stop on runlevel [!2345]
pre-start script
# prepare environment
touch /var/logs/DID.log
exec echo DID installation started `date` >> /var/log/DID.log
end script
script
# do some stuff
exec ~/Documents/script_2.sh
console output
end script
post-stop script
# clean up
exec echo DID stage 2 installation finished `date` >> /var/log/DID.log
end script
Cheers in advance for any help you can provide.
Upvotes: 1
Views: 7545
Reputation: 406
You can create user systemd scripts that might help you out (https://wiki.archlinux.org/index.php/Systemd/User).
Here is a brief example of how you can start a script in a terminal from systemd (not on Ubuntu at the moment so not sure this will work with the paths) goes in your systemd user folder, probably /etc/systemd/user/:
[Unit]
Description=Start Script in terminal
[Service]
ExecStart=/usr/bin/xterm -hold -e /path/to/your/script.sh
[Install]
WantedBy=graphical.target
This will run for me on my system (Arch) with systemctl --user start servicename.service
The trick will be getting it to start once you have a full graphical environment up (with the script I have given if you ran systemctl --user enable servicename.service
it would almost certainly start before your window manager, since I am not in Ubuntu I can't test). This might help (last response): https://superuser.com/questions/759759/writing-a-service-that-depends-on-xorg . They are an Ubuntu user that got a systemd service to run a graphical program after login.
If you can figure the start timing out you can create the service file, create/enable it at the end of your first script and then disable/delete it at the end of your second.
Upvotes: 3