Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions meshchat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
Copyright (C) 2022 Tim Wilkinson
Base on code (C) Trevor Paskett (see https://github.com/tpaskett)
Base on code (C) Trevor Paskett (see https://github.com/tpaskett)
See Contributors file for additional contributors

This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -701,7 +701,7 @@ function hosts()

local node = node_name()
local hosts = {}
for line in io.lines("/var/dhcp.leases")
for line in io.lines("/tmp/dhcp.leases")
do
local epoch, mac1, ip, hostname, mac2 = line:match("^(%S+)%s(%S+)%s(%S+)%s(%S+)%s(%S+)$")
hosts[#hosts + 1] = {
Expand Down Expand Up @@ -752,7 +752,7 @@ function hosts_raw()
print("\r")

local hosts = {}
for line in io.lines("/var/dhcp.leases")
for line in io.lines("/tmp/dhcp.leases")
do
local epoch, mac1, ip, hostname, mac2 = line:match("^(%S+)%s(%S+)%s(%S+)%s(%S+)%s(%S+)$")
hosts[#hosts + 1] = {
Expand Down
22 changes: 6 additions & 16 deletions meshchatlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,12 @@ end
-- @treturn string Name of MeshChat zone
--
function zone_name()
local dmz_mode = uci.cursor("/etc/config.mesh"):get("aredn", "@dmz[0]", "mode")
local servfile = "/etc/config.mesh/_setup.services.nat"
-- LAN mode is not set to NAT
if dmz_mode ~= "0" then
servfile = "/etc/config.mesh/_setup.services.dmz"
end
if nixio.fs.access(servfile) then
for line in io.lines(servfile)
do
-- this will match the new service names with the icon metadata
-- in this case we are using a space or a pipe to terminate
-- the service name
local zone = line:match("^(.-)[%s%|].*|meshchat$")
if zone then
return zone
end
local services = uci.cursor("/etc/config.mesh"):get("setup", "services", "service") or {}
for _, service in ipairs(services)
do
local zone = service:match("^(.*)%s+%[.+%]|.*|.*|.*|.*|meshchat$") or service:match("^(.*)|.*|.*|.*|.*|meshchat$")
if zone then
return zone
end
end
return "MeshChat"
Expand Down
2 changes: 1 addition & 1 deletion package/meshchat-api/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: meshchat-api
Version:
Depends: lua
Depends: lua, luci-lib-base
Provides:
Source: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
Section: net
Expand Down
2 changes: 1 addition & 1 deletion package/meshchat/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: meshchat
Version:
Depends: curl lua
Depends: curl, lua, luci-lib-base
Provides:
Source: package/meshchat
Section: net
Expand Down
36 changes: 8 additions & 28 deletions package/meshchat/postinst
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
#!/bin/sh

grep "|8080|meshchat" /etc/config.mesh/_setup.services.dmz &> /dev/null
DMZPRESENT=$?
grep "|8080|meshchat" /etc/config.mesh/_setup.services.nat &> /dev/null
NATPRESENT=$?
NODEMODE=$(uci -q -c /etc/local/uci/ get hsmmmesh.settings.config)
RAND=$(awk 'BEGIN{srand();print int(rand()*10000) }')
RESTART=0
uci -c /etc/config.mesh show setup.services | grep "|8080|meshchat" &> /dev/null
PRESENT=$?

if [ "$DMZPRESENT" != 0 ]; then
echo "MeshChat-$RAND|1|http|$(uname -n)|8080|meshchat" >> /etc/config.mesh/_setup.services.dmz
RESTART=1
if [ "$PRESENT" != 0 ]; then
RAND=$(awk 'BEGIN{srand();print int(rand()*10000) }')
uci -c /etc/config.mesh add_list setup.services.service="MeshChat-$RAND [chat]|1|http|$(uname -n)|8080|meshchat"
uci -c /etc/config.mesh commit setup
fi

if [ "$NATPRESENT" != 0 ]; then
echo "MeshChat-$RAND|1|http|$(uname -n)|8080|meshchat" >> /etc/config.mesh/_setup.services.nat
RESTART=1
fi

if [ "$NODEMODE" = "mesh" -a "$RESTART" = "1" ]; then
echo "Applying service announcement"
/usr/local/bin/node-setup -a -p mesh &> /dev/null
/etc/init.d/olsrd restart &> /dev/null
fi
/usr/local/bin/node-setup &> /dev/null
/usr/local/bin/restart-services.sh &> /dev/null

/etc/init.d/meshchatsync enable
/etc/init.d/meshchatsync start

echo "<br>"

echo "Mesh Chat has been setup at http://$(uname -n):8080/meshchat"
echo "<br>"
if [ "$RESTART" = "1" ]; then
echo "An advertised service has been added for Mesh Chat on the Services configuration page"
fi

exit 0