LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-17-2018, 12:47 AM   #1
compton
LQ Newbie
 
Registered: May 2018
Posts: 6

Rep: Reputation: Disabled
MPD won't auto start at boot


Hello fine slackfolk. I can't seem to make mpd autostart at boot.
I'm using Slackware 14.2 on a MacbookPro7,1.
Mpd installed from SBo
I using senior member SCerovecs suggested rc.mpd posted here:
https://www.linuxquestions.org/quest...me-4175596626/

I can start mpd manualy after logging in, although it takes about 30 secs before mpc or ncmpcpp can connect, but if mpd was playing when shutdown, it plays right away. I have tried sleep in rc.mpd. Seems to make no difference whether network is up or not. Verbose log shows same as rc.mpd output.
$USER refers to my user Thanks

/etc/rc.d/rc.local
Code:
# Start MPD server
if [ -x /etc/rc.d/rc.mpd ]; then
  /etc/rc.d/rc.mpd start
fi
/etc/rc.d/rc.mpd
Code:
#!/bin/sh

# we find mpd
# (usually in /usr/bin/mpd, Use 'which mpd' to determine)
MPD="/usr/bin/mpd "
# mpd companion and it's path
MPC=/usr/bin/mpc
# we default to start as the command
CMD=${1:-start}
# we default to the here provided user
USR=$USER

for X in $MPD $MPC; {
  if [[ ! -x "$X" ]]; then
    echo "[${X}] is not executable or present"
    exit 1
  fi
}

case $USR in
root)
    echo  -e "run as root [$USR] - trouble ahead!"
    ;;
*)
    echo -e "run as non root [$USR], as recommended."
    if id $USR; then
      echo "found [$USR] present, continuing..."
    else
      echo "[$USR] not known on this host. aborting."
      exit 1
    fi
    ;;
esac

case $CMD in
start)
    #echo "starting music player daemon: su -c ${MPD} ${USR}"
    echo "starting music player daemon: su -c sleep 10; ${MPD} ${USR}"
    su -c "sleep 10; $MPD" $USR
    ;;
stop)
    echo "stopping mpd: su -c ${MPD} --kill ${USR}"
    su -c "$MPD --kill" $USR
    ;;
status)
    echo "mpd status:  su -c $MPC stats"
    su -c "$MPC stats" $USR
    ;;
*)
    echo "rc.mpd - undefined command, use - <start|stop|status> only.)"
    exit 1
    ;;
esac

#ends here
bash-4.3# /etc/rc.d/rc.mpd start
Code:
run as non root [flint], as recommended.
uid=1000($USER) gid=100(users) groups=100(users),7(lp),11(floppy),16(dialout),17(audio),18(video),19(cdrom),83(plugdev),84(power),86(netdev),93(scanner)
found [$USER] present, continuing...
starting music player daemon: su -c sleep 10; /usr/bin/mpd  flint
May 17 14:38 : exception: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
May 17 14:38 : libsamplerate: libsamplerate converter 'Fastest Sinc Interpolator'
May 17 14:38 : vorbis: Xiph.Org libVorbis 1.3.6
May 17 14:38 : opus: libopus 1.1
May 17 14:38 : sndfile: libsndfile-1.0.26
May 17 14:38 : simple_db: reading DB
May 17 14:38 : curl: version 7.59.0
May 17 14:38 : curl: with OpenSSL/1.0.2o
bash-4.3$ cat .mpdconf
Code:
music_directory			"/home/Music"
playlist_directory		"/home/Playlists"
db_file				"~/.mpd/database"
log_file			"~/.mpd/log"
pid_file			"~/.mpd/pid"
state_file			"~/.mpd/state"
sticker_file			"~/.mpd/sticker.sql"
user				"$USER"
#group				"audio"
bind_to_address			"any"
#bind_to_address		"127.0.0.1"
bind_to_address			"~/.mpd/socket"
#port				"6600"
log_level			"verbose"
max_output_buffer_size	"16384"		# default 8192
#gapless_mp3_playback			"yes"
#restore_paused 		"no"
#save_absolute_paths_in_playlists	"no"
#metadata_to_use	"artist,album,title,track,name,genre,date,composer,performer,disc"
auto_update	"yes"
auto_update_depth "4"
#follow_outside_symlinks	"yes"
#follow_inside_symlinks		"yes"
#zeroconf_enabled		"yes"
#zeroconf_name			"Music Player"
#password                        "password@read,add,control,admin"
#default_permissions             "read,add,control,admin"
#database {
#       plugin "proxy"
#       host "other.mpd.host"
#       port "6600"
#}
input {
        plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
}
audio_output {
	type		"alsa"
	name		"default"
#	name		"Pro240004f7"
#	device		"hw:0,0"	# optional
#	mixer_type      "software"	# optional
#	mixer_device	"default"	# optional
	mixer_control	"PCM"		# optional
	mixer_index	"0"		# optional
}
audio_output {
	type		"httpd"
	name		"MPD"
	encoder		"vorbis"		# optional, vorbis or lame
	port		"8000"
#	bind_to_address	"0.0.0.0"		# optional, IPv4 or IPv6
	quality		"10.0"			# do not define if bitrate is defined
#	bitrate		"320"			# do not define if quality is defined
	format		"44100:16:2"
	max_clients	"1"			# optional 0=no limit
}
audio_output {
    type                    "fifo"
    name                    "mpd_visualiser"
    path                    "~/tmp/mpd.fifo"
    format                  "44100:16:2"
}

replaygain			"album"
volume_normalization		"yes"
 
