1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#!/bin/sh
set -e
if [ "$1" = "sysvinit" ] && [ -d /run/systemd/system ]; then
if [ "$AUTOPKGTEST_REBOOT_MARK" = "sysvinit" ]; then
echo "Still running under systemd, but sysvinit requested"
exit 1
fi
apt-get -y install sysvinit-core
/tmp/autopkgtest-reboot "sysvinit"
fi
mkdir -p /etc/systemd/system
if [ -d /run/systemd/system ]; then
cat <<-EOF >/etc/systemd/system/dep8-sd-only.service
[Unit]
Description=Dummy DEP-8 systemd-only service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/sh -c "echo running > /tmp/dep8-sd-only.status"
ExecStop=/bin/rm -f /tmp/dep8-sd-only.status
[Install]
WantedBy=multi-user.target
EOF
fi
cat <<-EOF >/etc/systemd/system/dep8-sd-sysv.service
[Unit]
Description=Dummy DEP-8 systemd + sysv service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/sh -c "echo running > /tmp/dep8-sd-sysv.status"
ExecStop=/bin/rm -f /tmp/dep8-sd-sysv.status
[Install]
WantedBy=multi-user.target
EOF
cat <<-EOF > /etc/init.d/dep8-sd-sysv
#!/bin/sh
# 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: dep8-sd-sysv
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d. This example start a
# single forking daemon capable of writing a pid
# file. To get other behavoirs, implemend
# do_start(), do_stop() or other functions to
# override the defaults in /lib/init/init-d-script.
### END INIT INFO
DESC="Dummy DEP-8 systemd + sysv service"
DAEMON="none"
do_start_cmd_override() {
echo "running" > /tmp/dep8-sd-sysv.status
}
do_stop_cmd_override() {
rm -f /tmp/dep8-sd-sysv.status
}
do_status() {
grep -q "running" /tmp/dep8-sd-sysv.status 2>/dev/null
exit \$?
}
EOF
chmod +x /etc/init.d/dep8-sd-sysv
cat <<-EOF > /etc/init.d/dep8-sysv-only
#!/bin/sh
# 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: dep8-sysv-only
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d. This example start a
# single forking daemon capable of writing a pid
# file. To get other behavoirs, implemend
# do_start(), do_stop() or other functions to
# override the defaults in /lib/init/init-d-script.
### END INIT INFO
DESC="Dummy DEP-8 sysv-only service"
DAEMON="none"
do_start_cmd_override() {
echo "running" > /tmp/dep8-sysv-only.status
}
do_stop_cmd_override() {
rm -f /tmp/dep8-sysv-only.status
}
do_status() {
grep -q "running" /tmp/dep8-sysv-only.status 2>/dev/null
exit \$?
}
EOF
chmod +x /etc/init.d/dep8-sysv-only
|