mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 18:33:56 +08:00
update 2026-05-10 09:48:30
This commit is contained in:
1 parent
95ac96413e
commit
0b362674f1
6244 files changed
+2992248
No files matched your search
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
chmod +x /usr/share/rpcd/ucode/luci.ddns-go
|
||||
chown root:www-data /usr/libexec/ddns-go-call
|
||||
chmod 750 /usr/libexec/ddns-go-call
|
||||
rm -f /tmp/luci-indexcache
|
||||
/etc/init.d/rpcd restart
|
||||
exit 0
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
case "$1" in
|
||||
"get_logs")
|
||||
logread -l 200 2>/dev/null | grep ddns-go || echo "No ddns-go logs found"
|
||||
;;
|
||||
"clear_logs")
|
||||
/etc/init.d/log restart >/dev/null 2>&1
|
||||
echo "Logs cleared"
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"admin/services/ddns-go": {
|
||||
"title": "DDNS-GO",
|
||||
"order": 58,
|
||||
"action": {
|
||||
"type": "firstchild"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-ddns-go" ],
|
||||
"uci": { "ddns-go": true }
|
||||
}
|
||||
},
|
||||
|
||||
"admin/services/ddns-go/ddns-go": {
|
||||
"title": "DDNS-GO Control panel",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "ddns-go/ddns-go"
|
||||
}
|
||||
},
|
||||
"admin/services/ddns-go/config": {
|
||||
"title": "Base Setting",
|
||||
"order": 20,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "ddns-go/config"
|
||||
}
|
||||
},
|
||||
|
||||
"admin/services/ddns-go/log": {
|
||||
"title": "Log",
|
||||
"order": 30,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "ddns-go/log"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"luci-app-ddns-go": {
|
||||
"description": "Grant UCI access for luci-app-ddns-go",
|
||||
"read": {
|
||||
"uci": [ "ddns-go" ],
|
||||
"file": {
|
||||
"/etc/init.d/ddns-go": [ "exec" ],
|
||||
"/usr/libexec/ddns-go-call": [ "exec" ],
|
||||
"/usr/share/rpcd/ucode/luci.ddns-go": [ "exec" ],
|
||||
"/bin/pidof": [ "exec" ],
|
||||
"/bin/ps": [ "exec" ],
|
||||
"/bin/ash": [ "exec" ],
|
||||
"/etc/ddns-go/ddns-go-config.yaml": [ "read" ],
|
||||
"/var/log/*": [ "read" ],
|
||||
"/bin/logread": [ "exec" ]
|
||||
},
|
||||
"ubus": {
|
||||
"rc": [ "*" ],
|
||||
"service": [ "list" ],
|
||||
"luci.ddns-go": [ "*" ],
|
||||
"network.interface.*": [ "status" ],
|
||||
"network": [ "*" ]
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "ddns-go" ],
|
||||
"file": {
|
||||
"/etc/ddns-go/ddns-go-config.yaml": [ "write" ]
|
||||
},
|
||||
"ubus": {
|
||||
"luci.ddns-go": [ "*" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/ucode
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (C) 2022-2026 sirpdboy <herboy2008@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { access, error, lstat, popen, readfile, writefile } from 'fs';
|
||||
|
||||
/* Kanged from ucode/luci */
|
||||
function shellquote(s) {
|
||||
return `'${replace(s, "'", "'\\''")}'`;
|
||||
}
|
||||
function get_current_version() {
|
||||
if (!access('/usr/bin/ddns-go'))
|
||||
return null;
|
||||
|
||||
const fd = popen('/usr/bin/ddns-go -v');
|
||||
if (fd) {
|
||||
let version_output = fd.read('all');
|
||||
fd.close();
|
||||
|
||||
if (!version_output || length(version_output) === 0)
|
||||
return null;
|
||||
|
||||
try {
|
||||
version_output = replace(trim(version_output), /^v/, '');
|
||||
return version_output;
|
||||
} catch(e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const methods = {
|
||||
get_ver: {
|
||||
call: function() {
|
||||
let current_version = get_current_version();
|
||||
if (!current_version)
|
||||
return { ver: {}, error: 'ddns-go not found or version check failed' };
|
||||
|
||||
return { ver: { version: current_version } };
|
||||
}
|
||||
},
|
||||
|
||||
last_update: {
|
||||
call: function() {
|
||||
if (!access('/usr/bin/ddns-go'))
|
||||
return { update: {}, error: 'ddns-go not found' };
|
||||
let version_before = get_current_version();
|
||||
|
||||
const fd = popen('/usr/bin/ddns-go -u');
|
||||
if (fd) {
|
||||
let output = fd.read('all');
|
||||
fd.close();
|
||||
|
||||
if (!output || length(output) === 0)
|
||||
return { update: {}, error: 'empty response' };
|
||||
|
||||
try {
|
||||
output = trim(output);
|
||||
let update_info = {
|
||||
raw_output: output,
|
||||
version_before: version_before,
|
||||
version_after: null,
|
||||
has_update: false,
|
||||
update_successful: false,
|
||||
current_version: '',
|
||||
latest_version: '',
|
||||
status: 'unknown',
|
||||
message: output
|
||||
};
|
||||
|
||||
update_info.version_after = get_current_version();
|
||||
|
||||
if (version_before && update_info.version_after && version_before !== update_info.version_after) {
|
||||
update_info.update_successful = true;
|
||||
update_info.has_update = false;
|
||||
update_info.status = 'updated';
|
||||
update_info.message = `Update successful: ${version_before} → ${update_info.version_after}`;
|
||||
}
|
||||
else if (match(output, /Current version.*is the latest/)) {
|
||||
update_info.status = 'latest';
|
||||
update_info.has_update = false;
|
||||
let version_match = match(output, /v[\d.]+/);
|
||||
if (version_match) {
|
||||
update_info.current_version = replace(version_match[0], /^v/, '');
|
||||
update_info.latest_version = update_info.current_version;
|
||||
}
|
||||
update_info.message = 'Already the latest version ' + (update_info.current_version || '');
|
||||
|
||||
} else if (match(output, /new version.*available/)) {
|
||||
update_info.status = 'update_available';
|
||||
update_info.has_update = true;
|
||||
|
||||
let versions = match(output, /v[\d.]+/, 'g');
|
||||
if (versions && length(versions) >= 2) {
|
||||
update_info.current_version = replace(versions[0], /^v/, '');
|
||||
update_info.latest_version = replace(versions[1], /^v/, '');
|
||||
} else if (version_before) {
|
||||
update_info.current_version = version_before;
|
||||
}
|
||||
update_info.message = 'New version available: ' + (update_info.latest_version || '');
|
||||
|
||||
} else if (match(output, /download.*failed/)) {
|
||||
update_info.status = 'download_failed';
|
||||
update_info.has_update = false;
|
||||
update_info.message = 'Download update failed';
|
||||
|
||||
} else if (match(output, /check.*failed/)) {
|
||||
update_info.status = 'check_failed';
|
||||
update_info.has_update = false;
|
||||
update_info.message = 'Update check failed';
|
||||
|
||||
} else {
|
||||
update_info.status = 'unknown';
|
||||
update_info.message = output;
|
||||
}
|
||||
|
||||
return { update: update_info };
|
||||
} catch(e) {
|
||||
return { update: {}, error: 'Parse error: ' + e };
|
||||
}
|
||||
} else {
|
||||
return { update: {}, error: 'failed to execute ddns-go command' };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return { 'luci.ddns-go': methods };
|
||||
Reference in new issue
Block a user