Skip to content

Commit

Permalink
Divide debian and openwrt package metadata files
Browse files Browse the repository at this point in the history
Signed-off-by: Gerard Hickey <[email protected]>
  • Loading branch information
hickey committed Apr 6, 2024
1 parent 97613ed commit af1b402
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 33 deletions.
10 changes: 10 additions & 0 deletions package/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: meshchat
Version:
Depends: lua5.4
Provides:
Source: package/meshchat
Section: net
Priority: optional
Maintainer: Gerard Hickey <[email protected]>
Architecture: all
Description: P2P distributed chat for mesh networks
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions package/meshchat-api/control

This file was deleted.

2 changes: 1 addition & 1 deletion package/meshchat/control → package/openwrt/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Provides:
Source: package/meshchat
Section: net
Priority: optional
Maintainer: Tim Wilkinson (KN6PLV) and Trevor Paskett (K7FPV)
Maintainer: Gerard Hickey <[email protected]>
Architecture: all
Description: P2P distributed chat for mesh networks
38 changes: 38 additions & 0 deletions package/openwrt/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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

if [ "$DMZPRESENT" != 0 ]; then
echo "MeshChat-$RAND|1|http|$(uname -n)|8080|meshchat" >> /etc/config.mesh/_setup.services.dmz
RESTART=1
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

/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
19 changes: 19 additions & 0 deletions package/openwrt/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

/etc/init.d/meshchatsync stop > /dev/null 2> /dev/null

mkdir -p /www/meshchat

# if there is not a meshchat_local.lua, then prepare one
if [ ! -f /www/cgi-bin/meshchat_local.lua ]; then
if [ -f /www/cgi-bin/meshchatconfig.lua ]; then
cp /www/cgi-bin/meshchatconfig.lua /www/cgi-bin/meshchat_local.lua

# remove vars that should not be in meshchat_local.lua
sed -i "/^protocol_version/d; /^app_version/d" /www/cgi-bin/meshchat_local.lua
else
touch /www/cgi-bin/meshchat_local.lua
fi
fi

exit 0
8 changes: 8 additions & 0 deletions package/openwrt/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

/etc/init.d/meshchatsync disable
/etc/init.d/meshchatsync stop

rm -rf /tmp/meshchat

exit 0
15 changes: 0 additions & 15 deletions package/populate-meshchat-api-fs.sh

This file was deleted.

19 changes: 12 additions & 7 deletions package/populate-meshchat-fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
IPK_DIR=$1
OSNAME=$2

# Populate the CONTROL portion of the package
mkdir -p $IPK_DIR/CONTROL
cp -p package/meshchat/* $IPK_DIR/CONTROL/
sed -i "s%\$GITHUB_SERVER_URL%$GITHUB_SERVER_URL%" $IPK_DIR/CONTROL/control
sed -i "s%\$GITHUB_REPOSITORY%$GITHUB_REPOSITORY%" $IPK_DIR/CONTROL/control

# Populate the filesystem image for the package
if [[ "$OSNAME" == "debian" ]]; then
install -d $IPK_DIR/DEBIAN
install -m 644 package/meshchat/* $IPK_DIR/DEBIAN
# Populate the CONTROL portion of the package
mkdir -p $IPK_DIR/CONTROL
cp -p package/debian/* $IPK_DIR/CONTROL/
sed -i "s%\$GITHUB_SERVER_URL%$GITHUB_SERVER_URL%" $IPK_DIR/CONTROL/control
sed -i "s%\$GITHUB_REPOSITORY%$GITHUB_REPOSITORY%" $IPK_DIR/CONTROL/control

install -d $IPK_DIR/var/www/html/meshchat
install www/* $IPK_DIR/var/www/html/meshchat
install -d $IPK_DIR/usr/lib/cgi-bin
Expand All @@ -27,6 +26,12 @@ if [[ "$OSNAME" == "debian" ]]; then
install -d $IPK_DIR/usr/local/lib/lua/5.4/net
install -m 644 lib/json.lua $IPK_DIR/usr/local/lib/lua/5.4/net
elif [[ "$OSNAME" == "openwrt" ]]; then
# Populate the CONTROL portion of the package
mkdir -p $IPK_DIR/CONTROL
cp -p package/openwrt/* $IPK_DIR/CONTROL/
sed -i "s%\$GITHUB_SERVER_URL%$GITHUB_SERVER_URL%" $IPK_DIR/CONTROL/control
sed -i "s%\$GITHUB_REPOSITORY%$GITHUB_REPOSITORY%" $IPK_DIR/CONTROL/control

install -d $IPK_DIR/www/meshchat
install www/* $IPK_DIR/www/meshchat
install -d $IPK_DIR/www/cgi-bin
Expand Down

0 comments on commit af1b402

Please sign in to comment.