I've been reading for the last couple hours about Upstart, .xinitrc, .xsessions, rc.local, /etc/init.d/, /etc/xdg/autostart, @reboot in crontab and so many other things that I'm totally confused!
Here is my bash script. It should start/run after the desktop environment is started and it should continue to run at all times until logout/shutdown. It should start again on reboot. Any time the DE is running, it should run.
#!/bin/bash
while true; do
if [[ -s ~/.updateNotification.txt ]]; then
read MSG < ~/.updateNotification.txt
kdialog --title 'The software has been updated' --msgbox "$MSG"
cat /dev/null > ~/.updateNotification.txt
fi
sleep 3600
done
exit 0
I know zero about using Upstart, but I understand that Upstart is one way to handle this. I'll consider other approaches but most of the things I've been reading about are too complex for me. Furthermore, I can't figure out which approach will meet my requirements (which I'll detail below).
There are two steps in my question:
How to automatically start the script above, as described above.
How to "install" that Upstart task via a bash script (i.e., my "installer").
I assume (or hope) that step 2 is almost trivial once I understand step 1.
I have to support all flavors of Ubuntu desktops. Therefore, the kdialog call above will be replaced. I'm considering easybashgui for this. (Or I could use zenity on gnome DE's.)
My requirements are:
The setup process (installation) must be done via a bash script. I cannot use the GUI method described in the Ubuntu doc AddingProgramToSessionStartup, for example. I must be able to script/automate the setup (installing) process using bash. Currently, it is as simple as having the bash installer script copy the above script into /home/$USER/.kde/Autostart/
The setup process must be universal across Ubuntu derivatives including Unity and KDE and gnome desktops. The same setup script (installer) should run on Linux Mint, Kubuntu, Xbuntu (basically any flavor of Ubuntu and major derivatives such as Linux Mint). For example, we cannot continue to put a script file in /home/$USER/.kde/Autostart/ because that exists only on KDE.
The above script should work for each of the limited flavors we use. Hence our interest in using easybashgui instead of kdialog or zenity. See below.
The installed monitoring script should only be started after the desktop is started since it will display a GUI message to the user if the update is found.
The monitoring script (above) should run without root privileges, of course. But the installer (bash script) can be run as root.
I'm not a real developer or a sysadmin. This is a part time volunteer thing for me, so it needs to be easy/simple. I can write bash scripts and I can program a little, but I know nothing about Upstart or systemd, for example. And, unfortunately, my job doesn't give me time to become an expert on init systems or much of anything else related to development and sysadmin. So I have to stick with simple solutions.
The easybashgui version of the script might look like this:
#!/bin/bash
source easybashgui
while true; do
if [[ -s ~/.updateNotification.txt ]]; then
read MSG < ~/.updateNotification.txt
message "$MSG"
cat /dev/null > ~/.updateNotification.txt
fi
sleep 3600
done
exit 0