[systemd-devel] [script] Eject CD before shutdown

Philip Müller philm at manjaro.org
Thu Sep 13 11:01:07 PDT 2012


Sorry, that was my fault. As suggested it works.
Thx again for your help.

Phil

Am 13.09.2012 18:19, schrieb Lennart Poettering:
> On Thu, 13.09.12 18:04, Philip Müller (philm at manjaro.org) wrote:
>
> [...]
>
>> All operations are timed out in systemd by default. You can turn this
>> off by pasing TimeoutSec=0.
>>
>> However, I'd probably recommend you to define your service a bit
>> differently. Add this to [Unit]:
>>
>>          DefaultDependencies=no
>>          After=shutdown.target
>>          Before=final.target
>>
>> And just use ExecStart= to spawn your code, drop the ExecStop=.
>>
>> And then pull that in from final.target.
>>
>> In case you wonder: the charts at the end of this man page might
>> explain better where a service like that is positioned:
>>
>> http://www.freedesktop.org/software/systemd/man/bootup.html
> [...]
>
>> [Unit]
>> Description=LiveMedia Eject Service
>> Before=unmount.target
>> After=shutdown.target
>> DefaultDependencies=no
>>
>> [Service]
>> Type=oneshot
>> ExecStart=/etc/manjaro/ejectcd
>> StandardInput=tty-force
>> RemainAfterExit=yes
>>
>> [Install]
>> WantedBy=shutdown.target
> Use "Before=final.target" as I suggested, not "Before=unmount.target"
> (there is no unmount.target anyway, only umount.target).
>
> Lennart
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: shutdown-eject-systemd.png
Type: image/png
Size: 13393 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20120913/705e5d03/attachment-0001.png>
-------------- next part --------------
#!/bin/sh

if [ -n "$(blkid -L %MISO_LABEL% |grep -Eo 'sr|cd')" ]; then
    eject -m /dev/disk/by-label/%MISO_LABEL%

    echo -e "\033[31m"
    echo -en "Remove the boot medium, close the tray (if any), "
    echo -en "then press ENTER."
    echo -e "\033[0m"

    read
fi
-------------- next part --------------
[Unit]
Description=LiveMedia Eject Service
Before=final.target
After=shutdown.target
DefaultDependencies=no

[Service]
Type=oneshot
ExecStart=/etc/manjaro/ejectcd
StandardInput=tty-force
RemainAfterExit=yes

[Install]
WantedBy=shutdown.target



More information about the systemd-devel mailing list