I have developed a small python application that I am trying to daemonize. I have used this guide and slightly modified the example. I have the following script:#!/bin/sh### BEGIN INIT INFO# Provides:          my-config-server# Required-Start:    $remote_fs $syslog# Required-Stop:     $remote_fs $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: My configuration website# Description:       Python Flask webserver with config views and API### END INIT INFO# Change the next 3 lines to suit where you install your script and what you want to call itDIR=/home/pi/myserver/config-siteDAEMON=$DIR/run.pyDAEMON_NAME=my-config-serverLOGFILE=/var/log/myserver/config.log# Add any command line options for your daemon hereDAEMON_OPTS=--public# This next line determines what user the script runs as.# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.DAEMON_USER=pi# The process ID of the script when it runs is stored here:PIDFILE=/tmp/$DAEMON_NAME.pid. /lib/lsb/init-functionsdo_start () {    log_daemon_msg Starting system $DAEMON_NAME daemon    start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas /bin/bash -- -c exec $DAEMON $DAEMON_OPTS > $LOGFILE 2>&1    log_end_msg $?}do_stop () {    log_daemon_msg Stopping system $DAEMON_NAME daemon    start-stop-daemon --stop --pidfile $PIDFILE --retry 10    log_end_msg $?}case $1 in    start|stop)        do_${1}        ;;    restart|reload|force-reload)        do_stop        do_start        ;;    status)        status_of_proc $DAEMON_NAME $DAEMON && exit 0 || exit $?        ;;    *)        echo Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}        exit 1        ;;esacexit 0The application reads/writes to a shelve file for storing configuration information. When I run the script from the command line as normal, everything is fine. When I try to start the service, I get a Permission Denied error when trying to read the shelve file:Traceback (most recent call last):  File /home/pi/myserver/config-site/run.py, line 17, in <module>    from config import app  File /home/pi/myserver/config-site/config/__init__.py, line 32, in <module>    alarm_brightness=100  File /home/pi/myserver/config-site/config/persistent_config.py, line 52, in set_defaults    if self.get(k) is None:  File /home/pi/myserver/config-site/config/persistent_config.py, line 14, in get    with shelve.open(self.filename) as shelf:  File /usr/lib/python3.4/shelve.py, line 239, in open    return DbfilenameShelf(filename, flag, protocol, writeback)  File /usr/lib/python3.4/shelve.py, line 223, in __init__    Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)  File /usr/lib/python3.4/dbm/__init__.py, line 94, in open    return mod.open(file, flag, mode)_dbm.error: [Errno 13] Permission deniedThe shelve file permissions and parent directory are currently rwxr--r--.How do I correctly run the daemon/set permissions so I can read/write to this file (and in general to any file with r/w user permissions?)I am running this on a Raspbian install on a Raspberry Pi Zero.
Read/write permissions for daemon running as non-root
permissions;raspbian;init script