mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-09 05:27:59 +08:00
🎨 Sync 2026-04-10 15:34:26
This commit is contained in:
1 parent
9b1a57d792
commit
42174fc0b0
66 files changed
+6841
-2210
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { readfile, popen } from 'fs';
|
||||
import { readfile, writefile, popen } from 'fs';
|
||||
|
||||
export function get_paths() {
|
||||
let result = {};
|
||||
@@ -120,4 +120,14 @@ export function get_cgroups() {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
export function load_profile() {
|
||||
const paths = get_paths();
|
||||
return json(readfile(paths.run_profile_path));
|
||||
};
|
||||
|
||||
export function save_profile(obj) {
|
||||
const paths = get_paths();
|
||||
return writefile(paths.run_profile_path, obj);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/ucode
|
||||
|
||||
'use strict';
|
||||
|
||||
import { cursor } from 'uci';
|
||||
import { uci_bool, uci_int, uci_array, merge, trim_all, load_profile, save_profile } from '/etc/momo/ucode/include.uc';
|
||||
|
||||
const uci = cursor();
|
||||
|
||||
const config = {};
|
||||
|
||||
config['log'] = {};
|
||||
config['log']['disabled'] = uci_bool(uci.get('momo', 'mixin', 'log_disabled'));
|
||||
config['log']['level'] = uci.get('momo', 'mixin', 'log_level');
|
||||
config['log']['timestamp'] = uci_bool(uci.get('momo', 'mixin', 'log_timestamp'));
|
||||
config['log']['output'] = uci.get('momo', 'mixin', 'log_output');
|
||||
|
||||
config['dns'] = {};
|
||||
config['dns']['strategy'] = uci.get('momo', 'mixin', 'dns_strategy');
|
||||
config['dns']['disable_cache'] = uci_bool(uci.get('momo', 'mixin', 'dns_disable_cache'));
|
||||
config['dns']['disable_expire'] = uci_bool(uci.get('momo', 'mixin', 'dns_disable_expire'));
|
||||
config['dns']['independent_cache'] = uci_bool(uci.get('momo', 'mixin', 'dns_independent_cache'));
|
||||
config['dns']['cache_capacity'] = uci_int(uci.get('momo', 'mixin', 'dns_cache_capacity'));
|
||||
config['dns']['reverse_mapping'] = uci_bool(uci.get('momo', 'mixin', 'dns_reverse_mapping'));
|
||||
|
||||
config['ntp'] = {};
|
||||
config['ntp']['enabled'] = uci_bool(uci.get('momo', 'mixin', 'ntp_enabled'));
|
||||
config['ntp']['server'] = uci.get('momo', 'mixin', 'ntp_server');
|
||||
config['ntp']['server_port'] = uci_int(uci.get('momo', 'mixin', 'ntp_server_port'));
|
||||
config['ntp']['interval'] = uci.get('momo', 'mixin', 'ntp_interval');
|
||||
|
||||
config['experimental'] = {};
|
||||
|
||||
config['experimental']['cache_file'] = {};
|
||||
config['experimental']['cache_file']['enabled'] = uci_bool(uci.get('momo', 'mixin', 'cache_enabled'));
|
||||
config['experimental']['cache_file']['path'] = uci.get('momo', 'mixin', 'cache_path');
|
||||
config['experimental']['cache_file']['store_fakeip'] = uci_bool(uci.get('momo', 'mixin', 'cache_store_fakeip'));
|
||||
config['experimental']['cache_file']['store_rdrc'] = uci_bool(uci.get('momo', 'mixin', 'cache_store_rdrc'));
|
||||
|
||||
config['experimental']['clash_api'] = {};
|
||||
config['experimental']['clash_api']['external_ui'] = uci.get('momo', 'mixin', 'external_control_ui_path');
|
||||
config['experimental']['clash_api']['external_ui_download_url'] = uci.get('momo', 'mixin', 'external_control_ui_download_url');
|
||||
config['experimental']['clash_api']['external_controller'] = uci.get('momo', 'mixin', 'external_control_api_listen');
|
||||
config['experimental']['clash_api']['secret'] = uci.get('momo', 'mixin', 'external_control_api_secret');
|
||||
|
||||
const profile = load_profile();
|
||||
|
||||
save_profile(merge(profile, trim_all(config)));
|
||||
Reference in new issue
Block a user