mirror of https://github.com/Aidaho12/haproxy-wi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.9 KiB
61 lines
1.9 KiB
7 years ago
|
#!/usr/bin/env python3
|
||
|
import html
|
||
|
import cgi
|
||
|
import os
|
||
|
import funct
|
||
7 years ago
|
from configparser import ConfigParser, ExtendedInterpolation
|
||
7 years ago
|
import glob
|
||
7 years ago
|
|
||
|
form = cgi.FieldStorage()
|
||
|
serv = form.getvalue('serv')
|
||
|
|
||
|
funct.head("Old Versions HAproxy config")
|
||
|
funct.check_config()
|
||
|
funct.check_login()
|
||
|
|
||
|
path_config = "haproxy-webintarface.config"
|
||
7 years ago
|
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||
7 years ago
|
config.read(path_config)
|
||
|
|
||
|
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||
|
|
||
7 years ago
|
funct.page_for_admin()
|
||
7 years ago
|
funct.chooseServer("delver.py", "Delete Versions HAproxy config", "n")
|
||
7 years ago
|
|
||
|
if serv is not None and form.getvalue('open') is not None:
|
||
|
|
||
|
print('<center><h3>Choose old version</h3>')
|
||
7 years ago
|
print('<form action="delver.py#conf" method="get">'
|
||
7 years ago
|
'<label for="select_all" id="label_select_all"><b>Select all</b></label>'
|
||
|
'<input type="checkbox" id="select_all"><br />')
|
||
7 years ago
|
|
||
|
os.chdir(hap_configs_dir)
|
||
|
|
||
|
for files in sorted(glob.glob('*.cfg')):
|
||
|
ip = files.split("-")
|
||
|
if serv == ip[0]:
|
||
|
print('<label for="%s"> %s </label><input type="checkbox" value="%s" name="%s" id="%s"><br />' % (files, files, files, files, files))
|
||
|
|
||
|
print('<input type="hidden" value="%s" name="serv">' % serv)
|
||
|
print('<input type="hidden" value="open" name="open">')
|
||
|
print('<input type="hidden" value="del" name="del">')
|
||
|
print('<p>')
|
||
7 years ago
|
funct.get_button("Delete")
|
||
7 years ago
|
print('</p></form>')
|
||
|
|
||
|
Select = form.getvalue('del')
|
||
|
|
||
|
if Select is not None:
|
||
|
os.chdir(hap_configs_dir)
|
||
|
print("<b>The following files were deleted:</b><br />")
|
||
|
for get in form:
|
||
|
if "cfg" in get:
|
||
|
try:
|
||
|
os.remove(form.getvalue(get))
|
||
|
print(form.getvalue(get) + "<br />")
|
||
7 years ago
|
funct.logging(serv, "delver.py deleted config: %s" % form.getvalue(get))
|
||
7 years ago
|
except OSError:
|
||
|
print ("Error: %s - %s." % (e.filename,e.strerror))
|
||
7 years ago
|
print('<meta http-equiv="refresh" content="10; url=delver.py?serv=%s&open=open">' % form.getvalue('serv'))
|
||
|
|
||
7 years ago
|
funct.footer()
|