How can I stop/disable mpd service at startup?
I tried to stop/disable mpd as a system service:
It didn't help. Also I tried this proposal:
systemd - Prevent mpd finally from auto-starting - Ask Ubuntu
It didn't work either. Whenever I start RPi I always see mpd process running:
What else should be changed to avoid mpd running as a service at startup?
Thanks!
I tried to stop/disable mpd as a system service:
Code:
sudo service mpd stop
sudo update-rc.d mpd disable
sudo systemctl disable mpd.socket
sudo systemctl disable mpd.service
systemd - Prevent mpd finally from auto-starting - Ask Ubuntu
It didn't work either. Whenever I start RPi I always see mpd process running:
Code:
pi@raspberrypi:~ $ ps -elf | grep mpd
0 S pi 631 556 0 80 0 - 49135 do_epo 03:56 ? 00:00:01 /usr/bin/mpd --no-daemon
Thanks!
It is being controled by systemctl? If not try chkconfig --list t see if it shows up.
If it does use chkconfig off mpd (assuming mpd is the actual service name)
Tony.
If it does use chkconfig off mpd (assuming mpd is the actual service name)
Tony.
There is no chkconfig on Raspbian OS. update-rc.d provides the same functionality:
chkconfig controlling services at boot - Raspberry Pi Forums
And I did that.
chkconfig controlling services at boot - Raspberry Pi Forums
And I did that.
If your raspbian does not use systemd (I do not know), you can always grep the /etc dir and find the occurence.
From that list you can easily find out why the service gets started.
If your system has update-rc, you can just delete the symlinks in corresponding level dirs. Or use
- see man update-rc.d for difference
But I wonder why mpd is running under pi user, normally it has a dedicated mpd user. Are you sure you do not have some custom scripts on your system?
Code:
sudo rgrep mpd /etc
From that list you can easily find out why the service gets started.
If your system has update-rc, you can just delete the symlinks in corresponding level dirs. Or use
Code:
sudo update-rc.d -f remove mpd
- see man update-rc.d for difference
But I wonder why mpd is running under pi user, normally it has a dedicated mpd user. Are you sure you do not have some custom scripts on your system?
I'm trying to make 'mpd' working under 'pi' user. Here are the steps:
It installs 'mpd' and stops it as a system service. After reboot I don't see 'mpd' process.
Then I switch to the 'pi' user:
Then I make mpd.conf file where all links point to ~/.config/mpd folder, change user 'mpd' to 'pi' and place the file in ~/.config/mpd
After that 'mpd' always starts during booting.
Code:
sudo apt-get install mpd
sudo service mpd stop
sudo update-rc.d mpd disable
sudo systemctl disable mpd
sudo systemctl disable mpd.socket
sudo systemctl disable mpd.service
Then I switch to the 'pi' user:
Code:
sudo chown pi /usr/bin/mpd
sudo chgrp audio /usr/bin/mpd
mkdir /home/pi/.config
mkdir /home/pi/.config/mpd
mkdir /home/pi/.config/mpd/playlists
After that 'mpd' always starts during booting.
Code:
pi@raspberrypi:~ $ sudo rgrep mpd /etc
Binary file /etc/ld.so.cache matches
/etc/shadow:mpd:*:18133:0:99999:7:::
/etc/ssl/certs/ca-certificates.crt:374jNUUeAlz+taibmSXaXvMiwzn15Cou08YfxGyqxRxqAQVKL9LFwag0Jl1mpdIC
/etc/default/mpd:## Defaults for the MPD init script, sourced by /etc/init.d/mpd on Debian
/etc/default/mpd:## command 'update-rc.d mpd disable' (or 'systemctl disable mpd' for systemd).
/etc/default/mpd:## The configuration file location for mpd:
/etc/default/mpd:# MPDCONF=/etc/mpd.conf
/etc/logrotate.d/mpd:/var/log/mpd/*.log {
/etc/passwd-:mpd:x:109:29::/var/lib/mpd:/usr/sbin/nologin
/etc/shadow-:mpd:*:18133:0:99999:7:::
/etc/init.d/mpd:# Provides: mpd
/etc/init.d/mpd:NAME=mpd
/etc/init.d/mpd:DAEMON=/usr/bin/mpd
/etc/init.d/mpd:MPDCONF=/etc/mpd.conf
/etc/init.d/mpd:mpd_start () {
/etc/init.d/mpd: if dpkg-statoverride --list --quiet /run/mpd > /dev/null; then
/etc/init.d/mpd: dpkg-statoverride --force --quiet --update --add $( dpkg-statoverride --list --quiet /run/mpd ) 2> /dev/null
/etc/init.d/mpd: chown mpd:audio $PIDDIR
/etc/init.d/mpd:mpd_stop () {
/etc/init.d/mpd:# /etc/init.d/mpd when mpd is updated
/etc/init.d/mpd: mpd_start
/etc/init.d/mpd: mpd_stop
/etc/init.d/mpd: mpd_stop
/etc/init.d/mpd: mpd_start
/etc/init.d/mpd: mpd_start
/etc/init.d/mpd: mpd_stop
/etc/init.d/mpd: mpd_start
/etc/init.d/mpd: mpd_stop
/etc/init.d/mpd: mpd_start
/etc/xdg/autostart/mpd.desktop:# Make sure to create your own ~/.mpdconf containing the path to your music,
/etc/xdg/autostart/mpd.desktop:Exec=mpd
/etc/passwd:mpd:x:109:29::/var/lib/mpd:/usr/sbin/nologin
Code:
/etc/xdg/autostart/mpd.desktop:# Make sure to create your own ~/.mpdconf containing the path to your music,
/etc/xdg/autostart/mpd.desktop:Exec=mpd
You have mpd in autostart - MPD is started when user logs in into desktop environment XDG Autostart - ArchWiki . Very likely configured by the MPD package . To confirm search the file in packages with
Code:
dpkg -S mpd.desktop
That's because I'm trying to do that from scratch and didn't complete yet the steps described in the link which I mentioned already: systemd - Prevent mpd finally from auto-starting - Ask Ubuntu
But even if I follow all those instructions 'mpd' is still running. Even if I remove completely that file /etc/xdg/autostart/mpd.desktop it's still running and also:
But even if I follow all those instructions 'mpd' is still running. Even if I remove completely that file /etc/xdg/autostart/mpd.desktop it's still running and also:
Code:
pi@raspberrypi:~ $ dpkg -S mpd.desktop
mpd: /etc/xdg/autostart/mpd.desktop
Yeah, the xdg entry is provided directly by the mpd package, it was expectable.
I would delete the autostart entry completely, instead of copying it to user-level xdg config and hoping some config directive is honoured. I do not see any reason why mpd should autostart (of course upon reboot), if there is no config anymore.
I would delete the autostart entry completely, instead of copying it to user-level xdg config and hoping some config directive is honoured. I do not see any reason why mpd should autostart (of course upon reboot), if there is no config anymore.
Yes, it looks weird (after removing config file and rebooting):
Code:
pi@raspberrypi:~ $ ls /etc/xdg/autostart/
xdg-user-dirs.desktop
pi@raspberrypi:~ $ ls .config
mpd
pi@raspberrypi:~ $ dpkg -S mpd.desktop
mpd: /etc/xdg/autostart/mpd.desktop
pi@raspberrypi:~ $ ps -elf | grep mpd
0 S pi 665 653 2 80 0 - 46832 do_epo 18:28 ? 00:00:01 /usr/bin/mpd --no-daemon
Are you sure you have no user xdg entry for mpd autostart?
I would disable user autologin to desktop environment (if enabled). When the login screen appears after reboot, I would switch to console (Ctrl+Alt+F1), log in and check if mpd is running. If so, it is started by some startup script (systemd, update-rc.d). If not, get back to X Window (Alt+F7 or F8), log into desktop environment. If mpd is running, it is started by xdg autostart, you must have it somewhere in the scripts (~/.config/autostart/* ?).
I would disable user autologin to desktop environment (if enabled). When the login screen appears after reboot, I would switch to console (Ctrl+Alt+F1), log in and check if mpd is running. If so, it is started by some startup script (systemd, update-rc.d). If not, get back to X Window (Alt+F7 or F8), log into desktop environment. If mpd is running, it is started by xdg autostart, you must have it somewhere in the scripts (~/.config/autostart/* ?).
Actually I don't use graphical desktop. I use 'Console with Autologin' mode and connect through 'putty' using SSH.
Still something must start mpd and that is configured either in /etc or in /home/pi. You can rgrep whole /home/pi for mpd.
Somehow it was started for 'pi' user. No idea how. And the most frustrating thing - I didn't configure anything for that.
Code:
pi@raspberrypi:~ $ grep mpd /etc/rc.local
pi@raspberrypi:~ $ grep mpd .bashrc
pi@raspberrypi:~ $ systemctl list-unit-files | grep mpd
mpd.service disabled
mpd.socket disabled
pi@raspberrypi:~ $ ls /etc/init.d | grep mpd
pi@raspberrypi:~ $ ps -elf | grep mpd
0 S pi 702 690 0 80 0 - 46832 do_epo 19:29 ? 00:00:01 /usr/bin/mpd --no-daemon
Brute force usually helps.
Also, does pstree reveal something about parent of mpd?
Code:
rgrep mpd /home/pi
Also, does pstree reveal something about parent of mpd?
Code:
pi@raspberrypi:~ $ rgrep mpd /home/pi
/home/pi/.config/mpd/mpd.conf:# or /usr/share/doc/mpd/user-manual.html
/home/pi/.config/mpd/mpd.conf:playlist_directory "~/.config/mpd/playlists"
/home/pi/.config/mpd/mpd.conf:db_file "~/.config/mpd/tag_cache"
/home/pi/.config/mpd/mpd.conf:#log_file "/var/log/mpd/mpd.log"
/home/pi/.config/mpd/mpd.conf:# for use of mpd --kill and some init scripts. This setting is disabled by
/home/pi/.config/mpd/mpd.conf:pid_file "~/.config/mpd/pid"
/home/pi/.config/mpd/mpd.conf:state_file "~/.config/mpd/state"
/home/pi/.config/mpd/mpd.conf:sticker_file "~/.config/mpd/sticker.sql"
/home/pi/.config/mpd/mpd.conf:# to have mpd listen on every address. Not effective if systemd socket
/home/pi/.config/mpd/mpd.conf:#bind_to_address "/run/mpd/socket"
/home/pi/.config/mpd/mpd.conf:# found in the mpd.conf man page.
/home/pi/.config/mpd/mpd.conf:# host "other.mpd.host"
/home/pi/.config/mpd/mpd.conf:# mount "/mpd.ogg"
/home/pi/.config/mpd/mpd.conf:# path "/var/lib/mpd/recorder/mpd.ogg"
/home/pi/.config/mpd/mpd.conf:# Please see README.Debian if you want mpd to play through the pulseaudio
/home/pi/.config/mpd/mpd.conf:# mpd.conf man page or the libsamplerate documentation. By default, this is
/home/pi/.config/mpd/state:mixrampdb: 0.000000
/home/pi/.config/mpd/state:mixrampdelay: -1.000000
Code:
pi@raspberrypi:~ $ pstree -G
systemd─┬─agetty
├─alsactl
├─avahi-daemon───avahi-daemon
├─bluetoothd
├─cron
├─dbus-daemon
├─dhcpcd
├─hciattach
├─lircd───sh
├─rngd───3*[{rngd}]
├─rsyslogd───3*[{rsyslogd}]
├─sshd───sshd───sshd───bash───pstree
├─systemd─┬─(sd-pam)
│ └─mpd───2*[{mpd}]
├─systemd-journal
├─systemd-logind
├─systemd-timesyn───{systemd-timesyn}
├─systemd-udevd
├─thd
└─2*[wpa_supplicant]
Interesting. mpd is not started directly by systemd like all other units (cron, lircd, etc.), but by another systemd process which started sd-pam too. PAM is login service. You said you have configured autologin to console. My 2 cents mpd is somehow configured as user-session systemd service systemd/User - ArchWiki
What is in your /usr/lib/systemd/user/? Perhaps the mpd package installed some service there too? Is any listed in dpkg -L mpd?
Look at systemd/User - ArchWiki - note the --user parameter of systemctl . It may be possible you have disabled global mpd, but your user-level mpd is enabled.
What is in your /usr/lib/systemd/user/? Perhaps the mpd package installed some service there too? Is any listed in dpkg -L mpd?
Look at systemd/User - ArchWiki - note the --user parameter of systemctl . It may be possible you have disabled global mpd, but your user-level mpd is enabled.
Yes, there was mpd.service in folder /usr/lib/systemd/user. Removing that file fixed the problem. Probably there is a command which should do that in a "graceful" way. I'm pretty sure I didn't configure user level service for 'mpd'. More likely 'mpd' itself does that.
Anyway, thanks a lot!
Anyway, thanks a lot!
Perfect, we both have learned a new feature of the systemd beast.
It would be very useful to know the "culprit". Check the list of all files in the mpd package with dpkg -L mpd. Very likely it will list the systemd user service file.
More likely 'mpd' itself does that.
It would be very useful to know the "culprit". Check the list of all files in the mpd package with dpkg -L mpd. Very likely it will list the systemd user service file.
Yes, it's there:
Code:
pi@raspberrypi:~ $ dpkg -L mpd
/.
/etc
/etc/default
/etc/default/mpd
/etc/init.d
/etc/init.d/mpd
/etc/logrotate.d
/etc/logrotate.d/mpd
/etc/mpd.conf
/etc/xdg
/etc/xdg/autostart
/etc/xdg/autostart/mpd.desktop
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/mpd.service
/lib/systemd/system/mpd.socket
/usr
/usr/bin
/usr/bin/mpd
/usr/lib
/usr/lib/systemd
/usr/lib/systemd/user
/usr/lib/systemd/user/mpd.service
...
- Status
- Not open for further replies.
- Home
- Source & Line
- PC Based
- mpd service or Who wants to live forever...