Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ampledata committed Jun 19, 2024
1 parent 916351f commit 808a5d2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
59 changes: 56 additions & 3 deletions debian/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,65 @@

echo "adsbxfeed postinst"

UUID_FILE="/etc/AryaOS/UUID.txt"
# shellcheck source=SCRIPTDIR/../etc/AryaOS/adsbxfeed.conf
[ -f "/etc/Aryaos/adsbxfeed.conf" ] && . /etc/Aryaos/adsbxfeed.conf

if [ ! -f $UUID_FILE ]; then
[ -z "$UUID_FILE" ] && UUID_FILE="/etc/AryaOS/UUID.txt"

if [ ! -f "$UUID_FILE" ]; then
mkdir -p /etc/AryaOS
echo "$UUID_FILE doesn't exist, initializing."
uuidgen > $UUID_FILE
uuidgen > "$UUID_FILE"
fi

# Sane defaults:

[ -z "$SERVER_HOME" ] && SERVER_HOME=/run/adsbxfeed
[ -z "$SERVER_USER" ] && SERVER_USER=adsbxfeed
[ -z "$SERVER_NAME" ] && SERVER_NAME="ADSBExchange.com ADS-B Feed System User"
[ -z "$SERVER_GROUP" ] && SERVER_GROUP=adsbxfeed

# Groups that the user will be added to, if undefined, then none.
ADDGROUP=""

# create user to avoid running server as root
# 1. create group if not existing
if ! getent group | grep -q "^$SERVER_GROUP:" ; then
echo -n "Adding group $SERVER_GROUP.."
addgroup --quiet --system "$SERVER_GROUP" 2>/dev/null ||true
echo "..done"
fi
# 2. create homedir if not existing
test -d "$SERVER_HOME" || mkdir "$SERVER_HOME"
# 3. create user if not existing
if ! getent passwd | grep -q "^$SERVER_USER:"; then
echo -n "Adding system user $SERVER_USER.."
adduser --quiet \
--system \
--ingroup "$SERVER_GROUP" \
--no-create-home \
--disabled-password \
"$SERVER_USER" 2>/dev/null || true
echo "..done"
fi
# 4. adjust passwd entry
usermod -c "$SERVER_NAME" \
-d "$SERVER_HOME" \
-g "$SERVER_GROUP" \
"$SERVER_USER"
# 5. adjust file and directory permissions
if ! dpkg-statoverride --list "$SERVER_HOME" >/dev/null
then
chown -R "$SERVER_USER":adm "$SERVER_HOME"
chmod u=rwx,g=rxs,o= "$SERVER_HOME"
fi
# 6. Add the user to the ADDGROUP group
if test -n "$ADDGROUP"
then
if ! groups "$SERVER_USER" | cut -d: -f2 | \
grep -qw "$ADDGROUP"; then
adduser "$SERVER_USER" "$ADDGROUP"
fi
fi

systemctl enable adsbxfeed
Expand Down
2 changes: 2 additions & 0 deletions debian/DEBIAN/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ echo "adsbxfeed prerm"
systemctl disable adsbxfeed
systemctl stop adsbxfeed

deluser --system adsbxfeed

exit 0
3 changes: 2 additions & 1 deletion debian/etc/AryaOS/adsbxfeed.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# limitations under the License.
#

RUN_DIR="/run/adsbxfeed"
ENABLE=1
UUID_FILE="/etc/AryaOS/UUID.txt"
RUN_DIR="/run/adsbxfeed"

INPUT="127.0.0.1:30005"
REDUCE_INTERVAL="0.5"
Expand Down
11 changes: 2 additions & 9 deletions debian/usr/bin/adsbxfeed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@
# limitations under the License.
#

CONF_FILE="/etc/AryaOS/adsbxfeed.conf"

if [ -f $CONF_FILE ]; then
# shellcheck source=SCRIPTDIR/../../etc/AryaOS/adsbxfeed.conf
. $CONF_FILE
else
echo "$CONF_FILE doesn't exist, exiting."
exit 1
fi
# shellcheck source=SCRIPTDIR/../..//etc/AryaOS/adsbxfeed.conf
[ -f "/etc/Aryaos/adsbxfeed.conf" ] && . /etc/Aryaos/adsbxfeed.conf

if ! [[ -d $RUN_DIR ]]; then
mkdir -p "$RUN_DIR"
Expand Down

0 comments on commit 808a5d2

Please sign in to comment.