systemd
parent
78ac1168bf
commit
701a14fe95
Binary file not shown.
|
@ -0,0 +1,17 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def eprint(*args, **kwargs):
|
||||||
|
print(*args, file=sys.stderr, **kwargs)
|
||||||
|
|
||||||
|
def input_print(p, default = ""):
|
||||||
|
eprint("\033[93m" + p, end=':\033[0m ', flush=True)
|
||||||
|
inp = input("")
|
||||||
|
if inp:
|
||||||
|
return inp
|
||||||
|
else:
|
||||||
|
if not default:
|
||||||
|
return input_print(p, default)
|
||||||
|
return default
|
||||||
|
|
||||||
|
def green_print(p):
|
||||||
|
eprint("\033[92m" + p + "\033[0m")
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import color_io
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog='Site Generator', description='Apache/Nginx Site Generator', epilog='Currently Only For Nginx')
|
parser = argparse.ArgumentParser(prog='Site Generator', description='Apache/Nginx Site Generator', epilog='Currently Only For Nginx')
|
||||||
|
|
||||||
|
@ -25,21 +26,8 @@ if not install_location.endswith('/'):
|
||||||
if not log_location.endswith('/'):
|
if not log_location.endswith('/'):
|
||||||
log_location = log_location + "/"
|
log_location = log_location + "/"
|
||||||
|
|
||||||
def inputprint(p, default = ""):
|
|
||||||
print("\033[93m" + p, end=':\033[0m ', flush=True)
|
|
||||||
inp = input("")
|
|
||||||
if inp:
|
|
||||||
return inp
|
|
||||||
else:
|
|
||||||
if not default:
|
|
||||||
return inputprint(p, default)
|
|
||||||
return default
|
|
||||||
|
|
||||||
site = {}
|
site = {}
|
||||||
site['name'] = inputprint("Enter site address (eg: 'tpgc.me')")
|
site['name'] = color_io.input_print("Enter site address (eg: 'tpgc.me')")
|
||||||
|
|
||||||
def greenprint(p):
|
|
||||||
print("\033[92m" + p + "\033[0m")
|
|
||||||
|
|
||||||
def get_config_name():
|
def get_config_name():
|
||||||
return site['name']
|
return site['name']
|
||||||
|
@ -73,10 +61,10 @@ def write_location(f, loc, mod):
|
||||||
f.write(" }\n\n")
|
f.write(" }\n\n")
|
||||||
|
|
||||||
def create_proxy():
|
def create_proxy():
|
||||||
greenprint("Creating proxy site")
|
color_io.green_print("Creating proxy site")
|
||||||
site['location'] = inputprint("Enter site location (default '/')", "/")
|
site['location'] = color_io.input_print("Enter site location (default '/')", "/")
|
||||||
site['address'] = inputprint("Enter address to proxy to (default: http://127.0.0.1)", "http://127.0.0.1")
|
site['address'] = color_io.input_print("Enter address to proxy to (default: http://127.0.0.1)", "http://127.0.0.1")
|
||||||
site['port'] = inputprint("Enter port")
|
site['port'] = color_io.input_print("Enter port")
|
||||||
f = create_nginx()
|
f = create_nginx()
|
||||||
write_location(f, site['location'], ["proxy_pass " + site['address'] + ":" + site['port'],
|
write_location(f, site['location'], ["proxy_pass " + site['address'] + ":" + site['port'],
|
||||||
"proxy_set_header Upgrade $http_upgrade",
|
"proxy_set_header Upgrade $http_upgrade",
|
||||||
|
@ -85,8 +73,8 @@ def create_proxy():
|
||||||
end_nginx(f)
|
end_nginx(f)
|
||||||
|
|
||||||
def create_root():
|
def create_root():
|
||||||
greenprint("Creating root site")
|
color_io.green_print("Creating root site")
|
||||||
site['path'] = inputprint("Enter site files path")
|
site['path'] = color_io.input_print("Enter site files path")
|
||||||
f = create_nginx()
|
f = create_nginx()
|
||||||
f.write(" root " + site['path'] + ";\n\n");
|
f.write(" root " + site['path'] + ";\n\n");
|
||||||
f.write(" include php-fpm;\n\n");
|
f.write(" include php-fpm;\n\n");
|
||||||
|
|
|
@ -1,2 +1,16 @@
|
||||||
#!/bin/python3
|
#!/bin/python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import subprocess
|
||||||
|
import color_io
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(prog='SystemD Service Generator', description='SystemD Service Unit File Generator', epilog='Meow')
|
||||||
|
|
||||||
|
parser.add_argument("-i", "--install", nargs='?', const="/etc/systemd/system/", default=None)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue