Updated setup with optional psql db

master
Ionut Filip 6 years ago
parent e668d360e8
commit ef6a0727ac

@ -13,6 +13,16 @@ services:
restart: always restart: always
volumes: volumes:
- "{{ root }}/redis:/data" - "{{ root }}/redis:/data"
{% if db_flavor == 'postgresql' and postgresql == 'internal' %}
database:
image: ${DOCKER_ORG:-mailu}/postgresql:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/data/psql_db:/data"
- "{{ root }}/data/psql_backup:/backup"
{% endif %}
# Core services # Core services
front: front:

@ -158,3 +158,15 @@ REAL_IP_FROM={{ real_ip_from }}
# choose wether mailu bounces (no) or rejects (yes) mail when recipient is unknown (value: yes, no) # choose wether mailu bounces (no) or rejects (yes) mail when recipient is unknown (value: yes, no)
REJECT_UNLISTED_RECIPIENT={{ reject_unlisted_recipient }} REJECT_UNLISTED_RECIPIENT={{ reject_unlisted_recipient }}
###################################
# Advanced settings
###################################
DB_FLAVOR = {{ db_flavor }}
{% if postgresql == 'external' %}
DB_USER={{ db_user }}
DB_PW={{ db_pw }}
DB_URL={{ db_url }}
DB_NAME={{ db_name }}
{% endif %}

@ -31,4 +31,46 @@ $(document).ready(function() {
$("#admin_path").attr("value", ""); $("#admin_path").attr("value", "");
} }
}); });
}); });
$(document).ready(function() {
if ($("#database").val() == 'sqlite') {
$("#postgres_db").hide();
} else {
$("#postgres_db").show();
}
if ($('#external_psql').prop('checked')) {
$("#external_db").show();
}
$("#database").click(function() {
if (this.value == 'sqlite') {
$("#postgres_db").hide();
} else {
$("#postgres_db").show();
}
});
$("#external_psql").change(function() {
if ($(this).is(":checked")) {
$("#external_db").show();
$("#db_user").prop('required',true);
$("#db_pw").prop('required',true);
$("#db_url").prop('required',true);
$("#db_name").prop('required',true);
} else {
$("#external_db").hide();
}
});
$("#internal_psql").change(function() {
if ($(this).is(":checked")) {
$("#external_db").hide();
$("#db_user").val("");
$("#db_pw").val("");
$("#db_url").val("");
$("#db_name").val("");
$("#db_user").prop('required',false);
$("#db_pw").prop('required',false);
$("#db_url").prop('required',false);
$("#db_name").prop('required',false);
}
});
});

@ -0,0 +1,39 @@
{% call macros.panel("info", "Database preferences") %}
<div class="form-group">
<label>Which database back end would you like to use?</label>
<br/>
<select class="btn btn-primary dropdown-toggle" name="db_flavor" id="database">
{% for dbflavor in ["sqlite", "postgresql"] %}
<option value="{{ dbflavor }}" >{{ dbflavor }}</option>
{% endfor %}
</select>
<p></p>
<div id="postgres_db" style="display: none">
<div class="form-check">
<input class="form-check-input" type="radio" name="postgresql" id="internal_psql" value="internal" checked>
<label class="form-check-label" for="internal_psql">
Use the Postgresql from Mailu
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="postgresql" value="external" id="external_psql" >
<label class="form-check-label" for="external_psql">
I want to connect to an external database
</label>
</div>
<br/>
<div class="form-group" id="external_db" style="display: none">
<label>DB User</label>
<input class="form-control" type="text" name="db_user" placeholder="Username" id="db_user">
<label>Db Password</label>
<input class="form-control" type="password" name="db_pw" placeholder="Password" id="db_pw">
<label>Db URL</label>
<input class="form-control" type="text" name="db_url" placeholder="URL" id="db_url">
<label>Db Name</label>
<input class="form-control" type="text" name="db_name" placeholder="Database Name" id="db_name">
</div>
</div>
</div>
{% endcall %}

@ -19,6 +19,7 @@
{%for file in steps %} {%for file in steps %}
{% include "steps/" + flavor + "/" + file %} {% include "steps/" + flavor + "/" + file %}
{% endfor %} {% endfor %}
{% include "steps/database.html" %}
<input class="btn btn-primary" type="submit" value="Setup Mailu"> <input class="btn btn-primary" type="submit" value="Setup Mailu">
{% endif %} {% endif %}
</form> </form>

Loading…
Cancel
Save