I’m getting this message when checking the status of minidlna on the Jessie image:
root@DietPi2:/etc# service minidlna status
● minidlna.service - MiniDLNA is a DLNA/UPnP-AV server software
Loaded: loaded (/lib/systemd/system/minidlna.service; disabled)
Active: failed (Result: exit-code) since Sun 2015-11-08 18:08:51 EST; 3min 11s ago
Process: 1331 ExecStart=/usr/sbin/minidlnad -S (code=exited, status=255)
Process: 1327 ExecStartPre=/bin/chown $USER /var/run/minidlna (code=exited, status=0/SUCCESS)
Process: 1325 ExecStartPre=/bin/mkdir -p /var/run/minidlna (code=exited, status=0/SUCCESS)
Main PID: 1331 (code=exited, status=255)
Nov 08 18:08:50 DietPi2 systemd[1]: Started MiniDLNA is a DLNA/UPnP-AV server software.
Nov 08 18:08:51 DietPi2 minidlnad[1331]: [2015/11/08 18:08:51] minidlna.c:611: error: Media directory "A,/root/Music" not accessible [Permission denied]
Nov 08 18:08:51 DietPi2 minidlnad[1331]: [2015/11/08 18:08:51] minidlna.c:611: error: Media directory "P,/root/Pictures" not accessible [Permission denied]
Nov 08 18:08:51 DietPi2 minidlnad[1331]: [2015/11/08 18:08:51] minidlna.c:611: error: Media directory "V,/root/Video" not accessible [Permission denied]
Nov 08 18:08:51 DietPi2 minidlnad[1331]: [2015/11/08 18:08:51] utils.c:277: warn: make_dir: cannot create directory '/root/.MiniDLNA_Cache'
Nov 08 18:08:51 DietPi2 minidlnad[1331]: [2015/11/08 18:08:51] minidlna.c:655: fatal: Database path not accessible! [/root/.MiniDLNA_Cache]
Nov 08 18:08:51 DietPi2 systemd[1]: minidlna.service: main process exited, code=exited, status=255/n/a
Nov 08 18:08:51 DietPi2 systemd[1]: Unit minidlna.service entered failed state.
It looks like a permission issue, but I am running as root so I’m not sure what permission I would need to grant. Any help would be appreciated. Thanks!
Looks like minidlna isnt running as root. The weird thing is, i did a test install on my RPiv2 + Jessie just now, and, service runs fine.
Can you try the following:
sed -i '/USER=m/c\USER=root' /etc/init.d/minidlna
systemctl daemon-reload
service minidlna restart
Checks its running:
systemctl status minidlna.service
If it still says failed, can you post the contents of:
cat /etc/init.d/minidlna
cat /lib/systemd/system/minidlna.service
ls -lha /root
EDIT:
It looks like your system is using a systemd service instead (/lib/systemd/system/minidlna.service) of the LSB (/etc/init.d/minidlna) which gets installed. Did you install minidlna via dietpi-software?
I can try the code you suggested when I get home and see if that works.
I am running with Jessie on a Raspberry Pi 2. Currently, it’s installed from the dietpi-software on a fresh image. I noticed that it broke after an apt-get update/upgrade on a previous image and then tried to re-image but it still didn’t work.
Here is the output of the commands you asked about after I tried it with your changes. It still failed due to the same error.
root@DietPi2:~# cat /etc/init.d/minidlna
#!/bin/sh
### BEGIN INIT INFO
# Provides: minidlna
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start minidlna at boot time
# Description: Manage the minidlna daemon, a DLNA/UPnP-AV media server.
### END INIT INFO
unset USER
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="DLNA/UPnP-AV media server"
NAME=minidlna
DAEMON=/usr/sbin/minidlnad
DAEMON_ARGS="-f /etc/minidlna/minidlna.conf"
PIDFILE=/var/run/minidlna/minidlna.pid
SCRIPTNAME=/etc/init.d/minidlna
DEFAULT=/etc/default/$NAME
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r $DEFAULT ] && . $DEFAULT
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
# Do not start the daemon if NO_START is enabled in DEFAULT
if [ "$START_DAEMON" != "yes" ] && [ "$1" != "stop" ]; then
log_warning_msg "$NAME: Not starting $DESC."
log_warning_msg "$NAME: Disabled in $DEFAULT."
exit 0
fi
# Set the default configuration file
if [ -z $CONFIGFILE ]; then
CONFIGFILE=/etc/minidlna.conf
fi
# Set the default log file
if [ -z $LOGFILE ]; then
LOGFILE=/var/log/minidlna.log
fi
# Run as `minidlna' if USER is not specified or is `root'
if [ -z $USER ]; then
USER=root
fi
# If no group is specified, use USER
if [ -z $GROUP ]; then
GROUP=$USER
fi
if [ ! -d /var/run/minidlna ]; then
mkdir /var/run/minidlna
chown $USER:$GROUP /var/run/minidlna
fi
DAEMON_ARGS="-f $CONFIGFILE -P $PIDFILE $DAEMON_OPTS"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
touch $LOGFILE && chown $USER:$GROUP $LOGFILE || return 2
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--chuid $USER:$GROUP --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--chuid $USER:$GROUP --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
if [ "$1" = "force-reload" ]; then
# Rescan the collection
DAEMON_ARGS="$DAEMON_ARGS -R"
fi
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
root@DietPi2:~# cat /lib/systemd/system/minidlna.service
[Unit]
Description=MiniDLNA is a DLNA/UPnP-AV server software
After=local-fs.target network.target
[Service]
User=minidlna
Group=minidlna
Type=simple
# drop root just before ExecStart to allow ExecStartPre to run as root
PermissionsStartOnly=true
# create PID directory
ExecStartPre=/bin/mkdir -p /var/run/minidlna
ExecStartPre=/bin/chown $USER /var/run/minidlna
ExecStart=/usr/sbin/minidlnad -S
[Install]
WantedBy=multi-user.target
root@DietPi2:~# ls -lha /root
total 52K
drwx------ 9 root root 4.0K Nov 8 19:23 .
drwxr-xr-x 21 root root 4.0K Nov 8 17:52 ..
-rw------- 1 root root 782 Nov 9 14:07 .bash_history
-rw-r--r-- 1 root root 723 Nov 8 17:13 .bashrc
drwx------ 3 root root 4.0K Feb 15 2015 .config
drwxrwxr-x 2 root root 4.0K Nov 8 17:50 downloads
drwxr-xr-x 3 root root 4.0K Nov 8 19:23 .java
drwxr-xr-x 2 root root 4.0K Nov 8 17:50 .MiniDLNA_Cache
drwxrwxr-x 2 root root 4.0K Nov 8 17:50 Music
-rw------- 1 root root 57 Nov 8 18:10 .nano_history
drwxrwxr-x 2 root root 4.0K Nov 8 17:50 Pictures
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
drwxrwxr-x 2 root root 4.0K Nov 8 17:50 Video
root@DietPi2:~#
Yep, looks like you had both LSB and SystemD init scripts. The systemd script was set to user=minidlna /lib/systemd/system/minidlna.service, that was causing the issue.
As for why you have both scripts, no idea lol Regardless i’ll update the installation code to support both scripts, just incase the minidlna package decides to update to systemd scripts in the future.