mpd: run mpd as a non-root user
* Make /etc/mpd.conf worldreadable. Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
This commit is contained in:
parent
d424d19b5a
commit
c9b28a3125
2 changed files with 12 additions and 3 deletions
|
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=mpd
|
PKG_NAME:=mpd
|
||||||
PKG_VERSION:=0.22.6
|
PKG_VERSION:=0.22.6
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
PKG_SOURCE_URL:=https://www.musicpd.org/download/mpd/0.22/
|
PKG_SOURCE_URL:=https://www.musicpd.org/download/mpd/0.22/
|
||||||
|
@ -35,6 +35,7 @@ define Package/mpd/Default
|
||||||
URL:=https://www.musicpd.org/
|
URL:=https://www.musicpd.org/
|
||||||
DEPENDS:= +zlib +libcurl +libpthread +libmpdclient +boost $(ICONV_DEPENDS) \
|
DEPENDS:= +zlib +libcurl +libpthread +libmpdclient +boost $(ICONV_DEPENDS) \
|
||||||
+AUDIO_SUPPORT:alsa-lib +libexpat +libflac +libid3tag +libfaad2 +libopus
|
+AUDIO_SUPPORT:alsa-lib +libexpat +libflac +libid3tag +libfaad2 +libopus
|
||||||
|
USERID:=mpd:mpd
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/mpd/Default/description
|
define Package/mpd/Default/description
|
||||||
|
@ -220,7 +221,7 @@ define Package/mpd/install
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mpd $(1)/usr/bin/
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mpd $(1)/usr/bin/
|
||||||
$(INSTALL_DIR) $(1)/etc
|
$(INSTALL_DIR) $(1)/etc
|
||||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/doc/mpdconf.example $(1)/etc/mpd.conf
|
$(INSTALL_DATA) $(PKG_BUILD_DIR)/doc/mpdconf.example $(1)/etc/mpd.conf
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
$(INSTALL_BIN) ./files/mpd.init $(1)/etc/init.d/mpd
|
$(INSTALL_BIN) ./files/mpd.init $(1)/etc/init.d/mpd
|
||||||
endef
|
endef
|
||||||
|
|
|
@ -9,6 +9,9 @@ PROG=/usr/bin/mpd
|
||||||
CONFIGFILE=/etc/mpd.conf
|
CONFIGFILE=/etc/mpd.conf
|
||||||
NICEPRIO=-10
|
NICEPRIO=-10
|
||||||
|
|
||||||
|
USER="mpd"
|
||||||
|
GROUP="mpd"
|
||||||
|
|
||||||
#TODO: Add uci config - nice, config
|
#TODO: Add uci config - nice, config
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
@ -16,7 +19,10 @@ start_service() {
|
||||||
|
|
||||||
#create mpd directories from config
|
#create mpd directories from config
|
||||||
pld=$(grep ^playlist_directory "$CONFIGFILE" | cut -d "\"" -f 2 | sed "s/~/\/root/g")
|
pld=$(grep ^playlist_directory "$CONFIGFILE" | cut -d "\"" -f 2 | sed "s/~/\/root/g")
|
||||||
[ -d "$pld" ] || mkdir -m 0755 -p "$pld"
|
if [ ! -d "$pld" ]; then
|
||||||
|
mkdir -m 0755 -p "$pld"
|
||||||
|
chown $USER:$GROUP $pld
|
||||||
|
fi
|
||||||
|
|
||||||
lport=$(grep ^port "$CONFIGFILE" | cut -d "\"" -f 2)
|
lport=$(grep ^port "$CONFIGFILE" | cut -d "\"" -f 2)
|
||||||
[ -z "$lport" ] && lport=6600
|
[ -z "$lport" ] && lport=6600
|
||||||
|
@ -24,6 +30,8 @@ start_service() {
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_add_mdns "mpd" "tcp" "$lport"
|
procd_add_mdns "mpd" "tcp" "$lport"
|
||||||
procd_set_param command "$PROG" --no-daemon "$CONFIGFILE"
|
procd_set_param command "$PROG" --no-daemon "$CONFIGFILE"
|
||||||
|
procd_set_param user "$USER"
|
||||||
|
procd_set_param group "$GROUP"
|
||||||
procd_set_param stderr 1
|
procd_set_param stderr 1
|
||||||
# Give MPD some real-time priority
|
# Give MPD some real-time priority
|
||||||
procd_set_param nice "$NICEPRIO"
|
procd_set_param nice "$NICEPRIO"
|
||||||
|
|
Loading…
Reference in a new issue