all bullshit OUT
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ serde_json = "1.0.143"
|
||||
serde_with = { version = "3.14.0", features = ["json"] }
|
||||
strum = { version = "0.27.2", features = ["derive", "strum_macros"] }
|
||||
thiserror = "2.0.16"
|
||||
tokio = { version = "1.47.1", features = ["fs", "process", "rt-multi-thread"] }
|
||||
tokio = { version = "1.47.1", features = ["fs", "process", "rt-multi-thread", "io-util"] }
|
||||
urlencoding = "2.1.3"
|
||||
|
||||
[profile.release]
|
||||
|
||||
+3
-3
@@ -12,14 +12,14 @@ fi
|
||||
[ -n "$pids" ] || exit 0
|
||||
|
||||
# Send TERM first
|
||||
kill -TERM $pids 2>/dev/null || true
|
||||
kill -TERM "$pids" 2>/dev/null || true
|
||||
|
||||
# Optional: hard kill if still alive after a short grace
|
||||
sleep 0.2
|
||||
sleep 1 # uhhh sleep is stupid
|
||||
remain=""
|
||||
for p in $pids; do
|
||||
kill -0 "$p" 2>/dev/null && remain="$remain $p"
|
||||
done
|
||||
[ -z "$remain" ] || kill -KILL $remain 2>/dev/null || true
|
||||
[ -z "$remain" ] || kill -KILL "$remain" 2>/dev/null || true
|
||||
|
||||
exit 0
|
||||
@@ -45,7 +45,6 @@ fetch() {
|
||||
if command -v uclient-fetch >/dev/null 2>&1; then
|
||||
uclient-fetch -O "$2" "$1" || return 1
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
# shellcheck disable=SC2086
|
||||
wget ${WAKEY_INSECURE:+--no-check-certificate} -O "$2" "$1" || return 1
|
||||
elif command -v curl >/dev/null 2>&1; then
|
||||
if [ -n "${WAKEY_INSECURE:-}" ]; then
|
||||
@@ -96,6 +95,7 @@ main() {
|
||||
|
||||
if [ -f /etc/init.d/wakey ]; then
|
||||
chmod +x /etc/init.d/wakey || true
|
||||
chmod +x /etc/init.d/kill_wakey.sh || true
|
||||
/etc/init.d/wakey enable || true
|
||||
/etc/init.d/wakey restart || /etc/init.d/wakey start || true
|
||||
fi
|
||||
|
||||
@@ -29,6 +29,7 @@ New-Item -ItemType Directory -Force -Path $rootDir | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $etcDir | Out-Null
|
||||
|
||||
Copy-Item $binSrc (Join-Path $rootDir "wakey") -Force
|
||||
Copy-Item (Join-Path $root 'scripts/kill.sh') (Join-Path $rootDir "kill_wakey.sh") -Force
|
||||
|
||||
# Copy all OpenWrt init scripts present in repo
|
||||
Get-ChildItem (Join-Path $root 'scripts/init/openwrt') -File | ForEach-Object {
|
||||
@@ -65,3 +66,4 @@ Write-Host "Rootfs package: " (Join-Path $dist $pkgName)
|
||||
Write-Host "On router: wget -O- <URL/$pkgName> | tar -xz -C /"
|
||||
Write-Host "Then: chmod +x /etc/init.d/wakey && /etc/init.d/wakey enable && /etc/init.d/wakey start"
|
||||
Write-Host "Helper scripts: /etc/ldlda_help/* (e.g., update_wakey.sh, update_tailscale.sh). Mark executable if needed: chmod +x /etc/ldlda_help/*.sh"
|
||||
Write-Host "Kill helper: /root/.bin/kill_wakey.sh (make it executable: chmod +x /root/.bin/kill_wakey.sh)"
|
||||
|
||||
+9
-6
@@ -1,7 +1,7 @@
|
||||
use std::{fs::read_to_string, io, net::IpAddr};
|
||||
|
||||
use macaddr::MacAddr;
|
||||
use serde::Serializer;
|
||||
use std::io::{self, ErrorKind};
|
||||
use std::net::IpAddr;
|
||||
|
||||
/// A single line from /tmp/dhcp.leases
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
@@ -34,8 +34,11 @@ pub fn parse_dhcp_lease_line(line: &str) -> Option<DhcpLeaseLine> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Read all leases from /tmp/dhcp.leases
|
||||
pub fn read_dhcp_leases() -> io::Result<Vec<DhcpLeaseLine>> {
|
||||
let file = read_to_string("/tmp/dhcp.leases")?;
|
||||
Ok(file.lines().flat_map(parse_dhcp_lease_line).collect())
|
||||
/// Read all leases from /tmp/dhcp.leases (simple and fast)
|
||||
pub async fn read_dhcp_leases() -> io::Result<Vec<DhcpLeaseLine>> {
|
||||
match tokio::fs::read_to_string("/tmp/dhcp.leases").await {
|
||||
Ok(file) => Ok(file.lines().filter_map(parse_dhcp_lease_line).collect()),
|
||||
Err(e) if e.kind() == ErrorKind::NotFound => Ok(Vec::new()),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ pub fn home_2_route() -> Router {
|
||||
.route("/home_2.js", get(home_2_js)) //js
|
||||
}
|
||||
|
||||
|
||||
pub async fn wake_handler(
|
||||
Query(DeviceQuery { name, .. }): Query<DeviceQuery>,
|
||||
) -> axum::response::Result<impl IntoResponse> {
|
||||
@@ -60,7 +59,6 @@ pub async fn wake_handler(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub async fn _get_status_2(q: Query<DeviceQuery>) -> Html<String> {
|
||||
let name = match q {
|
||||
Query(DeviceQuery {
|
||||
@@ -96,5 +94,3 @@ pub async fn _home() -> Html<String> {
|
||||
// }
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-11
@@ -55,9 +55,9 @@ pub async fn devs_router() -> Json<Vec<String>> {
|
||||
}
|
||||
|
||||
async fn get_dhcp_leases() -> impl IntoResponse {
|
||||
match tokio::task::spawn_blocking(dhcpparse::read_dhcp_leases).await {
|
||||
Ok(Ok(leases)) => (StatusCode::OK, Json(leases)).into_response(),
|
||||
Ok(Err(e)) => (
|
||||
match dhcpparse::read_dhcp_leases().await {
|
||||
Ok(leases) => (StatusCode::OK, Json(leases)).into_response(),
|
||||
Err(e) => (
|
||||
StatusCode::BAD_GATEWAY,
|
||||
Json(StatusError {
|
||||
name: None,
|
||||
@@ -65,14 +65,6 @@ async fn get_dhcp_leases() -> impl IntoResponse {
|
||||
}),
|
||||
)
|
||||
.into_response(),
|
||||
Err(join_err) => (
|
||||
StatusCode::BAD_GATEWAY,
|
||||
Json(StatusError {
|
||||
name: None,
|
||||
error: join_err.to_string(),
|
||||
}),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user