Merge ahh force (ahhhhh)

This commit is contained in:
lda
2025-08-31 07:05:37 +07:00 Unverified
12 changed files with 66 additions and 52 deletions
Generated
+1 -1
View File
@@ -1179,7 +1179,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]] [[package]]
name = "wakey" name = "wakey"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"axum", "axum",
"axum-extra", "axum-extra",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "wakey" name = "wakey"
version = "0.1.1" version = "0.1.2"
edition = "2024" edition = "2024"
publish = ["gitea"] publish = ["gitea"]
+1 -1
View File
@@ -54,7 +54,7 @@ This folder has small helpers for build, CI, and router install. Keep it simple;
## Local build/install (manual path) ## Local build/install (manual path)
```powershell ```powershell
# Build # Build
cargo build --release --target armv7-unknown-linux-musleabihf cargo build --release --target armv7-unknown-linux-musleabihf
# Package rootfs # Package rootfs
+19 -13
View File
@@ -7,19 +7,25 @@
# Default-Stop: # Default-Stop:
# Short-Description: Pre-flight Tailscale update # Short-Description: Pre-flight Tailscale update
START=50 # Run before Tailscale (typically START~80) START=50 # Run before Tailscale (typically START~80)
USE_PROCD=1
start_service() { start() {
procd_open_instance LOGFILE=/var/log/update_tailscale.log
procd_set_param command /bin/sh -c \ MAX_RETRIES=10
'while ! /etc/ldlda_help/update_tailscale.sh; do sleep 5; done' RETRY_COUNT=0
# procd_set_param respawn 0 0 0
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
stop_service() { # shellcheck disable=SC2016
: # one-shot nohup sh -c '
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
if fn; then
echo "[update_tailscale] Success at $(date)" >>"$LOGFILE"
exit 0
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
echo "[update_tailscale] Retry $RETRY_COUNT at $(date)" >>"$LOGFILE"
sleep 5
done
echo "[update_tailscale] Too many retries. Exiting at $(date)" >>"$LOGFILE"
exit 1
' >>"$LOGFILE" 2>&1 &
} }
+18 -20
View File
@@ -1,25 +1,23 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
START=66 START=66
USE_PROCD=1
# reboot == new file. start() {
FLAG=/var/wakey_updated.flag LOGFILE=/var/log/update_wakey.log
MAX_RETRIES=10
RETRY_COUNT=0
start_service() { # shellcheck disable=SC2016
[ -f "$FLAG" ] && return nohup sh -c '
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
procd_open_instance if /etc/ldlda_help/update_wakey.sh; then
procd_set_param command /bin/sh -c \ echo "[update_wakey] Success at $(date)" >>"$LOGFILE"
'while ! /etc/ldlda_help/update_wakey.sh; do sleep 5; done' exit 0
procd_set_param stdout 1 fi
procd_set_param stderr 1 RETRY_COUNT=$((RETRY_COUNT + 1))
procd_close_instance echo "[update_wakey] Retry $RETRY_COUNT at $(date)" >>"$LOGFILE"
} sleep 5
done
stop_service() { echo "[update_wakey] Too many retries. Exiting at $(date)" >>"$LOGFILE"
: # no-op exit 1
} ' >>"$LOGFILE" 2>&1 &
post_service() {
touch "$FLAG"
} }
+1 -1
View File
@@ -22,4 +22,4 @@ for p in $pids; do
done done
[ -z "$remain" ] || kill -KILL "$remain" 2>/dev/null || true [ -z "$remain" ] || kill -KILL "$remain" 2>/dev/null || true
exit 0 exit 0
+5 -1
View File
@@ -8,6 +8,11 @@ elif [ -f /rom/etc/resolv.conf ]; then
cp -af /rom/etc/resolv.conf /etc/resolv.conf cp -af /rom/etc/resolv.conf /etc/resolv.conf
fi fi
if [ -x "$(which tailscale)" ]; then
tailscale update
exit 0
fi
# 1. Fetch the latest version number from Tailscale's site # 1. Fetch the latest version number from Tailscale's site
LATEST=$(curl -s https://pkgs.tailscale.com/stable/ | grep -Eo 'tailscale_[0-9\.]+_arm.tgz' | head -n1) LATEST=$(curl -s https://pkgs.tailscale.com/stable/ | grep -Eo 'tailscale_[0-9\.]+_arm.tgz' | head -n1)
@@ -20,7 +25,6 @@ URL="https://pkgs.tailscale.com/stable/${LATEST}"
cd /var/tmp cd /var/tmp
if [ -f "$LATEST" ]; then if [ -f "$LATEST" ]; then
echo "file exists" echo "file exists"
rm "$LATEST" rm "$LATEST"
+13 -6
View File
@@ -15,13 +15,18 @@
set -eu set -eu
# reboot == new file.
FLAG=/var/wakey_updated.flag
ARCH=${WAKEY_ARCH:-armv7-unknown-linux-musleabihf} ARCH=${WAKEY_ARCH:-armv7-unknown-linux-musleabihf}
TMPDIR="/var/tmp" TMPDIR="/var/tmp"
TMPFILE="$TMPDIR/wakey-rootfs.$$.$ARCH.tgz" TMPFILE="$TMPDIR/wakey-rootfs.$$.$ARCH.tgz"
STAGING="$TMPDIR/wakey-rootfs.$$.$ARCH" STAGING="$TMPDIR/wakey-rootfs.$$.$ARCH"
log() { echo "[update_wakey] $*"; } log() { echo "[update_wakey] $*"; }
fail() { echo "[update_wakey] ERROR: $*" >&2; exit 1; } fail() {
echo "[update_wakey] ERROR: $*" >&2
exit 1
}
http_get() { http_get() {
# http_get <url> # http_get <url>
@@ -65,13 +70,14 @@ latest_asset_url() {
API="https://$HOST/api/v1/repos/$OWNER/$REPO/releases/latest" API="https://$HOST/api/v1/repos/$OWNER/$REPO/releases/latest"
RESP=$(http_get "$API") || return 1 RESP=$(http_get "$API") || return 1
# Extract the first browser_download_url ending with our ARCH .tgz (BusyBox-friendly) # Extract the first browser_download_url ending with our ARCH .tgz (BusyBox-friendly)
echo "$RESP" \ echo "$RESP" |
| grep -o '"browser_download_url"[[:space:]]*:[[:space:]]*"[^"]*'"$ARCH"'\.tgz"' \ grep -o '"browser_download_url"[[:space:]]*:[[:space:]]*"[^"]*'"$ARCH"'\.tgz"' |
| head -n1 \ head -n1 |
| cut -d '"' -f 4 cut -d '"' -f 4
} }
main() { main() {
[ -f "$FLAG" ] && return
URL="${WAKEY_TGZ_URL:-}" URL="${WAKEY_TGZ_URL:-}"
if [ -z "$URL" ]; then if [ -z "$URL" ]; then
HOST=${WAKEY_HOST:-git.ldlda.com} HOST=${WAKEY_HOST:-git.ldlda.com}
@@ -109,7 +115,7 @@ main() {
for f in \ for f in \
"$STAGING/etc/init.d/"* \ "$STAGING/etc/init.d/"* \
"$STAGING/etc/ldlda_help/"*.sh \ "$STAGING/etc/ldlda_help/"*.sh \
"$STAGING/root/.bin/"*.sh ; do "$STAGING/root/.bin/"*.sh; do
[ -f "$f" ] && sed -i 's/\r$//' "$f" 2>/dev/null || true [ -f "$f" ] && sed -i 's/\r$//' "$f" 2>/dev/null || true
done done
@@ -123,6 +129,7 @@ main() {
/etc/init.d/wakey enable || true /etc/init.d/wakey enable || true
/etc/init.d/wakey restart || /etc/init.d/wakey start || true /etc/init.d/wakey restart || /etc/init.d/wakey start || true
fi fi
touch "$FLAG"
log "done" log "done"
} }
+4 -1
View File
@@ -14,7 +14,10 @@ if [ -z "$BIN_TMP" ] || [ -z "$DEST" ]; then
exit 2 exit 2
fi fi
[ -f "$BIN_TMP" ] || { echo "tmp binary not found: $BIN_TMP" >&2; exit 1; } [ -f "$BIN_TMP" ] || {
echo "tmp binary not found: $BIN_TMP" >&2
exit 1
}
chmod +x "$BIN_TMP" || true chmod +x "$BIN_TMP" || true
if [ "$RESTART" = "1" ]; then if [ "$RESTART" = "1" ]; then
-1
View File
@@ -1,4 +1,3 @@
use axum::Json; use axum::Json;
use axum::http::StatusCode; use axum::http::StatusCode;
use axum::response::IntoResponse; use axum::response::IntoResponse;
+2 -2
View File
@@ -1,11 +1,11 @@
use crate::{ use crate::{
arpparse::{NUDState}, arpparse::NUDState,
utils::parse::{de_many, serialize_macs}, utils::parse::{de_many, serialize_macs},
}; };
use axum::{Json, http::StatusCode, response::IntoResponse}; use axum::{Json, http::StatusCode, response::IntoResponse};
use axum_extra::extract::Query; use axum_extra::extract::Query;
use macaddr::MacAddr; use macaddr::MacAddr;
use serde::{Serialize, Deserialize}; use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none; use serde_with::skip_serializing_none;
use std::collections::HashSet; use std::collections::HashSet;
use std::net::IpAddr; use std::net::IpAddr;
+1 -4
View File
@@ -1,9 +1,6 @@
use std::net::IpAddr; use std::net::IpAddr;
use axum::{ use axum::{http::header, response::IntoResponse};
http::header,
response::IntoResponse,
};
use macaddr::MacAddr; use macaddr::MacAddr;
use crate::{arpparse::NUDState, route::DeviceQuery, utils::query::dev::has_dev}; use crate::{arpparse::NUDState, route::DeviceQuery, utils::query::dev::has_dev};