1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-12-18 07:36:34 -05:00

Ensure fortune is installed

This patch uses python3's shutil to find the path
to fortune app, which can be very different depending on
the host OS that aprsd is running on.
This commit is contained in:
Hemna 2020-12-20 17:16:15 -05:00
parent c39fddef67
commit 18b269a39d
4 changed files with 12 additions and 4 deletions

View File

@ -4,6 +4,8 @@ CHANGES
v1.1.0
------
* Ensure fortune is installed
* Updated docker-compose
* Added Changelog
* Fixed issue when RX ack
* Updated the aprsd-slack-plugin required version

View File

@ -6,7 +6,7 @@ ENV HOME=/home/aprs
ENV VIRTUAL_ENV=$HOME/.venv3
ENV INSTALL=$HOME/install
RUN apk add --update git wget py3-pip py3-virtualenv bash
RUN apk add --update git wget py3-pip py3-virtualenv bash fortune
# Setup Timezone
ENV TZ=US/Eastern

View File

@ -10,7 +10,7 @@ ENV APRSD_BRANCH="master"
ENV VIRTUAL_ENV=$HOME/.venv3
ENV INSTALL=$HOME/install
RUN apk add --update git vim wget py3-pip py3-virtualenv bash
RUN apk add --update git vim wget py3-pip py3-virtualenv bash fortune
# Setup Timezone
ENV TZ=US/Eastern
@ -19,7 +19,6 @@ ENV TZ=US/Eastern
#RUN dpkg-reconfigure --frontend noninteractive tzdata
RUN addgroup --gid 1001 $APRS_USER
RUN adduser --help
RUN adduser -h $HOME -D -u 1001 -G $APRS_USER $APRS_USER
ENV LC_ALL=C.UTF-8

View File

@ -7,6 +7,7 @@ import json
import logging
import os
import re
import shutil
import subprocess
import time
@ -246,9 +247,15 @@ class FortunePlugin(APRSDPluginBase):
def command(self, fromcall, message, ack):
LOG.info("FortunePlugin")
reply = None
fortune_path = shutil.which("fortune")
if not fortune_path:
reply = "Fortune command not installed"
return reply
try:
process = subprocess.Popen(
["/usr/games/fortune", "-s", "-n 60"], stdout=subprocess.PIPE
[fortune_path, "-s", "-n 60"], stdout=subprocess.PIPE
)
reply = process.communicate()[0]
reply = reply.decode(errors="ignore").rstrip()