First, I’m still pretty new to using linux in general and to bash scripting, so apologies for any obvious mistakes I’ve made here.
I have installed
kdocker and I use it to keep an instance of firefox running in the system tray. There are a couple of reasons I do this, but it’s mostly a convenient way to avoid having to re-log into bitwarden every time I close the browser without having to set my vault timeout to “never.” I have actually set kdocker and firefox to autostart like this. However, whenever I reboot the system, kdocker causes it to hang and I have to wait for an extra 2 minutes for a stop job to run.
I wanted to avoid having to manually exit out of kdocker before I do a reboot, so I wrote this very basic
kill_kdocker.sh bash script.
and I’ve placed it in /usr/local/sbin
After reading up a bit about systemd services, I then attempted to create the following “killkdocker.service” systemd service that would run the script before a reboot or shutdown occurs.
Description=Kill kdocker before reboot
I can enable the service with
systemctl enable killkdocker.service, but when I run
systemctl start killkdocker.service, the
killall kdocker command in my script runs immediately instead of waiting until a reboot starts. So kdocker is immediately terminated.
When I run
systemctl status killkdocker.service I get the following output:
● kdockerkill.service - Kill kdocker before reboot
Loaded: loaded (/etc/systemd/system/kdockerkill.service; enabled; vendor preset: disabled)
Active: inactive (dead)
I am sure there is something obvious that I am missing here, but I can’t figure it out. I’m not sure if the issue is with my systemd service file, or with my simple bash script. Like I said, this is pretty new for me. I have also tried using “poweroff.target,” but I get the same result.
How can I set this up so my kill kdocker script only runs before a reboot or shutdown?
If anyone can shed some light on the probably straight forward mistake I’m making, it would be greatly appreciated!