sysd2v

sysd2v converts systemd service units into sysvinit scripts.

Examples

anacron.service

simple service:

[Unit]
Description=Run anacron jobs
After=time-sync.target
ConditionACPower=true
Documentation=man:anacron man:anacrontab

[Service]
EnvironmentFile=/etc/default/anacron
ExecStart=/usr/sbin/anacron -d -q $ANACRON_ARGS
IgnoreSIGPIPE=false
KillMode=mixed
# Use SIGUSR1 to stop gracefully
KillSignal=SIGUSR1

[Install]
WantedBy=multi-user.target

output:

#!/bin/sh
# Generated by sysd2v v0.3  --  http://www.trek.eu.org/devel/sysd2v
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:       anacron
# Required-Start: $remote_fs
# Required-Stop:  $remote_fs
# Should-Start:   $time
# Should-Stop:    $time
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    Run anacron jobs
### END INIT INFO
set -a
. /etc/default/anacron
set +a

DAEMON=/usr/sbin/anacron
DAEMON_ARGS="-d -q $ANACRON_ARGS"
PIDFILE=/var/run/anacron-sysd2v.pid
START_ARGS="--background --make-pidfile"
STOP_ARGS="--retry=USR1/90/KILL/5"

keyboard-setup.service

oneshot service:

[Unit]
Description=Set the console keyboard layout
DefaultDependencies=no
Before=local-fs-pre.target
Wants=local-fs-pre.target
ConditionPathExists=/bin/setupcon

[Service]
Type=oneshot
ExecStart=/lib/console-setup/keyboard-setup.sh
RemainAfterExit=yes

[Install]
WantedBy=sysinit.target

output:

#!/bin/sh
# Generated by sysd2v v0.2  --  http://www.trek.eu.org/devel/sysd2v
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:       keyboard-setup
# Required-Start:
# Required-Stop:
# Should-Start:   mountkernfs
# Default-Start:  S
# Default-Stop:
# Description:    Set the console keyboard layout
### END INIT INFO
DESC="keyboard-setup"
DAEMON=none
PIDFILE=none

do_start_cmd_override ()
{
  /lib/console-setup/keyboard-setup.sh || return 2
}

do_stop_override () :

do_status_override () :

miniupnpd.service

forking service with pre/post directives:

[Unit]
Description=UPnP Internet Gateway Device Daemon
Documentation=man:miniupnpd(8)
After=network-online.target

[Service]
Type=forking
EnvironmentFile=-/etc/default/miniupnpd
EnvironmentFile=/etc/miniupnpd/miniupnpd.conf
ExecStartPre=/etc/miniupnpd/iptables_init.sh -i $ext_ifname
ExecStartPre=/bin/sh -c "[ \"$MiniUPnPd_ip6tables_enable\" != 1 ] || /etc/miniupnpd/ip6tables_init.sh -i $ext_ifname"
ExecStart=/usr/sbin/miniupnpd -f /etc/miniupnpd/miniupnpd.conf $MiniUPnPd_OTHER_OPTIONS
ExecStopPost=/etc/miniupnpd/iptables_removeall.sh -i $ext_ifname
ExecStopPost=/bin/sh -c "[ \"$MiniUPnPd_ip6tables_enable\" != 1 ] || /etc/miniupnpd/ip6tables_removeall.sh -i $ext_ifname"
PrivateTmp=yes
PIDFile=/run/miniupnpd.pid

[Install]
WantedBy=multi-user.target

output:

#!/bin/sh
# Generated by sysd2v v0.3  --  http://www.trek.eu.org/devel/sysd2v
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:       miniupnpd
# Required-Start: $remote_fs
# Required-Stop:  $remote_fs
# Should-Start:   $network
# Should-Stop:    $network
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    UPnP Internet Gateway Device Daemon
### END INIT INFO
set -a
[ -r /etc/default/miniupnpd ] && . /etc/default/miniupnpd
. /etc/miniupnpd/miniupnpd.conf
set +a

DAEMON=/usr/sbin/miniupnpd
DAEMON_ARGS="-f /etc/miniupnpd/miniupnpd.conf $MiniUPnPd_OTHER_OPTIONS"
PIDFILE=/run/miniupnpd.pid

do_start_cmd_override ()
{
  /etc/miniupnpd/iptables_init.sh -i $ext_ifname || return 2
  /bin/sh -c "[ \"$MiniUPnPd_ip6tables_enable\" != 1 ] || /etc/miniupnpd/ip6tables_init.sh -i $ext_ifname" || return 2
  do_start_cmd || return $?
}

do_stop_cmd_override ()
{
  do_stop_cmd || return $?
  /etc/miniupnpd/iptables_removeall.sh -i $ext_ifname || return 2
  /bin/sh -c "[ \"$MiniUPnPd_ip6tables_enable\" != 1 ] || /etc/miniupnpd/ip6tables_removeall.sh -i $ext_ifname" || return 2
}

boinc-client.service

simple service with priority and user directives:

[Unit]
Description=Berkeley Open Infrastructure Network Computing Client
Documentation=man:boinc(1)
After=network-online.target

[Service]
ProtectHome=true
Type=simple
Nice=10
User=boinc
WorkingDirectory=/var/lib/boinc
ExecStart=/usr/bin/boinc
ExecStop=/usr/bin/boinccmd --quit
ExecReload=/usr/bin/boinccmd --read_cc_config
ExecStopPost=/bin/rm -f lockfile
IOSchedulingClass=idle

[Install]
WantedBy=multi-user.target

output:

#!/bin/sh
# Generated by sysd2v v0.2  --  http://www.trek.eu.org/devel/sysd2v
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:       boinc-client
# Required-Start: $remote_fs
# Required-Stop:  $remote_fs
# Should-Start:   $network
# Should-Stop:    $network
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    Berkeley Open Infrastructure Network Computing Client
### END INIT INFO
DESC="boinc-client"
DAEMON=/usr/bin/boinc
PIDFILE=/run/boinc-client-sysd2v.pid
START_ARGS="--user boinc --chuid boinc --iosched idle --nicelevel 10 --chdir /var/lib/boinc --background --make-pidfile"
STOP_ARGS="--user boinc"

do_stop_cmd_override ()
{
  cd /var/lib/boinc || return 2
  ionice -c idle nice -n 10 runuser -u boinc -- /usr/bin/boinccmd --quit || return 2
  do_stop_cmd
  ionice -c idle nice -n 10 runuser -u boinc -- /bin/rm -f lockfile || return 2
}

do_reload_cmd_override ()
{
  cd /var/lib/boinc || return 2
  ionice -c idle nice -n 10 runuser -u boinc -- /usr/bin/boinccmd --read_cc_config || return 2
}

do_reload ()
{
  log_daemon_msg "Reloading $DESC configuration files" "$NAME"
  MAINPID=$(cat $PIDFILE)
  do_reload_cmd_override
  log_end_msg $?
}
Last update: 2019-11-27
3k
www.000webhost.com