Add pc support
This commit is contained in:
parent
e8429d66ed
commit
537d14c8cd
4 changed files with 112 additions and 75 deletions
|
|
@ -235,18 +235,37 @@ def write_smartdns_domain_set():
|
|||
f.write(domain_set_text)
|
||||
|
||||
|
||||
def reload_smartdns():
|
||||
def reload_openwrt_smartdns():
|
||||
subprocess.run(["/etc/init.d/smartdns", "reload"])
|
||||
|
||||
|
||||
def main():
|
||||
def reload_pc_smartdns():
|
||||
subprocess.run(["systemctl", "restart", "smartdns.service"])
|
||||
|
||||
|
||||
def run_openwrt():
|
||||
write_smartdns_domain_set()
|
||||
reload_smartdns()
|
||||
reload_openwrt_smartdns()
|
||||
|
||||
write_dnsmasq()
|
||||
reload_dnsmasq()
|
||||
|
||||
|
||||
def run_pc():
|
||||
write_smartdns_domain_set()
|
||||
reload_pc_smartdns()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
logging.basicConfig(stream=sys.stderr, level=logging.INFO, format="%(levelname)s:%(message)s")
|
||||
main()
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("where", choices=["openwrt", "pc"], help="运行环境:openwrt 或 pc")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.where == "openwrt":
|
||||
run_openwrt()
|
||||
elif args.where == "pc":
|
||||
run_pc()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue