release/dist/qnap: add qnap target builder

Creates new QNAP builder target, which builds go binaries then uses
docker to build into QNAP packages. Much of the docker/script code
here is pulled over from https://github.com/tailscale/tailscale-qpkg,
with adaptation into our builder structures.

The qnap/Tailscale folder contains static resources needed to build
Tailscale qpkg packages, and is an exact copy of the existing folder
in the tailscale-qpkg repo.

Builds can be run with:
```
sudo ./tool/go run ./cmd/dist build qnap
```

Updates tailscale/tailscale-qpkg#135

Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
This commit is contained in:
Sonia Appasamy
2024-04-22 16:42:01 -04:00
committed by Sonia Appasamy
parent b743b85dad
commit 0a84215036
17 changed files with 658 additions and 3 deletions
+50
View File
@@ -0,0 +1,50 @@
#!/bin/sh
CONF=/etc/config/qpkg.conf
QPKG_NAME="Tailscale"
QPKG_ROOT=`/sbin/getcfg ${QPKG_NAME} Install_Path -f ${CONF}`
QPKG_PORT=`/sbin/getcfg ${QPKG_NAME} Service_Port -f ${CONF}`
export QNAP_QPKG=${QPKG_NAME}
set -e
case "$1" in
start)
ENABLED=$(/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f ${CONF})
if [ "${ENABLED}" != "TRUE" ]; then
echo "${QPKG_NAME} is disabled."
exit 1
fi
mkdir -p /home/httpd/cgi-bin/qpkg
ln -sf ${QPKG_ROOT}/ui /home/httpd/cgi-bin/qpkg/${QPKG_NAME}
mkdir -p -m 0755 /tmp/tailscale
if [ -e /tmp/tailscale/tailscaled.pid ]; then
PID=$(cat /tmp/tailscale/tailscaled.pid)
if [ -d /proc/${PID}/ ]; then
echo "${QPKG_NAME} is already running."
exit 0
fi
fi
${QPKG_ROOT}/tailscaled --port ${QPKG_PORT} --statedir=${QPKG_ROOT}/state --socket=/tmp/tailscale/tailscaled.sock 2> /dev/null &
echo $! > /tmp/tailscale/tailscaled.pid
;;
stop)
if [ -e /tmp/tailscale/tailscaled.pid ]; then
PID=$(cat /tmp/tailscale/tailscaled.pid)
kill -9 ${PID} || true
rm -f /tmp/tailscale/tailscaled.pid
fi
;;
restart)
$0 stop
$0 start
;;
remove)
;;
*)
echo "Usage: $0 {start|stop|restart|remove}"
exit 1
esac
exit 0
+2
View File
@@ -0,0 +1,2 @@
Options +ExecCGI
AddHandler cgi-script .cgi
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
CONF=/etc/config/qpkg.conf
QPKG_NAME="Tailscale"
QPKG_ROOT=$(/sbin/getcfg ${QPKG_NAME} Install_Path -f ${CONF} -d"")
exec "${QPKG_ROOT}/tailscale" --socket=/tmp/tailscale/tailscaled.sock web --cgi --prefix="/cgi-bin/qpkg/Tailscale/index.cgi/"