Old 05-17-2018, 02:17 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,602

Rep: Reputation: 126Reputation: 126
I don't know what's wrong with your setup. The way it works for me (on slackwarearm-current): A simple line with only "mpd" in rc.local and two lines in /etc/mpd.conf:

Code:
user    "tito"
group   "users"
 
Old 05-19-2018, 02:34 PM   #3
MisterL
LQ Newbie
 
Registered: Mar 2018
Location: Germany
Distribution: Slackware
Posts: 10

Rep: Reputation: 7
Quote:
Originally Posted by compton View Post
May 17 14:38 : exception: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
Hi compton,

please check if mpd is already started or whatelse is listening on the ipv4 port. I think another mpd process may run, started by root via the rc.local and blocking the audio output. DB and state file look ok to me. I don't use a unix socket myself, so I can't say if this would disable the ipv4 socket. Nor do I run mpd as the logged-in user.

Try disable the rc.local autostart and see if this helps.
 
Old 05-19-2018, 10:00 PM   #4
compton
LQ Newbie
 
Registered: May 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MisterL
Try disable the rc.local autostart and see if this helps.
No difference. I commented out rc.mpd lines from rc.local. Mpd output is the same when started manualy.

Quote:
Originally Posted by MisterL
please check if mpd is already started or whatelse is listening on the ipv4 port
I'm pretty sure mpd isn't running already, ncmpcpp says connectioned refused if mpd is not running, but says timeout if up but not cantactable. If mpd was playing when shutdown it will play imdiateley when started again, which has never happened automatically at boot for me.

How do I check if anything is listening on the ipv4 port?

Thanks for the replies

Quote:
Originally Posted by titopoquito
A simple line with only "mpd" in rc.local and two lines in /etc/mpd.conf:
I'll try using /etc/mpd.conf instaed of ~/.mpdconf
 
Old 05-19-2018, 11:56 PM   #5
MisterL
LQ Newbie
 
Registered: Mar 2018
Location: Germany
Distribution: Slackware
Posts: 10

Rep: Reputation: 7
Quote:
Originally Posted by compton View Post
How do I check if anything is listening on the ipv4 port?
As root: netstat -anp | grep 6600
 
Old 05-20-2018, 01:04 AM   #6
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,602

Rep: Reputation: 126Reputation: 126
I am getting this exception, too. mpd ist working fine though.
 
Old 05-20-2018, 02:30 AM   #7
compton
LQ Newbie
 
Registered: May 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MisterL
please check if mpd is already started or whatelse is listening on the ipv4 port
netstat returns nothing until mpd is started manually.

I have both /etc/mpd.conf and ~/.mpdconf.
 
Old 05-20-2018, 09:41 AM   #8
MisterL
LQ Newbie
 
Registered: Mar 2018
Location: Germany
Distribution: Slackware
Posts: 10

Rep: Reputation: 7
OK, seems I'm getting that error, too, but don't log it.

The music you're playing is a local file, ie. no nfs or smb mount, right?
Sorry, now I'm out of ideas.
 
Old 05-20-2018, 11:22 AM   #9
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,602

Rep: Reputation: 126Reputation: 126
An addendum: I had to set pulseaudio to run system wide (versus the per user setting) by setting permissions to 755 for /etc/rc.d/rc.pulseaudio. I am not sure if this might affect your tries. With this and the /etc/mpd.conf setting it is working for me flawlessly, despite the above mentioned exception.
 
Old 05-21-2018, 12:56 AM   #10
compton
LQ Newbie
 
Registered: May 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MisterL
The music you're playing is a local file, ie. no nfs or smb mount, right?
Media files reside locally.

Quote:
Originally Posted by titopoquito
I had to set pulseaudio to run system wide (versus the per user setting) by setting permissions to 755 for /etc/rc.d/rc.pulseaudio.
Is that secure? I don't use pulseaudio, but maybe I could try changing /etc/rc.d/rc.alsa permissions to 755.
 
Old 05-21-2018, 03:07 AM   #11
compton
LQ Newbie
 
Registered: May 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
/etc/rc.d/rc.alsa is 755 already.
 
Old 05-21-2018, 03:30 AM   #12
BigTig
Member
 
Registered: Aug 2015
Posts: 30

Rep: Reputation: Disabled
I had similar problems so this is what I did:
I put the following in rc.local:
sudo -u bigtig /usr/bin/mpd

I then put this in rc.local_shutdown
sudo -u bigtig mpd --kill

so it'll stop mpd appropriately. It has worked fine so far.
 
Old 05-24-2018, 04:36 AM   #13
compton
LQ Newbie
 
Registered: May 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
BigTig said:
I put the following in rc.local:
sudo -u bigtig /usr/bin/mpd

I then put this in rc.local_shutdown
sudo -u bigtig mpd --kill
I tried doing it like that, but alas, no joy. Thanks though.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware 14.2 - How to start mpd (Music Player Daemon) at boot time glupa4e Slackware 6 01-05-2017 02:20 AM
[SOLVED] Ubuntu Lucid + Kubuntu Desktop - Screen Saver won't auto start Bumpalot Ubuntu 0 05-31-2012 05:30 PM
MPD auto DB update - Can it be disabled? corrosivemisery Linux - Desktop 0 02-13-2012 04:24 PM
How do I auto start modules that aren't auto loaded on boot? darkbluedrew Debian 2 09-18-2005 09:10 AM
KDM won't auto-start after power failure ltb Linux - Newbie 1 03-16-2005 04:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration