1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-05-24 10:32:25 -04: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 v1.1.0
------ ------
* Ensure fortune is installed
* Updated docker-compose
* Added Changelog * Added Changelog
* Fixed issue when RX ack * Fixed issue when RX ack
* Updated the aprsd-slack-plugin required version * Updated the aprsd-slack-plugin required version

View File

@ -6,7 +6,7 @@ ENV HOME=/home/aprs
ENV VIRTUAL_ENV=$HOME/.venv3 ENV VIRTUAL_ENV=$HOME/.venv3
ENV INSTALL=$HOME/install 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 # Setup Timezone
ENV TZ=US/Eastern ENV TZ=US/Eastern

View File

@ -10,7 +10,7 @@ ENV APRSD_BRANCH="master"
ENV VIRTUAL_ENV=$HOME/.venv3 ENV VIRTUAL_ENV=$HOME/.venv3
ENV INSTALL=$HOME/install 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 # Setup Timezone
ENV TZ=US/Eastern ENV TZ=US/Eastern
@ -19,7 +19,6 @@ ENV TZ=US/Eastern
#RUN dpkg-reconfigure --frontend noninteractive tzdata #RUN dpkg-reconfigure --frontend noninteractive tzdata
RUN addgroup --gid 1001 $APRS_USER RUN addgroup --gid 1001 $APRS_USER
RUN adduser --help
RUN adduser -h $HOME -D -u 1001 -G $APRS_USER $APRS_USER RUN adduser -h $HOME -D -u 1001 -G $APRS_USER $APRS_USER
ENV LC_ALL=C.UTF-8 ENV LC_ALL=C.UTF-8

View File

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