#!/bin/bash # # Startup script for the TiMidity++ ALSA sequencer interface # # chkconfig: 2345 20 65 # description: TiMidity is a MIDI to WAVE converter and player that uses Gravis # Ultrasound(tm) or SoundFont(tm) patch files to generate digital # audio data from general MIDI files. # # processname: timidity # config: /etc/sysconfig/timidity ### BEGIN INIT INFO # Provides: timidity # Should-Start: alsa # Default-Start: 2 3 4 5 # Short-Description: MIDI to WAVE converter and player # Description: TiMidity is a MIDI to WAVE converter and player that uses Gravis # Ultrasound(tm) or SoundFont(tm) patch files to generate digital # audio data from general MIDI files. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Get config. . /etc/sysconfig/timidity [ -x /usr/bin/timidity ] || exit 0 OPTIONS="-iADq -Os" RETVAL=0 # See how we were called. case "$1" in start) gprintf "Starting TiMidity++ ALSA sequencer interface:" if [ ! -f /var/lock/subsys/timidity ]; then # Parse options if [[ "$BUFNUM" =~ "[0-9]+" ]] && [[ "$BUFSIZE" =~ "[0-9]+" ]]; then OPTIONS="${OPTIONS} --buffer-fragments=${BUFNUM},${BUFSIZE}" fi [[ "$SAMPLERATE" =~ "[0-9]+" ]] && OPTIONS="$OPTIONS --sampling-freq=$SAMPLERATE" [ "$ANTIALIAS" = "true" ] && OPTIONS="$OPTIONS --anti-alias" [[ "$PRIORITY" =~ "[0-9]+" ]] && OPTIONS="$OPTIONS --realtime-priority=$PRIORITY" [ -n "$EXTRA_OPTIONS" ] && OPTIONS="$OPTIONS $EXTRA_OPTIONS" daemon timidity $OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timidity else failure fi echo ;; stop) gprintf "Shutting down TiMidity++ ALSA sequencer interface:" if [ -f /var/lock/subsys/timidity ]; then killproc timidity RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/timidity else failure fi echo ;; status) status timidity RETVAL=$? ;; reload) killproc -HUP timidity RETVAL=$? ;; restart) $0 stop $0 start RETVAL=$? ;; *) gprintf "Usage: %s {start|stop|status|reload|restart}\n" "$0" exit 1 esac exit $RETVAL