install: update script to set PYTHONPATH env var

This is preferable to setting the WorkingDirectory item in
the systemd unit, as its possible to switch between git repos
and installed wheels without requiring root.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-02-10 12:11:31 -05:00
parent 5ffd18d132
commit 7520d0e7b1
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 3 additions and 3 deletions

View File

@ -131,12 +131,13 @@ install_script()
ENV_FILE="${DATA_PATH}/systemd/moonraker.env" ENV_FILE="${DATA_PATH}/systemd/moonraker.env"
if [ ! -f $ENV_FILE ] || [ $FORCE_DEFAULTS = "y" ]; then if [ ! -f $ENV_FILE ] || [ $FORCE_DEFAULTS = "y" ]; then
rm -f $ENV_FILE rm -f $ENV_FILE
args="MOONRAKER_ARGS=\"${SRCDIR}/moonraker/moonraker.py" args="MOONRAKER_ARGS=\"-m moonraker"
[ -n "${CONFIG_PATH}" ] && args="${args} -c ${CONFIG_PATH}" [ -n "${CONFIG_PATH}" ] && args="${args} -c ${CONFIG_PATH}"
[ -n "${LOG_PATH}" ] && args="${args} -l ${LOG_PATH}" [ -n "${LOG_PATH}" ] && args="${args} -l ${LOG_PATH}"
args="${args} -d ${DATA_PATH}" args="${args} -d ${DATA_PATH}"
args="${args}\"" args="${args}\""
echo $args > $ENV_FILE args="${args}\nPYTHONPATH=\"${SRCDIR}\""
echo -e $args > $ENV_FILE
fi fi
[ -f $SERVICE_FILE ] && [ $FORCE_DEFAULTS = "n" ] && return [ -f $SERVICE_FILE ] && [ $FORCE_DEFAULTS = "n" ] && return
report_status "Installing system start script..." report_status "Installing system start script..."
@ -156,7 +157,6 @@ Type=simple
User=$USER User=$USER
SupplementaryGroups=moonraker-admin SupplementaryGroups=moonraker-admin
RemainAfterExit=yes RemainAfterExit=yes
WorkingDirectory=${SRCDIR}
EnvironmentFile=${ENV_FILE} EnvironmentFile=${ENV_FILE}
ExecStart=${PYTHONDIR}/bin/python \$MOONRAKER_ARGS ExecStart=${PYTHONDIR}/bin/python \$MOONRAKER_ARGS
Restart=always Restart=always