mirror of
https://github.com/Mo3he/Axis_Cam_Tailscale.git
synced 2026-08-17 04:36:50 +00:00
chore(acap3): add remaining app source files (Makefile, launcher.c, package.conf)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2020 Tailscale & AUTHORS.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1 @@
|
||||
nop:
|
||||
@@ -0,0 +1,67 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
* ACAP 3 supervisor launcher for Tailscale_VPN.
|
||||
*
|
||||
* elflibcheck.sh requires APPNAME to be an ELF binary.
|
||||
* acap-startstop / respawnd / list.cgi all use pidof(APPNAME) for status.
|
||||
*
|
||||
* This binary NEVER exits voluntarily — it loops restarting start.sh if it
|
||||
* dies, so:
|
||||
* - pidof Tailscale_VPN always finds this process → UI shows "Running"
|
||||
* - respawnd never triggers (it only fires when APPNAME exits)
|
||||
* - If tailscaled OOMs and start.sh exits, we cleanly restart it
|
||||
*
|
||||
* To stop the app, acap-startstop calls stop_daemon which sends SIGTERM here.
|
||||
* We forward SIGTERM/SIGINT to the child and then exit.
|
||||
*/
|
||||
|
||||
static volatile int g_stop = 0;
|
||||
static volatile pid_t g_child = -1;
|
||||
|
||||
static void sig_forward(int sig) {
|
||||
g_stop = 1;
|
||||
if (g_child > 0)
|
||||
kill(g_child, sig);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
signal(SIGTERM, sig_forward);
|
||||
signal(SIGINT, sig_forward);
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
|
||||
while (!g_stop) {
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
/* child: reset signals and exec start.sh */
|
||||
signal(SIGTERM, SIG_DFL);
|
||||
signal(SIGINT, SIG_DFL);
|
||||
execl("/usr/local/packages/Tailscale_VPN/start.sh",
|
||||
"/usr/local/packages/Tailscale_VPN/start.sh", (char *)0);
|
||||
_exit(127);
|
||||
}
|
||||
if (pid < 0) {
|
||||
sleep(5);
|
||||
continue;
|
||||
}
|
||||
g_child = pid;
|
||||
|
||||
int status;
|
||||
pid_t ret;
|
||||
do {
|
||||
ret = waitpid(pid, &status, 0);
|
||||
} while (ret == -1 && errno == EINTR && !g_stop);
|
||||
|
||||
g_child = -1;
|
||||
|
||||
if (!g_stop) {
|
||||
/* start.sh died unexpectedly — wait before restarting */
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
PACKAGENAME=Tailscale_VPN
|
||||
MENUNAME="Tailscale VPN"
|
||||
VENDOR="Mo3he"
|
||||
APPMAJORVERSION=1
|
||||
APPMINORVERSION=96
|
||||
APPMICROVERSION=4
|
||||
APPTYPE=armv7hf
|
||||
APPNAME=Tailscale_VPN
|
||||
APPOPTS=""
|
||||
STARTMODE=respawn
|
||||
OTHERFILES="lib html index.html LICENSE start.sh"
|
||||
SETTINGSPAGEFILE=index.html
|
||||
GRPNAME=
|
||||
USERNAME=root
|
||||
Reference in New Issue
Block a user