From f5bc70be3aa5339165dedc4d1d1a12e9c3264cb1 Mon Sep 17 00:00:00 2001 From: oycol Date: Sat, 6 Nov 2021 05:03:09 +0800 Subject: [PATCH] openwrt: mipsle build and service --- .github/workflows/buildandrelease.yml | 11 ++++++++ scripts/openwrt-daemon.sh | 36 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 scripts/openwrt-daemon.sh diff --git a/.github/workflows/buildandrelease.yml b/.github/workflows/buildandrelease.yml index bed20157..2fe5ffe0 100644 --- a/.github/workflows/buildandrelease.yml +++ b/.github/workflows/buildandrelease.yml @@ -39,6 +39,7 @@ jobs: env GOOS=linux GOARCH=arm GOARM=6 go build -o build/netclient-arm6/netclient main.go env GOOS=linux GOARCH=arm GOARM=7 go build -o build/netclient-arm7/netclient main.go env GOOS=linux GOARCH=arm64 go build -o build/netclient-arm64/netclient main.go + env GOOS=linux GOARCH=mipsle go build -ldflags "-s -w" -o build/netclient-mipsle/netclient main.go && upx build/netclient-mipsle/netclient - name: Upload x86 to Release uses: svenstaro/upload-release-action@v2 @@ -89,3 +90,13 @@ jobs: overwrite: true prerelease: true asset_name: netclient-arm64 + + - name: Upload mipsle to Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: netclient/build/netclient-mipsle/netclient + tag: ${{ env.NETMAKER_VERSION }} + overwrite: true + prerelease: true + asset_name: netclient-mipsle diff --git a/scripts/openwrt-daemon.sh b/scripts/openwrt-daemon.sh new file mode 100644 index 00000000..7f9b3f71 --- /dev/null +++ b/scripts/openwrt-daemon.sh @@ -0,0 +1,36 @@ +#!/bin/bash /etc/rc.common +# Copyright (C) 2007 OpenWrt.org +EXTRA_COMMANDS="status" +EXTRA_HELP=" status Check service is running" +START=99 + + +LOG_FILE="/tmp/netclient.logs" + +start() { + local PIDS=($(ps -ef|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')) + if [ $PIDS ];then + echo "service is running" + return + fi + bash -c "while [ 1 ]; do /etc/netclient/netclient checkin -n all >> $LOG_FILE 2>&1;sleep 15;\ + if [ $(ls -l $LOG_FILE|awk '{print $5}') -gt 10240000 ];then tar zcf "${LOG_FILE}.tar" -C / "tmp/netclient.logs" && > $LOG_FILE;fi;done &" + echo "start" +} + +stop() { + local PIDS=($(ps -ef|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')) + for i in "${PIDS[@]}"; do + kill $i + done + echo "stop" +} + +status() { + local PIDS=($(ps -ef|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')) + if [ $PIDS ];then + echo -e "netclient[$PIDS] is running \n" + else + echo -e "netclient is not running \n" + fi +}