Como faço para converter um job upstart em um serviço systemd?

1

Eu tenho o seguinte trabalho inicial:

# hwclock - adjust system clock and timezone
#
# The hwclock task adjusts the system clock when the hardware clock is
# set to localtime (e.g. when dual-booting with Windows), and also
# ensures that the system timezone is set so that timestamps are written
# to FAT devices.

description     "adjust system clock and timezone"

start on starting mountall

task

script
    exec hwclock --systz --utc --noadjfile
end script

Gostaria de mudar isso para o serviço systemd.

Como o start on starting mountall deve ser implementado no systemd?

Eu criei o serviço systemd como abaixo, mas não sei como fazer start on starting mountall .

[Unit]
Description=hwclock
After=
Before=

[Service]
ExecStart=/sbin/hwclock --systz --utc --noadjfile
    
por DonBit 22.01.2018 / 06:09

1 resposta

1

Você precisará destas linhas:

Requires=
After=

Como afirmado aqui:

Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.

After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.

A estrutura deve ser:

[Unit]
Description=hwclock
Requires= # mountall most happen
After= # mountall should have started before hwclock run

[Service]
Type=oneshort
ExecStart=/sbin/hwclock --systz --utc --noadjfile

De aqui :

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Upstart stanza | systemd unit file directive | systemd unit file section
               |                             |
-------------------------------------------------------------------------
start on       |    Wants, Requires, Before, |
               |    After                    |  Unit 
--------------------------------------------------------------------------

Nota: Isto é para um sistema Ubuntu, mas deve ser semelhante. Consulte: link também.

    
por 22.01.2018 / 07:31

Tags