This file is indexed.

/usr/bin/systemd2init is in dh-systemd 1.29ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/sh
# vim:noet:sw=4:ts=4
#    systemd2init - convert a systemd service file into init shell script
#    Copyright (C) 2014 Ondřej Surý <ondrej@sury.org>
#                       Lukáš Zapletal <lzap+git@redhat.com>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

lsconf() {
    RET=
	aug_path="/files/lib/systemd/system//${SYSTEMD_SERVICE}${1}"
	[ -f "$SYSTEMD_SERVICE" ] && aug_path="/files$(pwd)//${SYSTEMD_SERVICE}${1}"
	augtool -r "$WORKINGDIR" -t "Systemd incl $(pwd)/$SYSTEMD_SERVICE" ls "$aug_path"
}

getconf() {
    RET=
	aug_path="/files/lib/systemd/system/${SYSTEMD_SERVICE}${1}"
	[ -f "$SYSTEMD_SERVICE" ] && aug_path="/files$(pwd)/${SYSTEMD_SERVICE}${1}"
	augtool -r "$WORKINGDIR" -t "Systemd incl $(pwd)/$SYSTEMD_SERVICE" get "$aug_path" | \
		sed -e "s;^${aug_path}[[:space:]]*\((none)\|(o)\|= \)[[:space:]]*;;"
}

getcommand() {
    echo "$(getconf $1/command)"
}

getvalue() {
    echo "$(getconf $1/value)"
}

getarg() {
    echo "$(getconf $1/arguments/$2)"
}

getargs() {
    RET=
    arg=0
    while arg=$(($arg+1)); do
	V=$(getarg $1 $arg)
	if [ -n "$V" ]; then
	    RET=" $V"
	else
	    break
	fi
    done
    [ -n "$RET" ] && echo $RET
}

getenvironment() {
    RET="$(lsconf $1 | sed -e 's/ = /=/g')"
    [ -n "$RET" ] && echo $RET
}

if [ -z "$1" ]; then
    echo "usage: $0 <name>"
    exit 1
fi

if ! [ -x /usr/bin/augtool ]; then
    echo "augtool not found, please install augeas-tools"
    exit 1
fi

NAME=$1

SYSTEMD_SERVICE="${NAME}.service"

if [ -f /etc/redhat-release ]; then
	WORKINGDIR="$(pwd)"
	SKELETON=/usr/share/dh-systemd/skeleton.redhat
	OUTPUT=$WORKINGDIR/${NAME}.init
	DEFAULT_PIDFILE="/var/run/\$NAME.pid"
else
	WORKINGDIR="$(pwd)/debian"
	SKELETON=$WORKINGDIR/${NAME}.init.skeleton
	if [ ! -f $SKELETON ]; then
		SKELETON=/usr/share/dh-systemd/skeleton.debian
	fi
	OUTPUT=$WORKINGDIR/${NAME}.init
	DEFAULT_PIDFILE="/run/\$NAME.pid"
fi

DESC="$(getvalue /Unit/Description)"
DAEMON="$(getcommand /Service/ExecStart)"
[ -z "$DAEMON" ] && DAEMON="/usr/sbin/\$NAME"
DAEMON_ARGS="$(getargs /Service/ExecStart)"
DAEMONIZE="$(getvalue /Service/X-Debian-Daemonize)"
[ -n "$DAEMONIZE" ] && DAEMON_ARGS="$DAEMONIZE $DAEMON_ARGS"
PIDFILE="$(getvalue /Service/PidFile)"
[ -z "$PIDFILE" ] && PIDFILE=$DEFAULT_PIDFILE
ENVIRONMENT="$(getenvironment /Service/Environment)"
ENVIRONMENTFILE="$(getvalue /Service/EnvironmentFile)"
[ -z "$ENVIRONMENTFILE" ] && ENVIRONMENTFILE="/etc/default/\$NAME"
RELOAD_SIGNAL="-1"
CASE_RESTART="restart"
CASE_RELOAD="reload|force-reload"
USAGE="{start|stop|restart|reload|force-reload}"

RELOAD_COMMAND="$(getcommand /Service/ExecReload)"
case "$RELOAD_COMMAND" in
    kill|/bin/kill)
	CUSTOM_RELOAD=false
	RELOAD_SIGNAL="$(getarg /Service/ExecReload 1)"
	;;
    "")
	CASE_RESTART="restart|force-reload"
	CASE_RELOAD="not-implemented"
	USAGE="{start|stop|status|restart|force-reload}"
    ;;
    *)
	CUSTOM_RELOAD=true
	RELOAD_ARGS="$(getargs /Service/ExecReload)"
	;;
esac

CUSTOM_STOP=false
STOP_COMMAND="$(getcommand /Service/ExecStop)"
case "$STOP_COMMAND" in
    "") ;;
    *)
	CUSTOM_STOP=true
	STOP_ARGS="$(getargs /Service/ExecStop)"
	;;
esac

STARTPRE="$(getcommand /Service/ExecStartPre)$(getargs /Service/ExecStartPre)"
STARTPOST="$(getcommand /Service/ExecStartPost)$(getargs /Service/ExecStartPost)"
STOPPRE="$(getcommand /Service/ExecStopPre)$(getargs /Service/ExecStopPre)"
STOPPOST="$(getcommand /Service/ExecStopPost)$(getargs /Service/ExecStopPost)"

sed -e "s^#NAME#^$NAME^g;" \
    -e "s^#DESC#^$DESC^g;" \
    -e "s^#DAEMON#^$DAEMON^g;" \
    -e "s^#DAEMON_ARGS#^$DAEMON_ARGS^g;" \
    -e "s^#PIDFILE#^$PIDFILE^g;" \
    -e "s^#ENVIRONMENT#^$ENVIRONMENT^g;" \
    -e "s^#ENVIRONMENTFILE#^$ENVIRONMENTFILE^g;" \
    -e "s^#CUSTOM_RELOAD#^$CUSTOM_RELOAD^g;" \
    -e "s^#RELOAD_SIGNAL#^$RELOAD_SIGNAL^g;" \
    -e "s^#RELOAD_COMMAND#^$RELOAD_COMMAND^g;" \
    -e "s^#RELOAD_ARGS#^$RELOAD_ARGS^g;" \
    -e "s^#CASE_RELOAD#^$CASE_RELOAD^g;" \
    -e "s^#CASE_RESTART#^$CASE_RESTART^g;" \
    -e "s^#USAGE#^$USAGE^g;" \
    -e "s^#STARTPRE#^$STARTPRE^g;" \
    -e "s^#STARTPOST#^$STARTPOST^g;" \
    -e "s^#STOPPRE#^$STOPPRE^g;" \
    -e "s^#STOPPOST#^$STOPPOST^g;" \
    -e "s^#CUSTOM_STOP#^$CUSTOM_STOP^g;" \
    -e "s^#STOP_COMMAND#^$STOP_COMMAND^g;" \
    -e "s^#STOP_ARGS#^$STOP_ARGS^g;" \
	< $SKELETON \
	> $OUTPUT