blank/fresh start
This commit is contained in:
parent
b87b147fec
commit
1866cb7fcf
@ -1,7 +0,0 @@
|
|||||||
from flask import Flask
|
|
||||||
|
|
||||||
app = Flask(__name__, instance_relative_config = True)
|
|
||||||
|
|
||||||
from app import views
|
|
||||||
|
|
||||||
app.config.from_object('config')
|
|
@ -1,32 +0,0 @@
|
|||||||
// https://github.com/sebkouba/dynamic-flask-form
|
|
||||||
$(function() {
|
|
||||||
$("div[data-toggle=fieldset]").each(function() {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
//Add new entry
|
|
||||||
$this.find("button[data-toggle=fieldset-add-row]").click(function() {
|
|
||||||
var target = $($(this).data("target"))
|
|
||||||
console.log(target);
|
|
||||||
var oldrow = target.find("[data-toggle=fieldset-entry]:last");
|
|
||||||
var row = oldrow.clone(true, true);
|
|
||||||
console.log(row.find(":input")[0]);
|
|
||||||
var elem_id = row.find(":input")[0].id;
|
|
||||||
var elem_num = parseInt(elem_id.replace(/.*-(\d{1,4})-.*/m, '$1')) + 1;
|
|
||||||
row.attr('data-id', elem_num);
|
|
||||||
row.find(":input").each(function() {
|
|
||||||
console.log(this);
|
|
||||||
var id = $(this).attr('id').replace('-' + (elem_num - 1) + '-', '-' + (elem_num) + '-');
|
|
||||||
$(this).attr('name', id).attr('id', id).val('').removeAttr("checked");
|
|
||||||
});
|
|
||||||
oldrow.after(row);
|
|
||||||
}); //End add new entry
|
|
||||||
|
|
||||||
//Remove row
|
|
||||||
$this.find("button[data-toggle=fieldset-remove-row]").click(function() {
|
|
||||||
if($this.find("[data-toggle=fieldset-entry]").length > 1) {
|
|
||||||
var thisRow = $(this).closest("[data-toggle=fieldset-entry]");
|
|
||||||
thisRow.remove();
|
|
||||||
}
|
|
||||||
}); //End remove row
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,12 +0,0 @@
|
|||||||
{% macro render_field(field) %}
|
|
||||||
<dt>{{ field.label }}
|
|
||||||
<dd>{{ field(**kwargs)|safe }}
|
|
||||||
{% if field.errors %}
|
|
||||||
<ul class=errors>
|
|
||||||
{% for error in field.errors %}
|
|
||||||
<li>{{ error }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
|
||||||
{% endmacro %}
|
|
@ -1,52 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>{% block title %}{% endblock %}</title>
|
|
||||||
<!-- Bootstrap core CSS -->
|
|
||||||
<!-- Thanks, https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xii-facelift and
|
|
||||||
https://scotch.io/tutorials/getting-started-with-flask-a-python-microframework -->
|
|
||||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">-->
|
|
||||||
<!-- Custom styles for this template -->
|
|
||||||
<link href="https://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="stylesheet">
|
|
||||||
<!--<link href="https://getbootstrap.com/docs/4.0/examples/offcanvas/offcanvas.css" rel="stylesheet">-->
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
||||||
<script src="../static/multiform.js"></script>
|
|
||||||
<style>
|
|
||||||
.is-hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<style class="statustbl">
|
|
||||||
/*table {*/
|
|
||||||
/* border-spacing: 30px 5px;*/
|
|
||||||
/*}*/
|
|
||||||
td {
|
|
||||||
padding: 0px 15px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<div class="header clearfix">
|
|
||||||
<nav>
|
|
||||||
<ul class="nav nav-pills pull-right">
|
|
||||||
<li role="presentation"><a href="/">Home</a></li>
|
|
||||||
<li role="presentation"><a href="/generator">Generator</a></li>
|
|
||||||
<!-- <li role="presentation"><a href="/usage">Usage</a></li> -->
|
|
||||||
<!-- the following opens in a new tab/window/whatever. the line after opens in the same tab/window/etc. -->
|
|
||||||
<!-- <li role="presentation"><a href="https://square-r00t.net/" target="_blank">r00t^2</a></li> -->
|
|
||||||
<li role="presentation"><a href="https://square-r00t.net/">r00t^2</a></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
{% block body %}{% endblock %}
|
|
||||||
<footer class="footer">
|
|
||||||
<p><sub>The code for this page is released under the <a
|
|
||||||
href="https://www.gnu.org/licenses/gpl-3.0.en.html#content">GPL 3.0 License</a>. It can be found <a
|
|
||||||
href="https://git.square-r00t.net/AIF-NG_Config/tree/">here</a>.</sub></p>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
<!-- /container -->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,74 +0,0 @@
|
|||||||
{% extends "base.html" %}{% block title %}AIF-NG Configurator | Generator{% endblock %}{% block body %}
|
|
||||||
<div class="jumbotron">
|
|
||||||
<h1>Generator</h1>
|
|
||||||
<p class="lead"><span style="color: red; ">WARNING:</span> Please note that this site may have you submit sensitive
|
|
||||||
information such as passwords, usernames, and the like.</br>
|
|
||||||
In the interests of full disclosure and respect for privacy, it is important that you know that <b>these are
|
|
||||||
entirely viewable to me, or whomever runs the instance of this website</b>.</br>
|
|
||||||
It is <b><i>highly</i></b> recommended that you generate it with dummy values for those sensitive fields
|
|
||||||
(denoted with <span style="color: blue; "><code>*sensitive</code></span>), and replace those locally in a
|
|
||||||
plaintext editor or XML editor of your choice after downloading the generated configuration file.</p>
|
|
||||||
</div>
|
|
||||||
<div class="flashes">
|
|
||||||
{% for message in get_flashed_messages() %}
|
|
||||||
<h3>{{ message }}</h3>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<ul id="top">
|
|
||||||
<li><a href="#ver">Version</a></li>
|
|
||||||
<li><a href="#disk">Disk</a></li>
|
|
||||||
<li><a href="#net">Network</a></li>
|
|
||||||
<li><a href="#sys">System</a></li>
|
|
||||||
<li><a href="#pac">Pacman</a></li>
|
|
||||||
<li><a href="#boot">Bootloader</a></li>
|
|
||||||
<li><a href="#scripts">Scripts</a></li>
|
|
||||||
</ul>
|
|
||||||
{% from "_formhelper.html" import render_field %}
|
|
||||||
<form method=post>
|
|
||||||
<!-- VERSION -->
|
|
||||||
<h2 id="ver">Version</h2>
|
|
||||||
<p>This version should match the version of AIF-NG that you are running. It must match a <a
|
|
||||||
href="https://git.square-r00t.net/AIF-NG/refs/">valid git reference</a> (tag, branch, commit, etc.) for
|
|
||||||
the
|
|
||||||
project.</p>
|
|
||||||
<p>{{ render_field(form.version) }}</p>
|
|
||||||
<a href="#top">(back to top)</a>
|
|
||||||
|
|
||||||
<!-- STORAGE -->
|
|
||||||
<h2 id="disk">Disk</h2>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<!-- NETWORK -->
|
|
||||||
<h2 id="net">Network</h2>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<!-- SYSTEM -->
|
|
||||||
<h2 id="sys">System</h2>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<!-- PACMAN -->
|
|
||||||
<h2 id="pac">Pacman</h2>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<!-- BOOTLOADER -->
|
|
||||||
<h2 id="boot">Bootloader</h2>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<!-- SCRIPTS -->
|
|
||||||
<h2 id="scripts">Scripts</h2>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<input type="submit" value="Generate"/>
|
|
||||||
</form>
|
|
||||||
{% if form.errors %}
|
|
||||||
<ul class="errors">
|
|
||||||
{%- for field_name, field_errors in form.errors|dictsort if field_errors %}
|
|
||||||
{%- for error in field_errors %}
|
|
||||||
<li>{{ form[field_name].label }}: {{ error }}</li>
|
|
||||||
{%- endfor %}
|
|
||||||
{%- endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
|
|
||||||
<script src="../js/multiform.js"></script>
|
|
||||||
{% endblock %}
|
|
@ -1,12 +0,0 @@
|
|||||||
{% extends "base.html" %}{% block title %}AIF-NG Configurator | Home{% endblock %}{% block body %}<div class="jumbotron">
|
|
||||||
<h1>AIF-NG Configurator</h1>
|
|
||||||
<p class="lead">A tool to generate XML configuration files for <a href="https://aif-ng.io/">AIF-NG</a>.</p>
|
|
||||||
</div>
|
|
||||||
<h1>What is it?</h1>
|
|
||||||
<p>This tool will let you generate configuration files for AIF-NG. I, the author of this generator and of AIF-NG,
|
|
||||||
recognize that not everyone is comfortable with writing XML from scratch — even if they use something like an IDE
|
|
||||||
with XML support (I recommend <a href="https://www.jetbrains.com/pycharm/download/#section=linux">PyCharm Community Edition</a>; it will validate your config as you go as long as you include the XSD in the header!).</p>
|
|
||||||
|
|
||||||
<p>So without further ado, head on over to the <a href="/generator.html">generator</a> or for more information on using this tool,
|
|
||||||
try the <a href="/usage.html">usage page</a>.</p>
|
|
||||||
{% endblock %}
|
|
@ -1,17 +0,0 @@
|
|||||||
{% extends "base.html" %}{% block title %}AIF-NG Configurator | Disks{% endblock %}{% block body %}
|
|
||||||
<div class="jumbotron">
|
|
||||||
<h1>Disks</h1>
|
|
||||||
<p class="lead"><a href="/generator">Generator</a> > <a href="generator/storage">Storage</a> > <a
|
|
||||||
href="generator/storage/disk">Disk</a></p>
|
|
||||||
</div>
|
|
||||||
<h1>Disks</h1>
|
|
||||||
<p>In this section, you must specify device path names of the target disk(s) to install to. It is <b>highly</b>
|
|
||||||
recommended to use actual device paths, but you can specify ONE entry as "auto" which will use the first
|
|
||||||
available unformatted disk. It is not recommended to combine "auto" and actual device path(s).</p>
|
|
||||||
<p>DISK FORM</p>
|
|
||||||
<div class="text-center">
|
|
||||||
<button class="btn btn-primary" onclick="window.location.href = '/generator/storage';">Back</button>
|
|
||||||
<button class="btn btn-primary" onclick="window.location.href = '/generator';">Up</button>
|
|
||||||
<button class="btn btn-primary" onclick="window.location.href = '/generator/filesystem';">Next</button>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,30 +0,0 @@
|
|||||||
{% extends "base.html" %}{% block title %}AIF-NG Configurator | Storage{% endblock %}{% block body %}
|
|
||||||
<div class="jumbotron">
|
|
||||||
<h1>Storage</h1>
|
|
||||||
<p class="lead"><a href="/generator">Generator</a> > <a href="generator/storage">Storage</a></p>
|
|
||||||
</div>
|
|
||||||
<h1>Storage</h1>
|
|
||||||
<p>In this section, you will configure disks/partitions and filesystems to use for your installation. Optionally, you
|
|
||||||
can also add support for <a href="https://sourceware.org/lvm2/">LVM</a>, <a
|
|
||||||
href="https://gitlab.com/cryptsetup/cryptsetup/-/wiki_pages/home">LUKS</a>, and/or <a
|
|
||||||
href="https://raid.wiki.kernel.org/index.php/Linux_Raid">mdadm</a>.</p>
|
|
||||||
|
|
||||||
<!-- <table class="statustbl">
|
|
||||||
{% for f in (('Disk', 'disk'), ('Filesystem', 'filesystem'), ('LUKS', 'luks'), ('LVM', 'lvm'), ('MD', 'mdadm')) %}
|
|
||||||
<tr>
|
|
||||||
{%- set status = true %}
|
|
||||||
{%- if status == true %}
|
|
||||||
{% set chkbox = ' checked' %}
|
|
||||||
{% else %}
|
|
||||||
{% set chkbox = '' %}
|
|
||||||
{%- endif %}
|
|
||||||
<td><a href="/generator/storage/{{ f[1] }}">{{ f[0] }}</a></td>
|
|
||||||
{#
|
|
||||||
<td>{% '<input type="checkbox" onclick="return false;" disabled="disabled">' if status else
|
|
||||||
'<input type="checkbox" onclick="return false;" disabled="disabled">' %}</td>
|
|
||||||
#}
|
|
||||||
<td><input type="checkbox" onclick="return false;" disabled="disabled"{{ chkbox }}></td>
|
|
||||||
</tr>
|
|
||||||
{%- endfor %}
|
|
||||||
</table> -->
|
|
||||||
{% endblock %}
|
|
33
app/views.py
33
app/views.py
@ -1,33 +0,0 @@
|
|||||||
from flask import render_template, make_response, request, flash
|
|
||||||
from app import app
|
|
||||||
# from flask_wtf import Form
|
|
||||||
from wtforms import Form, BooleanField, PasswordField, StringField, TextAreaField, validators
|
|
||||||
|
|
||||||
|
|
||||||
class DiskForm():
|
|
||||||
disk = TextAreaField(label = 'Disk(s):',
|
|
||||||
validators = [validators.required(),
|
|
||||||
validators.Regexp((r'^(/dev/([A-Za-z0-9_]+/)?'
|
|
||||||
r'[A-Za-z0-9_]+[0-9]?|'
|
|
||||||
r'auto)$'))],
|
|
||||||
default = '/dev/sda')
|
|
||||||
|
|
||||||
|
|
||||||
class GeneratorForm(Form):
|
|
||||||
version = StringField(label = 'Version:',
|
|
||||||
validators = [validators.required()],
|
|
||||||
default = '0.2.0')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods = ['GET'])
|
|
||||||
def index():
|
|
||||||
return(render_template('index.html'))
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/generator', methods = ['GET', 'POST'])
|
|
||||||
def generator():
|
|
||||||
form = GeneratorForm(request.form)
|
|
||||||
if request.method == 'POST' and form.validate():
|
|
||||||
print(form)
|
|
||||||
flash('Generated!')
|
|
||||||
return(render_template('generator.html', form = form))
|
|
@ -1,3 +0,0 @@
|
|||||||
# Flask debugging - DISABLE FOR PRODUCTION ENVIRONMENTS
|
|
||||||
DEBUG = True
|
|
||||||
#DEBUG = False
|
|
8
run.py
8
run.py
@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from app import app
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
# app.run()
|
|
||||||
app.run(host = 'localhost', port = 5001, debug = True)
|
|
||||||
|
|
18
uwsgi.ini
18
uwsgi.ini
@ -1,18 +0,0 @@
|
|||||||
[uwsgi]
|
|
||||||
plugin = python
|
|
||||||
py-autoreload = 1
|
|
||||||
#uid = http
|
|
||||||
#gid = http
|
|
||||||
socket = /run/uwsgi/aifng_config.sock
|
|
||||||
chown-socket = http:http
|
|
||||||
processes = 4
|
|
||||||
master = 1
|
|
||||||
base = /usr/local/lib/aif-ng_configgen
|
|
||||||
chdir = %(base)
|
|
||||||
#mount = /=%(base)/run.py
|
|
||||||
wsgi-file = %(base)/run.py
|
|
||||||
chmod-socket = 660
|
|
||||||
callable = app
|
|
||||||
cgi-helper =.py=python
|
|
||||||
logto = /var/log/uwsgi/%n.log
|
|
||||||
vacuum
|
|
Loading…
Reference in New Issue
Block a user