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

Philip Müller philm at manjaro.org
Sat Sep 15 01:24:11 PDT 2012


Yes it is the root-disk. I managed it by overwritting all messages with 
attached script.
No issues at all. It displays my message and reacts as wanted. No 
hangups etc.

Am 14.09.2012 19:20, schrieb Lennart Poettering:
> On Fri, 14.09.12 00:14, Philip Müller (philm at manjaro.org) wrote:
>
>> So, seems to work. I attached my current scripts and two picutes
>> with error messages.
>> Also I added now *read -t 30* and fixed hanging by pressing the
>> Enter-key. Is there any way
>> to hide those error messages (seems the system still tries to read
>> from CD after it got ejected),
>> so my message gets displayed clean? Maybe there is a way to get it cleaner.
> You are ejecting the root disk? Well, that's difficult to get right.
>
> You could transition back into an initrd of some kind and print the
> message there:
>
> http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface
>
> Or you could print this message from a script in
> /usr/lib/systemd/system-shutdown and hope for the best. (And turn off
> console printk output via /proc/sys/kernel/printk first). Since the
> systemd-shutdown binary (which runs at the very end) locks itself into
> memory you might be able to get away with that. That said, the initrd
> thing is the only fix that would really get this right.
>
> Lennart
>

-------------- next part --------------
#!/bin/sh

if [ -n "$(blkid -L %MISO_LABEL% |grep -Eo 'sr|cd|loop')" ]; then
    cdrecord -eject

    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : "
    echo -e " : \033[00;32m          _     _              _                   \033[0m"
    echo -e " : \033[00;32m         | |   | |            (_)                  \033[0m"
    echo -e " : \033[00;32m         | | _ | | ____ ____   _  ____  ____ ___   \033[0m"
    echo -e " : \033[00;32m         | || || |/ _  |  _ \ | |/ _  |/ ___) _ \  \033[0m"
    echo -e " : \033[00;32m         | || || ( ( | | | | || ( ( | | |  | |_| | \033[0m"
    echo -e " : \033[00;32m         |_||_||_|\_||_|_| |_|| |\_||_|_|   \___/  \033[0m"
    echo -e " : \033[00;32m                            (__/                   \033[0m"
    echo -e " : "
    echo -e " : "
    echo -e " : \033[33m Remove the boot medium, close the tray (if any), then press ENTER. \033[0m"
    echo -e " : "
    echo -e " : "
    echo -e ".:."

    read -t 120
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
StandardOutput=inherit
StandardError=inherit

[Install]
WantedBy=shutdown.target



More information about the systemd-devel mailing list