[CentOS] systemctl (again)

Thu Apr 2 22:40:23 UTC 2015
J Martin Rushton <martinrushton56 at btinternet.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SELinux certainly was causing fun and games.  I copied your suggestion
to /etc/systemd/user/timidity.service (mode 750) but it's still not happy:

	[root at tamar user]# systemctl status timidity
	timidity.service
	   Loaded: not-found (Reason: No such file or directory)
	   Active: failed (Result: exit-code) since Th...

	... Starting LSB: Add and remove timidity...
	... timidity.service: control process exited, code=exited status=203
	... Failed to start LSB: Add and remove timidity.
	... Unit timidity.service entered failed state.
	... Stopped timidity.service.

I've wasted way too much time on this, I've put it in my .profile.
The weirdness of systemctl will have to wait!

Thanks all

On 02/04/15 22:16, Andrew Holway wrote:
> It might be SELinux. On a standard system; when we run things as a
> user from the command line SELinux rules do not apply. It would
> explain why it works manually but not via systemd.
> 
> Rather than using an init.d script you might want to try using a
> systemd service. I haven't tested but something like this should
> work.
> 
> [Unit] Description=timidity daemon
> 
> [Service] PIDFile=/var/run/timidity.pid User=someuser 
> Group=someuser WorkingDirectory=/home/someuser 
> ExecStart=/bin/timidity ExecReload=/bin/kill -s HUP $MAINPID 
> ExecStop=/bin/kill -s TERM $MAINPID PrivateTmp=true
> 
> 
> 
> 
> 
> On 2 April 2015 at 23:07, J Martin Rushton
> <martinrushton56 at btinternet.com> wrote:
> 
> I've been trying to get the timidity system running as a daemon.
> I wrote the following init script:
> 
> #!/bin/sh # # timidity # ### BEGIN INIT INFO # Provides: timidity #
> Required-Start: # Required-Stop: # Default-Start:  2 3 4 5 #
> Default-Stop: 0 1 6 # Short-Description: Add and remove timidity #
> Description: ### END INIT INFO
> 
> . /etc/rc.d/init.d/functions
> 
> RETVAL=0 PROG=timidity EXEC=/bin/$PROG 
> PIDFILE=/var/run/timidity.pid
> 
> function start { [[ -x $EXEC ]] || exit 5 echo -n "Starting $PROG:
> " $EXEC -iAD RETVAL=$? echo return $RETVAL }
> 
> function stop { echo -n "Stopping $PROG: " killproc $EXEC -TERM 
> RETVAL=$? echo return $RETVAL }
> 
> case "$1" in start)  start RETVAL=$? ;; stop)   stop RETVAL=$? ;; 
> status) status $PROG RETVAL=$? ;; restart) stop start ;; reload) 
> stop start ;; *) echo $"Usage: $prog 
> {start|stop|status|restart|reload}" exit 1 esac exit $RETVAL
> 
> 
> When run through systemctl during startup it fails:
> 
> [root at tamar init.d]# systemctl status timidity timidity.service -
> LSB: Add and remove timidity Loaded: loaded
> (/etc/rc.d/init.d/timidity) Active: active (exited) since Thu ... 
> Process: 784 ExecStart=/etc/rc.d/init.d/timidity start 
> (code=exited, status=0/SUCCESS)
> 
> ... Starting LSB: Add and remove timidity... ... Starting
> timidity: ... jack_client_new: deprecated ... Started LSB: Add and
> remove timidity. ... Cannot connect to server socket err = No such
> file or directory ... Cannot connect to server request channel ...
> jack server is not running or cannot be started ... Couldn't open
> output device
> 
> But when run directly is works fine:
> 
> [root at tamar init.d]# ./timidity start Starting timidity: TiMidity
> starting in ALSA server mode Opening sequencer port: 128:0 128:1
> 128:2 128:3
> 
> If I use # service timidity start it also fails.
> 
> I _think_ that what is happening is that systemctl is stripping
> off the switch.  I've spent a couple of hours searching for any
> links or explanation and got nowhere.  I even knocked up a script
> to try and separate the two parts: #!/bin/sh cd /etc/init.d 
> ./timidity start but to no avail.
> 
> If there is a simple fix could someone point me there, if it's
> complex don't bother, I only need the daemon when running MIDI and
> can start it by hand.
>> _______________________________________________ CentOS mailing
>> list CentOS at centos.org 
>> http://lists.centos.org/mailman/listinfo/centos
>> 
> _______________________________________________ CentOS mailing
> list CentOS at centos.org 
> http://lists.centos.org/mailman/listinfo/centos
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJVHcVWAAoJEAF3yXsqtyBlHDcP/2VULTDUzhuWefhRm1pqhMpi
S/bOjeNIuhhmpnyPhnCg4xm5jYXFa1ix6q4RCxv70HAGXkv/dZpFOZ63/ni+nKnD
5xyjez0TLpvlYGg3sGJhbtatenwYMlCy4KdZt+JnuWNce/9cgPy8/oALxSOQfmp/
Comfk2d3BN/g7TxpNs1zPetFEW2fytbzh0IMjF7pOe5OtOPe+FMI8Y8wZSbkzd73
6I/5bmL6nWEHelI65dB4KaXDsWfGoc9ZkVbXJ2lHrx70avbuyKu9o+jD9MVYxa83
AgGUGlt7oZuuYGVLy4oR+T6c6O+LdLXgSuI79RsSBwwdwSkTLGOIT5ljDV53krum
2g93QtJyGtPL2+oCNqvcqKhkO8RVJ/i9B9huHvRYT0s9TcJ6+54nrCbv54y6zXc2
eonvwyuFtGkRPG2spOotK342dx63cus1T+vQU+d4ohBTANvSkh6NVFb0nbAbADJy
FLRx3IdFRbe05Ehsb6hTTEnTZMTLNXx1EruvPJdTpA4c6j2eU35LwF/vEeOC+5Kq
XESUSr6kSSgFHmZB40rt03lPcMameqIpWBVBgQln7KTkxxVY5yb/zjm7Cz9HdsUm
TK96Gf+Xxf/iV6E/fZAsBLQmqbHL/6WeteF0t8qa7YcET1Y68xkJ/8Rbn1/Ers/C
/DE83/mqV3dz2SQO6Di+
=iFvP
-----END PGP SIGNATURE-----