I am trying to convert a systemd service to sysvinit, while trying to run the following service named mullvad-vpn;
#!/bin/sh
.....
. /lib/lsb/init-functions
prog=mullvad-daemon
PIDFILE=/var/run/$prog.pid
DESC="Mullvad VPN daemon"
start() {
log_daemon_msg "Starting $DESC" "$prog"
start_daemon -p $PIDFILE /opt/Mullvad\x20VPN/resources/mullvad-daemon -v --disable-stdout-timestamps
if [ $? -ne 0 ]; then
log_end_msg 1
exit 1
fi
if [ $? -eq 0 ]; then
log_end_msg 0
fi
exit 0
}
stop() {
log_daemon_msg "Stopping $DESC" "$prog"
killproc -p $PIDFILE /opt/Mullvad\x20VPN/resources/mullvad-daemon
if [ $? -ne 0 ]; then
log_end_msg 1
exit 1
fi
if [ $? -eq 0 ]; then
log_end_msg 0
fi
.....
Giving me the following result;
sudo service mullvad-daemon.sh start
Starting Mullvad VPN daemon: mullvad-daemon/sbin/start-stop-daemon: unable to stat /opt/Mullvadx20VPN/resources/mullvad-daemon (No such file or directory)
I tried; double quotes around path with just a space, single quotes path with just a space, and with backslashes, double backward backslashes, to try and escape further. All with combinations of \x20 or \xa0. It works if I remove the space from the folder name and adjust directory, and while it's usable it obviously fails to load some assets. This is probably very simple and the only thing stopping it from being fully functional.
Thank you @user1934428 and @GordonDavisson for putting me on the right track. The solution was to wrap
$exec
in quotes on line 58 in/lib/lsb/init-functions
;my
/etc/init.d/mullvad-daemon.sh
now looks like this