diff --git a/.github/workflows/workflow-meshchat-debian-package.yaml b/.github/workflows/workflow-meshchat-debian-package.yaml index 13a0f89..381c6ae 100644 --- a/.github/workflows/workflow-meshchat-debian-package.yaml +++ b/.github/workflows/workflow-meshchat-debian-package.yaml @@ -32,9 +32,9 @@ jobs: - run: package/update-version.sh ${{ inputs.build_dir }} # - run: info "Packing up MeshChat files" - run: dpkg-deb --root-owner-group --build ${{ inputs.build_dir }} - - run: mv meshchat-deb.deb meshchat_${{ inputs.build_version }}_all.deb + - run: mv package/meshchat-deb.deb package/meshchat_${{ inputs.build_version }}_all.deb - id: detect-package-file - run: echo "file=meshchat_${{inputs.build_version }}_all.deb" >> $GITHUB_OUTPUT + run: echo "file=package/meshchat_${{inputs.build_version }}_all.deb" >> $GITHUB_OUTPUT - run: echo "${{ steps.detect-package-file.outputs.file }}" - uses: actions/upload-artifact@v4 with: diff --git a/package/debian/control b/package/debian/control new file mode 100644 index 0000000..27438a1 --- /dev/null +++ b/package/debian/control @@ -0,0 +1,10 @@ +Package: meshchat +Version: +Depends: lua5.4 +Provides: +Source: package/meshchat +Section: net +Priority: optional +Maintainer: Gerard Hickey +Architecture: all +Description: P2P distributed chat for mesh networks diff --git a/package/meshchat/postinst b/package/debian/postinst similarity index 100% rename from package/meshchat/postinst rename to package/debian/postinst diff --git a/package/meshchat/preinst b/package/debian/preinst similarity index 100% rename from package/meshchat/preinst rename to package/debian/preinst diff --git a/package/meshchat/prerm b/package/debian/prerm similarity index 100% rename from package/meshchat/prerm rename to package/debian/prerm diff --git a/package/meshchat-api/control b/package/meshchat-api/control deleted file mode 100755 index 0761bf2..0000000 --- a/package/meshchat-api/control +++ /dev/null @@ -1,10 +0,0 @@ -Package: meshchat-api -Version: -Depends: lua -Provides: -Source: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -Section: net -Priority: optional -Maintainer: Tim Wilkinson (KN6PLV) and Trevor Paskett (K7FPV) -Architecture: all -Description: P2P distributed chat for mesh networks diff --git a/package/meshchat/control b/package/openwrt/control similarity index 74% rename from package/meshchat/control rename to package/openwrt/control index d78266e..0791ad5 100644 --- a/package/meshchat/control +++ b/package/openwrt/control @@ -5,6 +5,6 @@ Provides: Source: package/meshchat Section: net Priority: optional -Maintainer: Tim Wilkinson (KN6PLV) and Trevor Paskett (K7FPV) +Maintainer: Gerard Hickey Architecture: all Description: P2P distributed chat for mesh networks diff --git a/package/openwrt/postinst b/package/openwrt/postinst new file mode 100755 index 0000000..67004c2 --- /dev/null +++ b/package/openwrt/postinst @@ -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 "
" + +echo "Mesh Chat has been setup at http://$(uname -n):8080/meshchat" +echo "
" +if [ "$RESTART" = "1" ]; then + echo "An advertised service has been added for Mesh Chat on the Services configuration page" +fi + +exit 0 diff --git a/package/openwrt/preinst b/package/openwrt/preinst new file mode 100755 index 0000000..9864975 --- /dev/null +++ b/package/openwrt/preinst @@ -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 diff --git a/package/openwrt/prerm b/package/openwrt/prerm new file mode 100755 index 0000000..eb6c0f7 --- /dev/null +++ b/package/openwrt/prerm @@ -0,0 +1,8 @@ +#!/bin/sh + +/etc/init.d/meshchatsync disable +/etc/init.d/meshchatsync stop + +rm -rf /tmp/meshchat + +exit 0 diff --git a/package/populate-meshchat-api-fs.sh b/package/populate-meshchat-api-fs.sh deleted file mode 100755 index f68f50a..0000000 --- a/package/populate-meshchat-api-fs.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# This script runs from the top of the project directory and -# creates the filesystem image for the MeshChat API package. - -IPK_DIR=$1 - -# Populate the CONTROL portion of the package -mkdir -p $IPK_DIR/CONTROL -cp -p package/meshchat-api/* $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 -install -D api/meshchat -m 755 $IPK_DIR/www/cgi-bin/meshchat diff --git a/package/populate-meshchat-fs.sh b/package/populate-meshchat-fs.sh index 6f98c85..5d5d177 100755 --- a/package/populate-meshchat-fs.sh +++ b/package/populate-meshchat-fs.sh @@ -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/DEBIAN + cp -p package/debian/* $IPK_DIR/DEBIAN/ + sed -i "s%\$GITHUB_SERVER_URL%$GITHUB_SERVER_URL%" $IPK_DIR/DEBIAN/control + sed -i "s%\$GITHUB_REPOSITORY%$GITHUB_REPOSITORY%" $IPK_DIR/DEBIAN/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 @@ -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