mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
Initial release - v0.7.5
This commit is contained in:
parent
a5b373b8ee
commit
f05d700aa0
12 changed files with 2342 additions and 0 deletions
9
tools/yunopackage/requirements.txt
Normal file
9
tools/yunopackage/requirements.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
Flask==3.0.0
|
||||
Flask_Misaka==1.0.0
|
||||
Flask_WTF==1.2.1
|
||||
Jinja2==3.1.2
|
||||
misaka==2.1.1
|
||||
WTForms==3.0.1
|
||||
flask_cors==4.0.0
|
||||
werkzeug==3.0.0
|
||||
markupsafe=2.1.3
|
316
tools/yunopackage/static/stylesheet.css
Normal file
316
tools/yunopackage/static/stylesheet.css
Normal file
|
@ -0,0 +1,316 @@
|
|||
:root {
|
||||
color-scheme:light;
|
||||
--yiq-contrasted-threshold: 150;
|
||||
--white: hsl(0, 0%, 100%);
|
||||
--white-h: 0;
|
||||
--white-s: 0%;
|
||||
--white-l: 100%;
|
||||
--black: hsl(0, 0%, 0%);
|
||||
--black-h: 0;
|
||||
--black-s: 0%;
|
||||
--black-l: 0%;
|
||||
--blue: hsl(211, 64%, 50%);
|
||||
--blue-h: 211;
|
||||
--blue-s: 64%;
|
||||
--blue-l: 50%;
|
||||
--indigo: hsl(263, 90%, 51%);
|
||||
--indigo-h: 263;
|
||||
--indigo-s: 90%;
|
||||
--indigo-l: 51%;
|
||||
--purple: hsl(280, 61%, 50%);
|
||||
--purple-h: 280;
|
||||
--purple-s: 61%;
|
||||
--purple-l: 50%;
|
||||
--pink: hsl(332, 79%, 58%);
|
||||
--pink-h: 332;
|
||||
--pink-s: 79%;
|
||||
--pink-l: 58%;
|
||||
--red: hsl(354, 70%, 54%);
|
||||
--red-h: 354;
|
||||
--red-s: 70%;
|
||||
--red-l: 54%;
|
||||
--orange: hsl(27, 98%, 54%);
|
||||
--orange-h: 27;
|
||||
--orange-s: 98%;
|
||||
--orange-l: 54%;
|
||||
--yellow: hsl(45, 100%, 66%);
|
||||
--yellow-h: 45;
|
||||
--yellow-s: 100%;
|
||||
--yellow-l: 66%;
|
||||
--green: hsl(134, 61%, 41%);
|
||||
--green-h: 134;
|
||||
--green-s: 61%;
|
||||
--green-l: 41%;
|
||||
--teal: hsl(162, 73%, 46%);
|
||||
--teal-h: 162;
|
||||
--teal-s: 73%;
|
||||
--teal-l: 46%;
|
||||
--cyan: hsl(188, 78%, 41%);
|
||||
--cyan-h: 188;
|
||||
--cyan-s: 78%;
|
||||
--cyan-l: 41%;
|
||||
--gray-100: hsl(210, 17%, 98%);
|
||||
--gray-100-h: 210;
|
||||
--gray-100-s: 17%;
|
||||
--gray-100-l: 98%;
|
||||
--gray-200: hsl(210, 16%, 93%);
|
||||
--gray-200-h: 210;
|
||||
--gray-200-s: 16%;
|
||||
--gray-200-l: 93%;
|
||||
--gray-300: hsl(210, 14%, 89%);
|
||||
--gray-300-h: 210;
|
||||
--gray-300-s: 14%;
|
||||
--gray-300-l: 89%;
|
||||
--gray-400: hsl(210, 14%, 83%);
|
||||
--gray-400-h: 210;
|
||||
--gray-400-s: 14%;
|
||||
--gray-400-l: 83%;
|
||||
--gray-500: hsl(210, 11%, 71%);
|
||||
--gray-500-h: 210;
|
||||
--gray-500-s: 11%;
|
||||
--gray-500-l: 71%;
|
||||
--gray-600: hsl(208, 7%, 46%);
|
||||
--gray-600-h: 208;
|
||||
--gray-600-s: 7%;
|
||||
--gray-600-l: 46%;
|
||||
--gray-700: hsl(210, 9%, 31%);
|
||||
--gray-700-h: 210;
|
||||
--gray-700-s: 9%;
|
||||
--gray-700-l: 31%;
|
||||
--gray-800: hsl(210, 10%, 23%);
|
||||
--gray-800-h: 210;
|
||||
--gray-800-s: 10%;
|
||||
--gray-800-l: 23%;
|
||||
--gray-900: hsl(210, 11%, 15%);
|
||||
--gray-900-h: 210;
|
||||
--gray-900-s: 11%;
|
||||
--gray-900-l: 15%
|
||||
}
|
||||
|
||||
|
||||
|
||||
h1,.h1 {
|
||||
font-size:2.25rem
|
||||
align="center";
|
||||
}
|
||||
|
||||
h2, .h2 {
|
||||
font-size: 1.35rem;
|
||||
}
|
||||
|
||||
h3, .h3 {
|
||||
font-size: 1.26rem;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin-top:.8rem;
|
||||
margin-bottom:.2rem;
|
||||
font-weight:500;
|
||||
line-height:1.2;
|
||||
}
|
||||
|
||||
body {
|
||||
/* font-family: 'source_sans_proregular'; */
|
||||
font-family: FiraGO,Fira Sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";
|
||||
font-size: 1em;
|
||||
line-height: 2.2;
|
||||
color: var(--gray-900);
|
||||
text-align: left;
|
||||
|
||||
width: 100%;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
max-width: 85%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.message {
|
||||
padding: 10px;
|
||||
margin: 5px;
|
||||
background-color: #2980b9;
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
.text-secondary {
|
||||
color: var(--gray-600) !important;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 20px;
|
||||
margin: 5px;
|
||||
color: #970020;
|
||||
background-color: #ffd5de;
|
||||
}
|
||||
|
||||
.grayed_hint {
|
||||
color: darkgray;
|
||||
}
|
||||
|
||||
.box {
|
||||
border:20px solid black
|
||||
padding: 50px auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background-color: #282c34;
|
||||
color: #ebf2ff;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
|
||||
overflow: auto;
|
||||
height: 400px;
|
||||
|
||||
white-space: pre;
|
||||
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.btn {
|
||||
display:inline-block;
|
||||
font-weight:400;
|
||||
color:var(--gray-900);
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
user-select:none;
|
||||
background-color:transparent;
|
||||
border:1px solid transparent;
|
||||
padding:.375rem .75rem;
|
||||
font-size:.9rem;
|
||||
line-height:1.5;
|
||||
border-radius:.25rem;
|
||||
transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color:hsla(0,0%,calc(-100 * (var(--blue-l) - calc(calc(var(--yiq-contrasted-threshold) / 2.56) * 1%))),1);
|
||||
background-color:var(--blue);
|
||||
border-color:var(--blue);
|
||||
font-size: larger;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
color:hsla(0,0%,calc(-100 * (calc(var(--blue-l) + -7.5%) - calc(calc(var(--yiq-contrasted-threshold) / 2.56) * 1%))),1);
|
||||
background-color:hsla(var(--blue-h),var(--blue-s),calc(var(--blue-l) + -7.5%),var(--blue-a, 1));
|
||||
border-color:hsla(var(--blue-h),var(--blue-s),calc(var(--blue-l) + -10%),var(--blue-a, 1))
|
||||
}
|
||||
.btn-primary:focus,
|
||||
.btn-primary.focus {
|
||||
color:hsla(0,0%,calc(-100 * (calc(var(--blue-l) + -7.5%) - calc(calc(var(--yiq-contrasted-threshold) / 2.56) * 1%))),1);
|
||||
background-color:hsla(var(--blue-h),var(--blue-s),calc(var(--blue-l) + -7.5%),var(--blue-a, 1));
|
||||
border-color:hsla(var(--blue-h),var(--blue-s),calc(var(--blue-l) + -10%),var(--blue-a, 1));
|
||||
box-shadow:0 0 0 .2rem hsla(calc((0 + var(--blue-h)) / 2),calc((0% + var(--blue-s)) / 2),calc((calc(-100 * (var(--blue-l) - calc(calc(var(--yiq-contrasted-threshold) / 2.56) * 1%))) + var(--blue-l)) / 2),.5)
|
||||
}
|
||||
.btn-primary.disabled,
|
||||
.btn-primary:disabled {
|
||||
color:hsla(0,0%,calc(-100 * (var(--blue-l) - calc(calc(var(--yiq-contrasted-threshold) / 2.56) * 1%))),1);
|
||||
background-color:var(--blue);
|
||||
border-color:var(--blue)
|
||||
}
|
||||
|
||||
.btn-center {
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.btn-sm,
|
||||
.btn-group-sm>.btn {
|
||||
padding:.25rem .5rem;
|
||||
//font-size:.7875rem;
|
||||
line-height:1.5;
|
||||
border-radius:.2rem;
|
||||
}
|
||||
|
||||
|
||||
.form-control {
|
||||
#display: block;
|
||||
#width: 100%;
|
||||
#height: calc(1.5em + .75rem + 2px);
|
||||
padding: .375rem .75rem;
|
||||
padding-right: 0.5rem;
|
||||
margin-left:0.75rem;
|
||||
font-size: .9rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
color: var(--gray-700);
|
||||
background-color: var(--white);
|
||||
background-clip: padding-box;
|
||||
border: 1px solid var(--gray-400);
|
||||
border-radius: .25rem;
|
||||
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
|
||||
}
|
||||
.form-control.is-invalid {
|
||||
border-color: var(--red);
|
||||
padding-right: calc(1.5em + .75rem) !important;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='var%28--red%29' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='var%28--red%29' stroke='none'/%3e%3c/svg%3e");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right calc(.375em + .1875rem) center;
|
||||
background-size: calc(.75em + .375rem) calc(.75em + .375rem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.custom-select {
|
||||
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: calc(1.5em + .75rem + 2px);
|
||||
padding: .375rem 1.75rem .375rem .75rem;
|
||||
font-size: .9rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
color: var(--gray-700);
|
||||
vertical-align: middle;
|
||||
background: var(--white) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='var%28--gray-800%29' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") right .75rem center/8px 10px no-repeat;
|
||||
border: 1px solid var(--gray-400);
|
||||
border-radius: .25rem;
|
||||
appearance: none;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.nav {
|
||||
display:flex;
|
||||
flex-wrap:wrap;
|
||||
padding-left:0;
|
||||
margin-bottom:0;
|
||||
list-style:none
|
||||
}
|
||||
.nav-tabs .nav-item.show .nav-link {
|
||||
color:var(--gray-700);
|
||||
background-color:var(--white);
|
||||
border-color:var(--gray-300) var(--gray-300) var(--white)
|
||||
}
|
||||
|
||||
nav a {
|
||||
margin-left: 50px;
|
||||
// text-decoration: none; // removing links underline is a bad idea
|
||||
}
|
||||
|
||||
footer .nav-item:before {
|
||||
/* content:"\2022"; */
|
||||
width:1rem;
|
||||
display:inline-block;
|
||||
margin-left:-1.15rem;
|
||||
padding-top:1rem!important;
|
||||
margin-top:auto!important;
|
||||
}
|
||||
|
||||
|
||||
.test {
|
||||
color:red;
|
||||
}
|
20
tools/yunopackage/templates/_common.sh.j2
Normal file
20
tools/yunopackage/templates/_common.sh.j2
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
{% if parameters["use_nodejs"] -%}
|
||||
nodejs_version={{ parameters["use_nodejs_version"]}}
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
111
tools/yunopackage/templates/backup.j2
Normal file
111
tools/yunopackage/templates/backup.j2
Normal file
|
@ -0,0 +1,111 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||
### to be backuped and not an actual copy of any file. The actual backup that
|
||||
### creates and fill the archive with the files happens in the core after this
|
||||
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
{% if parameters["data_dir"] -%}
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# The --is_big parameters ensure this folder is not included in the backup by default (taking less space), except if BACKUP_CORE_ONLY=0 is passed before the backup command. You might want to document that for your users.
|
||||
{% endif -%}
|
||||
# Only relevant if there is a "data_dir" resource for this app
|
||||
ynh_backup --src_path="$data_dir" --is_big
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
{% if parameters["use_php"] -%}
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
{% endif -%}
|
||||
{% if parameters["use_fail2ban"] -%}
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
{% endif -%}
|
||||
{% if parameters["use_logrotate"] -%}
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
{% endif -%}
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
{% if parameters["use_cron"] -%}
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
{% endif -%}
|
||||
ynh_backup --src_path="/etc/$app/"
|
||||
|
||||
|
||||
{% if parameters["use_db"] -%}
|
||||
#=================================================
|
||||
# BACKUP THE DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the {{ parameters['use_db'] }} database..."
|
||||
|
||||
### (However, things like MySQL dumps *do* take some time to run, though the
|
||||
### copy of the generated dump to the archive still happens later)
|
||||
|
||||
{% if parameters["use_db"] == 'mysql' -%}
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
{% elif parameters["use_db"] == 'postgresql' -%}
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
53
tools/yunopackage/templates/change_url.j2
Normal file
53
tools/yunopackage/templates/change_url.j2
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
109
tools/yunopackage/templates/config.j2
Normal file
109
tools/yunopackage/templates/config.j2
Normal file
|
@ -0,0 +1,109 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# In simple cases, you don't need a config script.
|
||||
|
||||
# With a simple config_panel.toml, you can write in the app settings, in the
|
||||
# upstream config file or replace complete files (logo ...) and restart services.
|
||||
|
||||
# The config scripts allows you to go further, to handle specific cases
|
||||
# (validation of several interdependent fields, specific getter/setter for a value,
|
||||
# display dynamic informations or choices, pre-loading of config type .cube... ).
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
||||
get__amount() {
|
||||
# Here we can imagine to have an API call to stripe to know the amount of donation during a month
|
||||
local amount = 200
|
||||
|
||||
# It's possible to change some properties of the question by overriding it:
|
||||
if [ $amount -gt 100 ]
|
||||
then
|
||||
cat << EOF
|
||||
style: success
|
||||
value: $amount
|
||||
ask:
|
||||
en: A lot of donation this month: **$amount €**
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
style: danger
|
||||
value: $amount
|
||||
ask:
|
||||
en: Not so much donation this month: $amount €
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
get__prices() {
|
||||
local prices = "$(grep "DONATION\['" "$install_dir/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
|
||||
if [ "$prices" == "," ];
|
||||
then
|
||||
# Return YNH_NULL if you prefer to not return a value at all.
|
||||
echo YNH_NULL
|
||||
else
|
||||
echo $prices
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
validate__publishable_key() {
|
||||
|
||||
# We can imagine here we test if the key is really a publisheable key
|
||||
(is_secret_key $publishable_key) &&
|
||||
echo 'This key seems to be a secret key'
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
set__prices() {
|
||||
|
||||
#---------------------------------------------
|
||||
# IMPORTANT: setter are trigger only if a change is detected
|
||||
#---------------------------------------------
|
||||
for price in $(echo $prices | sed "s/,/ /"); do
|
||||
frequency=$(echo $price | cut -d/ -f1)
|
||||
currency=$(echo $price | cut -d/ -f2)
|
||||
price_id=$(echo $price | cut -d/ -f3)
|
||||
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$install_dir/settings.py"
|
||||
|
||||
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$install_dir/settings.py"
|
||||
done
|
||||
|
||||
#---------------------------------------------
|
||||
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
|
||||
#---------------------------------------------
|
||||
ynh_app_setting_set $app prices $prices
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
ynh_app_config_run $1
|
887
tools/yunopackage/templates/index.html
Normal file
887
tools/yunopackage/templates/index.html
Normal file
|
@ -0,0 +1,887 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheet.css') }}">
|
||||
|
||||
<script>
|
||||
function showForm(element, type) {
|
||||
if (type == 'PHP') {
|
||||
form = 'php_config_file';
|
||||
} else if (type == 'NodeJS') {
|
||||
form = 'nodejs_config';
|
||||
} else if (type == 'Python') {
|
||||
form = 'python_config';
|
||||
} else if (type == 'Python_dependencies') {
|
||||
form = 'python_dependencies_form';
|
||||
} else if (type == 'SystemD') {
|
||||
form = 'systemd_config';
|
||||
} else if (type == 'fail2ban') {
|
||||
form = 'fail2ban_config';
|
||||
} else if (type == 'custom_config') {
|
||||
form = 'custom_config';
|
||||
} else if (type == 'cron') {
|
||||
form = 'cron_config';
|
||||
}
|
||||
|
||||
|
||||
if(element.checked==true) {
|
||||
selects = document.getElementsByClassName(form);
|
||||
for(var i=0, il = selects.length;i<il;i++){
|
||||
selects[i].style.display='inline';
|
||||
}
|
||||
} else {
|
||||
selects = document.getElementsByClassName(form);
|
||||
for(var i=0, il = selects.length;i<il;i++){
|
||||
selects[i].style.display='none';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function showPage(tag,page) {
|
||||
console.log("ERREUR");
|
||||
console.log(tag);
|
||||
console.log(page);
|
||||
document.getElementById(tag).innerHTML = `{{ "{% include 'install.j2' %}" }}`; // This syntax escape the jinja syntax, so it's not changed in the function code (before being injected and then adjusted as a template content)
|
||||
}
|
||||
function clearPage(tag) {
|
||||
document.getElementById(tag).innerHTML = ``;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function copyCodeBlock(code_block) {
|
||||
var codeBlock = document.querySelector(code_block);
|
||||
var codeText = codeBlock.textContent;
|
||||
|
||||
navigator.clipboard.writeText(codeText)
|
||||
.then(function() {
|
||||
alert("Le code a été copié dans le presse-papier !");
|
||||
})
|
||||
.catch(function() {
|
||||
alert("Une erreur s'est produite lors de la copie du code.");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function generateContent(file) {
|
||||
// Generate file content
|
||||
if (file == 'manifest') {
|
||||
console.log("Generating content for manifest file")
|
||||
var template_file_content = {{ template_manifest_content | safe |tojson }};
|
||||
} else if (file == 'install') {
|
||||
console.log("Generating content for install file")
|
||||
var template_file_content = {{ template_install_content | safe |tojson }};
|
||||
} else if (file == 'remove') {
|
||||
console.log("Generating content for remove file")
|
||||
var template_file_content = {{ template_remove_content | safe |tojson }};
|
||||
} else if (file == 'backup') {
|
||||
console.log("Generating content for backup file")
|
||||
var template_file_content = {{ template_backup_content | safe |tojson }};
|
||||
} else if (file == 'restore') {
|
||||
console.log("Generating content for restore file")
|
||||
var template_file_content = {{ template_restore_content | safe |tojson }};
|
||||
} else if (file == 'upgrade') {
|
||||
console.log("Generating content for upgrade file")
|
||||
var template_file_content = {{ template_upgrade_content | safe |tojson }};
|
||||
} else if (file == 'config') {
|
||||
console.log("Generating content for config file")
|
||||
var template_file_content = {{ template_config_content | safe |tojson }};
|
||||
} else if (file == 'change_url') {
|
||||
console.log("Generating content for change_url file")
|
||||
var template_file_content = {{ template_change_url_content | safe |tojson }};
|
||||
} else if (file == 'custom_config_file') {
|
||||
var template_file_content = '{{ parameters['custom_config_file_content'] | safe |tojson }}';
|
||||
} else if (file == 'nginx_config_file') {
|
||||
var template_file_content = '{{ nginx_config_file | safe |tojson }}';
|
||||
} else if (file == 'systemd_config_file') {
|
||||
var template_file_content = '{{ systemd_config_file | safe |tojson }}';
|
||||
} else if (file == 'cron_config_file') {
|
||||
var template_file_content = '{{ cron_config_file | safe |tojson }}';
|
||||
} else {
|
||||
alert("Fichier non prévu")
|
||||
}
|
||||
return template_file_content;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function downloadFile(file) {
|
||||
const content = generateContent(file); // Generate file content (it's not an actual file);
|
||||
const dataUrl = 'data:text/plain;charset=utf-8,' + encodeURIComponent(content);
|
||||
if (file == 'manifest') {
|
||||
link = document.querySelector('#download_manifest');
|
||||
} else if (file == 'install') {
|
||||
link = document.querySelector('#download_install');
|
||||
} else if (file == 'remove') {
|
||||
link = document.querySelector('#download_remove');
|
||||
} else if (file == 'backup') {
|
||||
link = document.querySelector('#download_backup');
|
||||
} else if (file == 'restore') {
|
||||
link = document.querySelector('#download_restore');
|
||||
} else if (file == 'upgrade') {
|
||||
link = document.querySelector('#download_upgrade');
|
||||
} else if (file == 'config') {
|
||||
link = document.querySelector('#download_config');
|
||||
} else if (file == 'change_url') {
|
||||
link = document.querySelector('#download_change_url');
|
||||
} else if (file == 'custom_config_file') {
|
||||
link = document.querySelector('#download_custom_config_file');
|
||||
} else if (file == 'nginx_config_file') {
|
||||
link = document.querySelector('#download_nginx_config_file');
|
||||
} else if (file == 'systemd_config_file') {
|
||||
link = document.querySelector('#download_systemd_config_file');
|
||||
} else if (file == 'cron_config_file') {
|
||||
link = document.querySelector('#download_cron_config_file');
|
||||
} else {
|
||||
alert("Fichier non prévu")
|
||||
}
|
||||
link.href = dataUrl;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function download_zip() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
|
||||
// retrieve variables
|
||||
template_manifest_content = encodeURIComponent( {{ template_manifest_content | safe |tojson }} );
|
||||
template_install_content = encodeURIComponent( {{ template_install_content | safe |tojson }} );
|
||||
template_remove_content = encodeURIComponent( {{ template_remove_content | safe |tojson }} );
|
||||
template_backup_content = encodeURIComponent( {{ template_backup_content | safe |tojson }} );
|
||||
template_restore_content = encodeURIComponent( {{ template_restore_content | safe |tojson }} );
|
||||
template_upgrade_content = encodeURIComponent( {{ template_upgrade_content | safe |tojson }} );
|
||||
template_config_content = encodeURIComponent( {{ template_config_content | safe |tojson }} );
|
||||
template_change_url_content = encodeURIComponent( {{ template_change_url_content | safe |tojson }} );
|
||||
|
||||
custom_config_file = encodeURIComponent( {{ parameters['custom_config_file'] | safe |tojson }} );
|
||||
custom_config_file_content = encodeURIComponent( {{ parameters['custom_config_file_content'] | safe |tojson }} );
|
||||
systemd_config_file = encodeURIComponent( {{ parameters['systemd_config_file'] | safe |tojson }} );
|
||||
nginx_config_file = encodeURIComponent( {{ parameters['nginx_config_file'] | safe |tojson }} );
|
||||
cron_config_file = encodeURIComponent( {{ parameters['cron_config_file'] | safe |tojson }} );
|
||||
use_php = encodeURIComponent( "{{ parameters['use_php'] | safe }}" );
|
||||
php_config_file = encodeURIComponent( {{ parameters['php_config_file'] | safe |tojson }} );
|
||||
php_config_file_content = encodeURIComponent( {{ parameters['php_config_file_content'] | safe |tojson }} );
|
||||
|
||||
// pass the variables back into the python code
|
||||
|
||||
//var url = '/download_as_zip?app_id=' + '{{ parameters['app_id'] }}' + '&template_manifest_content=' + template_manifest_content + '&template_install_content=' + template_install_content + '&template_remove_content=' + template_remove_content + '&template_backup_content=' + template_backup_content + '&template_restore_content=' + template_restore_content + '&template_upgrade_content=' + template_upgrade_content + '&template_config_content=' + template_config_content + '&template_change_url_content=' + template_change_url_content + '&custom_config_file=' + custom_config_file+ '&custom_config_file_content=' + custom_config_file_content + '&nginx_config_file=' + nginx_config_file + '&systemd_config_file=' + systemd_config_file + '&use_php=' + use_php + '&php_config_file=' + php_config_file + '&php_config_file_content=' + php_config_file_content;
|
||||
|
||||
var formData = new FormData();
|
||||
console.log(formData)
|
||||
formData.append('app_id', "{{ parameters['app_id'] }}");
|
||||
console.log(formData)
|
||||
//formData.append('template_manifest_content', template_manifest_content);
|
||||
//formData.append('template_install_content', template_install_content);
|
||||
//formData.append('template_remove_content', template_remove_content);
|
||||
//formData.append('template_backup_content', template_backup_content);
|
||||
//formData.append('template_restore_content', template_restore_content);
|
||||
//formData.append('template_upgrade_content', template_upgrade_content);
|
||||
//formData.append('template_config_content', template_config_content);
|
||||
formData.append('custom_config_file', custom_config_file);
|
||||
formData.append('custom_config_file_content', custom_config_file_content);
|
||||
formData.append('systemd_config_file', systemd_config_file);
|
||||
formData.append('nginx_config_file', nginx_config_file);
|
||||
formData.append('cron_config_file', cron_config_file);
|
||||
formData.append('use_php', use_php);
|
||||
formData.append('php_config_file', php_config_file);
|
||||
formData.append('php_config_file_content', php_config_file_content);
|
||||
var url = '/download_zip?' + new URLSearchParams(formData).toString()
|
||||
|
||||
xhr.open('GET', url, true);
|
||||
//xhr.open('GET', '/download_as_zip', true);
|
||||
xhr.responseType = 'blob';
|
||||
|
||||
console.log('Generating the zip archive using the following parameters:')
|
||||
console.log(url)
|
||||
|
||||
xhr.onload = function() { // onload // onreadystatechange
|
||||
console.log("Running XHR")
|
||||
console.log(xhr.status)
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
var blob = new Blob([xhr.response], { type: 'application/zip' });
|
||||
var url = URL.createObjectURL(blob);
|
||||
var link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = '{{ parameters['app_id'] }}' + '.zip'; // archive name
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} else {
|
||||
alert('Error while generating the zip archive. Error code: ' + xhr.status)
|
||||
}
|
||||
}
|
||||
console.log(xhr)
|
||||
console.log(xhr.status)
|
||||
xhr.send();
|
||||
console.log(xhr)
|
||||
console.log(xhr.status)
|
||||
}
|
||||
</script>
|
||||
<title>My Webpage</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!--
|
||||
<h1>TODO nav bar ?</h1>
|
||||
|
||||
<br>
|
||||
<ul id="navigation">
|
||||
{% for item in navigation %}
|
||||
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
-->
|
||||
|
||||
<p style="text-align: center; margin-left:5%">Version: {{ parameters['GENERATOR_VERSION'] }}</p>
|
||||
<h1 class="message" , style="text-align:center">Formulaire de génération d'une application Yunohost</h1>
|
||||
<form id="main-form" method="POST" action="{{ url_prefix }}/"> <! "action" is not needed to submit on the same page>
|
||||
{{ main_form.hidden_tag() }}
|
||||
|
||||
|
||||
{{ main_form.tutorial.label }} {{ main_form.tutorial() }}
|
||||
{# TODO : this doesn't work, should be changed on the fly. Is it worth the trouble ?
|
||||
{% if main_form.tutorial %}
|
||||
L'application générée contiendra des commentaires additionnels pour faciliter la compréhension
|
||||
{% else %}
|
||||
L'application générée ne contiendra que le minimum nécessaire
|
||||
{% endif %}
|
||||
<br>
|
||||
#}
|
||||
<br>
|
||||
<span><i class="grayed_hint">En mode tutoriel, l'application générée contiendra des commentaires additionnels pour faciliter la compréhension. En version épurée, l'application générée ne contiendra que le minimum nécessaire.</i></span>
|
||||
|
||||
|
||||
<h2>L'application à empaquetter dans Yunohost</h2>
|
||||
<p><i>Cette partie sert à indiquer comment le logiciel est intégré à Yunohost.</i></p>
|
||||
{{ main_form.app_name.label }} {{ main_form.app_name()}}
|
||||
<br>
|
||||
{{ main_form.app_id.label}} {{ main_form.app_id() }} <span>_ynh</span>
|
||||
<br>
|
||||
|
||||
|
||||
<div style="display:flex; text-align:center">
|
||||
{{ main_form.description_en.label}}
|
||||
{{ main_form.description_en(style="height:
|
||||
2.5em;min-height: 2em; max-height: 4em;flex-grow: 1;box-sizing: border-box;")}}
|
||||
</div>
|
||||
<br>
|
||||
<div style="display:flex">
|
||||
{{ main_form.description_fr.label}} {{ main_form.description_fr(style="
|
||||
height:
|
||||
2.5em;min-height: 1em; max-height: 4em;flex-grow: 1;box-sizing: border-box;")}}
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<h2>Intégration</h2>
|
||||
<p><i>Cette partie sert à indiquer comment le logiciel est intégré à Yunohost.</i></p>
|
||||
<br>
|
||||
|
||||
|
||||
{{ main_form.version.label}} {{ main_form.version()}}
|
||||
<br>
|
||||
{{ main_form.maintainers.label}} {{ main_form.maintainers(style="width: 60%;")}}
|
||||
<br>
|
||||
{{ main_form.multi_instance.label}} {{ main_form.multi_instance()}}
|
||||
<br>
|
||||
<div style="display: flex; align-items: center;">
|
||||
{{ main_form.architectures.label}} {{ main_form.architectures()}}
|
||||
</div>
|
||||
<br>
|
||||
{{ main_form.ldap.label}} {{ main_form.ldap()}}
|
||||
<br>
|
||||
{{ main_form.sso.label}} {{ main_form.sso()}}
|
||||
<br>
|
||||
|
||||
<h2>Informations sur le logiciel</h2>
|
||||
<p><i>Cette partie donne des informations génériques sur le logiciel.</i></p>
|
||||
<br>
|
||||
{{ main_form.license.label}} {{ main_form.license()}}
|
||||
<br>
|
||||
{{ main_form.website.label}} {{ main_form.website()}}
|
||||
<br>
|
||||
{{ main_form.demo.label}} {{ main_form.demo()}}
|
||||
<br>
|
||||
{{ main_form.admindoc.label}} {{ main_form.admindoc()}}
|
||||
<br>
|
||||
{{ main_form.userdoc.label}} {{ main_form.userdoc()}}
|
||||
<br>
|
||||
{{ main_form.code.label}} {{ main_form.code()}}
|
||||
|
||||
|
||||
<h2>Paramétrage de l'application</h2>
|
||||
<p><i>Cette partie sert à indiquer comment configurer l'application côté Yunohost.</i></p>
|
||||
|
||||
|
||||
<fieldset name="data_dir_main_form" class="box data_dir_config" style="width:90%;">
|
||||
<legend>Dossier des données</legend>
|
||||
{{ main_form.data_dir.label}} {{ main_form.data_dir()}}
|
||||
<br>
|
||||
{{ main_form.data_subdirs.label}} {{ main_form.data_subdirs()}}
|
||||
<br>
|
||||
</fieldset>
|
||||
{{ main_form.supports_change_url.label}} {{ main_form.supports_change_url()}}
|
||||
<br>
|
||||
|
||||
|
||||
<fieldset name="data_dir_main_form" class="box data_dir_config" style="width:90%;">
|
||||
<legend>Paramètres de langue</legend>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<div style="width: 50%; float:left">
|
||||
{{ main_form.language.label}} {{ main_form.language()}}
|
||||
</div>
|
||||
<div style="width: 50%; float:right">
|
||||
{{ main_form.default_language.label}} {{
|
||||
main_form.default_language()}}
|
||||
|
||||
</div>
|
||||
|
||||
<br style="clear:both;"/>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
||||
|
||||
{{ main_form.visibility.label}} {{ main_form.visibility()}}
|
||||
<br>
|
||||
{{ main_form.use_logrotate.label}} {{ main_form.use_logrotate()}}
|
||||
<br>
|
||||
|
||||
<!-- FAIL2BAN -->
|
||||
{{ main_form.use_fail2ban.label}} {{ main_form.use_fail2ban(onchange="showForm(this, 'fail2ban')")}}
|
||||
|
||||
{%- if parameters['use_fail2ban'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.fail2ban_config {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.fail2ban_config {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="fail2ban_main_form" class="box fail2ban_config" style="width:90%;">
|
||||
<legend>Configuration pour fail2ban</legend>
|
||||
{{ main_form.fail2ban_regex.label}} {{ main_form.fail2ban_regex(style="width:60%;")}}
|
||||
</fieldset>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- CRON -->
|
||||
|
||||
{{ main_form.use_cron.label }} {{ main_form.use_cron(onchange="showForm(this, 'cron')") }}
|
||||
|
||||
{%- if parameters['use_cron'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.cron_config {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.cron_config {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="cron_main_form" class="box cron_config" style="width:90%;">
|
||||
<legend>Configuration pour CRON</legend>
|
||||
{{ main_form.cron_config_file.label}} {{ main_form.cron_config_file()}}
|
||||
</fieldset>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- NGINX -->
|
||||
|
||||
|
||||
<fieldset name="nginx_main_form" class="box nginx_config" style="width:90%;">
|
||||
<legend>Configuration pour le serveur NGINX</legend>
|
||||
{{ main_form.nginx_config_file.label }}<br>
|
||||
{{ main_form.nginx_config_file() }}
|
||||
</fieldset>
|
||||
<br>
|
||||
|
||||
|
||||
<!-- SYSTEMD -->
|
||||
{{ main_form.use_systemd_service.label}} {{ main_form.use_systemd_service(onchange="showForm(this, 'SystemD')")}}
|
||||
<br>
|
||||
|
||||
{%- if parameters['use_systemd_service'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.systemd_config {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.systemd_config {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="systemd_main_form" class="box systemd_config" style="width:90%;">
|
||||
<legend>Configuration pour le service SystemD</legend>
|
||||
{{ main_form.systemd_service_description.label }} {{ main_form.systemd_service_description() }}<br>
|
||||
|
||||
{{ main_form.systemd_config_file.label }}<br>
|
||||
{{ main_form.systemd_config_file() }}
|
||||
</fieldset>
|
||||
<br>
|
||||
|
||||
<!-- CONFIG FILE -->
|
||||
{{ main_form.use_custom_config_file.label}} {{ main_form.use_custom_config_file(onchange="showForm(this,
|
||||
'custom_config')")}}
|
||||
<br>
|
||||
|
||||
{%- if parameters['use_custom_config_file'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.custom_config {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.custom_config {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="custom_config_main_form" class="box custom_config" style="width:90%;">
|
||||
<legend>Fichier de configuration personnalisé</legend>
|
||||
{{ main_form.custom_config_file.label }} {{ main_form.custom_config_file() }}<br>
|
||||
|
||||
{{ main_form.custom_config_file_content.label }}<br>
|
||||
{{ main_form.custom_config_file_content() }}
|
||||
</fieldset>
|
||||
|
||||
|
||||
<!-- how to validate only if both field are checked (or none of them) ?
|
||||
<label for="boolField">Bool Field:</label>
|
||||
<input type="checkbox" id="boolField" name="boolField">
|
||||
<br>
|
||||
|
||||
<label for="requiredField">Required Field:</label>
|
||||
<input type="text" id="requiredField" name="requiredField">
|
||||
<br>
|
||||
|
||||
<script>
|
||||
document.getElementById(document).ready
|
||||
document.getElementById(document).ready(function() {
|
||||
document.getElementById('#myForm').submit(function(event) {
|
||||
var boolField = document.getElementById('#boolField').prop('checked');
|
||||
var requiredField = document.getElementById('#requiredField').val();
|
||||
|
||||
if (boolField && requiredField === '') {
|
||||
event.preventDefault(); // Empêche la soumission du formulaire
|
||||
alert('Le champ requis doit être rempli lorsque le champ booléen est coché.');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script> -->
|
||||
|
||||
|
||||
<h2>Questions à poser pendant l'installation</h2>
|
||||
<p><i>Cette partie sert à indiquer les questions qui devront être posées.</i>
|
||||
<br>
|
||||
<em>NB: seules des questions standard sont proposées ici, il faudra éventuellement compléter à la main en
|
||||
suivant le modèle des autres questions.</em>
|
||||
</p>
|
||||
|
||||
{{ main_form.use_whole_domain.label}} {{ main_form.use_whole_domain()}}
|
||||
<br>
|
||||
|
||||
|
||||
<h2>Source du logiciel et dépendances</h2>
|
||||
|
||||
{{ main_form.source_url.label}} {{ main_form.source_url()}}
|
||||
<br>
|
||||
{{ main_form.sha256sum.label}} {{ main_form.sha256sum()}}
|
||||
<br>
|
||||
{{ main_form.auto_update.label}} {{ main_form.auto_update()}}
|
||||
<br>
|
||||
{{ main_form.dependencies.label}} {{ main_form.dependencies(style="width:40%;")}}
|
||||
<br><br>
|
||||
|
||||
|
||||
{{ main_form.use_db.label }} {{ main_form.use_db() }}
|
||||
<br>
|
||||
|
||||
|
||||
<h3>Utilisation de PHP</h3>
|
||||
{{ main_form.use_php.label}} {{ main_form.use_php(onchange="showForm(this, 'PHP')") }}<br>
|
||||
|
||||
{%- if parameters['use_php'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.php_config_file {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.php_config_file {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="php_main_form" class="box php_config_file" style="width:90%;">
|
||||
<legend>Fichier de configuration pour PHP</legend>
|
||||
{{ main_form.php_config_file.label }} {{ main_form.php_config_file()}}<br>
|
||||
{{ main_form.php_config_file_content.label }} {{ main_form.php_config_file_content()}}<br>
|
||||
<!class="custom-select" TODO fix label>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<h3>Utilisation de NodeJS</h3>
|
||||
{{ main_form.use_nodejs.label}} {{ main_form.use_nodejs(onchange="showForm(this, 'NodeJS')") }} <br>
|
||||
|
||||
{%- if parameters['use_nodejs'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.nodejs_config {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.nodejs_config {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="nodejs_main_form" class="box nodejs_config" style="width:90%;">
|
||||
<legend>Configuration pour NodeJS</legend>
|
||||
{{ main_form.use_nodejs_version.label}} {{ main_form.use_nodejs_version() }} <br>
|
||||
{{ main_form.use_nodejs_needs_yarn.label}} {{ main_form.use_nodejs_needs_yarn() }} <br>
|
||||
|
||||
</fieldset>
|
||||
|
||||
|
||||
<h3>Utilisation de Python</h3>
|
||||
{{ main_form.use_python.label}} {{ main_form.use_python(onchange="showForm(this, 'Python')") }} <br>
|
||||
|
||||
{%- if parameters['use_python'] == True -%} {# Not shown by default, so we show it if needed #}
|
||||
<style>.python_config {display:inline;}</style>
|
||||
{%- else -%}
|
||||
<style>.python_config {display:none;}</style>
|
||||
{%- endif -%}
|
||||
<fieldset name="python_main_form" class="box python_config" style="width:90%;">
|
||||
<legend>Configuration pour Python</legend>
|
||||
{{ main_form.python_dependencies_type.label}} {{ main_form.python_dependencies_type(onchange="showForm(this,
|
||||
'Python_dependencies')") }} <br>
|
||||
|
||||
<div name="python_dependencies_form"> <!-- TODO : this has to be changed by Javascript-->
|
||||
{%- if parameters['python_dependencies_type'] == 'requirements.txt' -%}
|
||||
{{ main_form.python_requirements.label}} {{ main_form.python_requirements() }}
|
||||
{%- else -%}
|
||||
{{ main_form.python_dependencies_list.label}} {{ main_form.python_dependencies_list() }}
|
||||
{%- endif -%}
|
||||
<br>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Submit button -->
|
||||
<br>
|
||||
{{ main_form.submit(class="btn btn-primary btn-sm btn-center") }}
|
||||
|
||||
{% if parameters['invalid_form'] %}
|
||||
<p class="alert">Formulaire invalide, veuillez vérifier quel champ contient une erreur svp.</p>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
{% if parameters['preview'] %} {# is defined #}
|
||||
<details>
|
||||
<summary>Afficher le code des fichiers principaux</summary>
|
||||
<h1>Voici le code de l'application <i>{{parameters['app.name']}}</i></h1>
|
||||
|
||||
|
||||
<!input id="clear_install" type="button" value="Cacher" onclick="clearPage('install_page','install.j2')">
|
||||
<!input id="show_install" type="button" value="Afficher" onclick="showPage('install_page')">
|
||||
|
||||
<!-- manifest -->
|
||||
<h2>Manifeste <i class="grayed_hint">(manifest.toml)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="manifest_code">
|
||||
{% set lines = template_manifest_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#manifest_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `manifest.toml`.">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_manifest" download="manifest.toml" onclick="downloadFile('manifest')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le manifeste</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- install -->
|
||||
<h2>Script d'installation <i class="grayed_hint">(install)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="install_code">
|
||||
{% set lines = template_install_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#install_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `install` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_install" download="install" onclick="downloadFile('install')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script d'installation</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- remove -->
|
||||
<h2>Script de suppression <i class="grayed_hint">(remove)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="remove_code">
|
||||
{% set lines = template_remove_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#remove_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `remove` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_remove" download="remove" onclick="downloadFile('remove')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script de suppression</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- backup -->
|
||||
<h2>Script de sauvegarde <i class="grayed_hint">(backup)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="backup_code">
|
||||
{% set lines = template_backup_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#backup_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `backup` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_backup" download="backup" onclick="downloadFile('backup')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script de sauvegarde</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- restore -->
|
||||
<h2>Script de restauration <i class="grayed_hint">(restore)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="restore_code">
|
||||
{% set lines = template_restore_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#restore_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `restore` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_restore" download="restore" onclick="downloadFile('restore')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script de restauration</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- upgrade -->
|
||||
<h2>Script de mise à jour <i class="grayed_hint">(upgrade)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="upgrade_code">
|
||||
{% set lines = template_upgrade_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#upgrade_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `upgrade` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_upgrade" download="upgrade" onclick="downloadFile('upgrade')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script de mise à jour</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- config -->
|
||||
<h2>Script de configuration spéciale <i class="grayed_hint">(config)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="config_code">
|
||||
{% set lines = template_config_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#config_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `config` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_config" download="config" onclick="downloadFile('config')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script de configuration spéciale</button>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- change_url -->
|
||||
{%- if template_change_url_content -%}
|
||||
<h2>Script de changement d'URL <i class="grayed_hint">(change_url)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="change_url_code">
|
||||
{% set lines = template_change_url_content.splitlines() %}
|
||||
{% for line in lines %} {{ line }}
|
||||
{% endfor %}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#change_url_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `change_url` (sans extension).">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_change_url" download="change_url" onclick="downloadFile('change_url')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le script de changement d'URL</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- systemd_config_file -->
|
||||
{%- if systemd_config_file -%}
|
||||
<h2>Fichier de configuration du service SystemD <i class="grayed_hint">(systemd.service)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="systemd_config_file_code">
|
||||
{{parameters['systemd_config_file']}}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#systemd_config_file_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `systemd.service`, à placer dans le dossier `conf`.">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_systemd_config_file" download="systemd_config_file"
|
||||
onclick="downloadFile('systemd_config_file')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le fichier de configuration du service SystemD</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- nginx_config_file -->
|
||||
{%- if nginx_config_file -%}
|
||||
<h2>Fichier de configuration de NGINX <i class="grayed_hint">(nginx.conf)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="nginx_config_file_code">
|
||||
{{parameters['nginx_config_file']}}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#nginx_config_file_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `nginx.conf`, à placer dans le dossier `conf`.">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_nginx_config_file" download="nginx_config_file"
|
||||
onclick="downloadFile('nginx_config_file')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le fichier de configuration d'NGINX</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- custom_config_file -->
|
||||
{%- if custom_config_file -%}
|
||||
<h2>Fichier de configuration personnalisé <i class="grayed_hint">({{custom_config_file}})</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="custom_config_file_code">
|
||||
{{parameters['custom_config_file_content']}}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#custom_config_file_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `{{custom_config_file}}`, à placer dans le dossier `conf`.">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_custom_config_file" download="custom_config_file"
|
||||
onclick="downloadFile('custom_config_file')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le fichier de configuration personnalisé</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- cron_config_file -->
|
||||
{%- if cron_config_file -%}
|
||||
<h2>Fichier de configuration de tâche CRON <i class="grayed_hint">(task.cron)</i></h2>
|
||||
<div class="code-block">
|
||||
<pre>
|
||||
<code id="cron_config_file_code">
|
||||
{{parameters['cron_config_file']}}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<button onclick="copyCodeBlock('#cron_config_file_code')"
|
||||
title="Mettre dans le presse-papier. Il faudra alors le coller dans un fichier nommé `task.cron`, à placer dans le dossier `conf`.">
|
||||
📋 Copier le code
|
||||
</button>
|
||||
<! paperclip emoji>
|
||||
<a href="#" id="download_cron_config_file" download="cron_config_file"
|
||||
onclick="downloadFile('cron_config_file')"
|
||||
title="Enregistrer le fichier sur votre ordinateur.">
|
||||
<button>💾 Télécharger le fichier de configuration de la tâche CRON</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!--
|
||||
End of file content part.
|
||||
-->
|
||||
</details>
|
||||
|
||||
<p>
|
||||
<button id="download_as_zip" class="btn btn-primary btn-sm" style="font-size: large;"
|
||||
title="Enregistrer tous les fichiers sur votre ordinateur." onclick="download_zip()">
|
||||
💾 Télécharger tous les fichiers de l'application (archive .zip)
|
||||
</button>
|
||||
</p>
|
||||
<!--
|
||||
End of the result part
|
||||
-->
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
|
||||
<footer class="py-3 mt-auto" style="margin-left: 38% ;margin-top:30px">
|
||||
<nav>
|
||||
<ul class="nav" style="text-align:center;">
|
||||
<li class="nav-item" style="float:left"><a href="https://yunohost.org/docs"
|
||||
rel="noopener" target="_blank"
|
||||
class="nav-link text-secondary"><span data-v-d85b127e=""
|
||||
data-v-ae4f6aeb=""
|
||||
aria-hidden="true"
|
||||
class="icon fa fa-book"></span>
|
||||
Documentation </a></li>
|
||||
<li class="nav-item" style="float:left"><a href="https://yunohost.org/"
|
||||
rel="noopener" target="_blank"
|
||||
class="nav-link text-secondary"><span data-v-d85b127e=""
|
||||
data-v-ae4f6aeb=""
|
||||
aria-hidden="true"
|
||||
class="icon fa fa-life-ring"></span>
|
||||
Découvrir Yunohost </a></li>
|
||||
<li class="nav-item" style="justify-content:right"><a href="https://donate.yunohost.org/"
|
||||
rel="noopener" target="_blank"
|
||||
class="nav-link text-secondary"><span
|
||||
data-v-d85b127e=""
|
||||
data-v-ae4f6aeb=""
|
||||
aria-hidden="true"
|
||||
class="icon fa fa-heart"></span>
|
||||
Faire un don </a></li>
|
||||
<li id="generator-version" class="navbar-text" style="display: inline-block; margin-left: auto">Propulsé par
|
||||
YoloGen {{ parameters['GENERATOR_VERSION']}}.
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</footer>
|
||||
</html>
|
284
tools/yunopackage/templates/install.j2
Normal file
284
tools/yunopackage/templates/install.j2
Normal file
|
@ -0,0 +1,284 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# Install parameters are automatically saved as settings
|
||||
#
|
||||
# Settings are automatically loaded as bash variables
|
||||
# in every app script context, therefore typically these will exist:
|
||||
# - $domain
|
||||
# - $path
|
||||
# - $language
|
||||
# ... etc
|
||||
#
|
||||
# Resources defined in the manifest are provisioned prior to this script
|
||||
# and corresponding settings are also available, such as:
|
||||
# - $install_dir
|
||||
# - $port
|
||||
# - $db_name
|
||||
# ...
|
||||
|
||||
#
|
||||
# $app is the app id (i.e. 'example' for first install,
|
||||
# or 'example__2', '__3', ... for multi-instance installs)
|
||||
#
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||
|
||||
{% if parameters["use_nodejs_needs_yarn"] -%}
|
||||
# Install Nodejs
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||
### downloaded from an upstream source, like a git repository.
|
||||
### `ynh_setup_source` use the file conf/app.src
|
||||
{% endif -%}
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# $install_dir will automatically be initialized with some decent
|
||||
# permission by default ... however, you may need to recursively reapply
|
||||
# ownership to all files such as after the ynh_setup_source step
|
||||
{% endif -%}
|
||||
chown -R $app:www-data "$install_dir" {# TODO : we may need to allow people to configure this #}
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
{% if use_php -%}
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### `ynh_add_fpm_config` is used to set up a PHP config.
|
||||
### You can remove it if your app doesn't use PHP.
|
||||
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
||||
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
||||
### with the reload at the end of the script.
|
||||
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
||||
### But wait : This should have been handled by our app generator ;)
|
||||
{% endif -%}
|
||||
|
||||
ynh_script_progression --message="Adding {{php_version}} configurations related to $app..." --weight=1
|
||||
# Create a dedicated PHP-FPM config using the conf/php-fpm.conf or conf/extra_php-fpm.conf
|
||||
ynh_add_fpm_config
|
||||
{% endif -%}
|
||||
|
||||
|
||||
{% if use_php -%}
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### `ynh_add_fpm_config` is used to set up a PHP config.
|
||||
### You can remove it if your app doesn't use PHP.
|
||||
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
||||
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
||||
### with the reload at the end of the script.
|
||||
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
||||
{% endif -%}
|
||||
|
||||
ynh_script_progression --message="Adding {{php_version}} configurations related to $app..." --weight=1
|
||||
# Create a dedicated PHP-FPM config using the conf/php-fpm.conf or conf/extra_php-fpm.conf
|
||||
ynh_add_fpm_config
|
||||
{% endif -%}
|
||||
|
||||
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||
ynh_add_nginx_config
|
||||
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
{% if version == "tutorial" -%}
|
||||
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
||||
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
||||
### Have a look at the app to be sure this app needs a systemd script.
|
||||
### `ynh_systemd_config` will use the file conf/systemd.service
|
||||
### If you're not using these lines:
|
||||
### - You can remove those files in conf/.
|
||||
### - Remove the section "BACKUP SYSTEMD" in the backup script
|
||||
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
|
||||
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
||||
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||
{% endif -%}
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||
### displayed in the admin interface and through the others `yunohost service` commands.
|
||||
### (N.B.: this line only makes sense if the app adds a service to the system!)
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
|
||||
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
|
||||
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
|
||||
{% endif -%}
|
||||
|
||||
yunohost service add $app --description="{{ parameters['systemd_service_description'] }}" --log="/var/log/$app/$app.log"
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### Additional options starting with 3.8:
|
||||
###
|
||||
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
|
||||
### which will then be checked by YunoHost's diagnosis system
|
||||
### (N.B. DO NOT USE THIS is the port is only internal!!!)
|
||||
###
|
||||
### --test_status "some command" a custom command to check the status of the service
|
||||
### (only relevant if 'systemctl status' doesn't do a good job)
|
||||
###
|
||||
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
|
||||
###
|
||||
### Re-calling 'yunohost service add' during the upgrade script is the right way
|
||||
### to proceed if you later realize that you need to enable some flags that
|
||||
### weren't enabled on old installs (be careful it'll override the existing
|
||||
### service though so you should re-provide all relevant flags when doing so)
|
||||
|
||||
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
||||
### Use this helper only if there is effectively a log file for this app.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
||||
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
|
||||
### - And the section "SETUP LOGROTATE" in the upgrade script
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
{% if parameters["use_fail2ban"] -%}
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="{{ parameters['fail2ban_regex'] }}"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_cron"] -%}
|
||||
#=================================================
|
||||
# ADD A CRON JOB
|
||||
#=================================================
|
||||
cron_path="/etc/cron.d/$app"
|
||||
ynh_add_config --template="../conf/task.cron" --destination="$cron_path"
|
||||
chown root: "$cron_path"
|
||||
chmod 644 "$cron_path"
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# APP INITIAL CONFIGURATION
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### You can add specific configuration files.
|
||||
###
|
||||
### Typically, put your template conf file in ../conf/your_config_file
|
||||
### The template may contain strings such as __FOO__ or __FOO_BAR__,
|
||||
### which will automatically be replaced by the values of $foo and $foo_bar
|
||||
###
|
||||
### ynh_add_config will also keep track of the config file's checksum,
|
||||
### which later during upgrade may allow to automatically backup the config file
|
||||
### if it's found that the file was manually modified
|
||||
###
|
||||
### Check the documentation of `ynh_add_config` for more info.
|
||||
{% endif -%}
|
||||
|
||||
ynh_add_config --template="{{ parameters['custom_config_file'] }}" --destination="$install_dir/{{ parameters['custom_config_file'] }}"
|
||||
|
||||
# FIXME: this should be handled by the core in the future
|
||||
# You may need to use chmod 600 instead of 400,
|
||||
# for example if the app is expected to be able to modify its own config
|
||||
chmod 400 "$install_dir/{{ parameters['custom_config_file'] }}"
|
||||
chown $app:$app "$install_dir/{{ parameters['custom_config_file'] }}"
|
||||
|
||||
### For more complex cases where you want to replace stuff using regexes,
|
||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||
###
|
||||
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||
|
||||
{% if parameters["use_nodejs_needs_yarn"] -%}
|
||||
#=================================================
|
||||
# INSTALL YARN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing yarn dependency..." --weight=15
|
||||
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install
|
||||
popd
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### Use these lines only if the app installation needs to be finalized through
|
||||
### web forms. We generally don't want to ask the final user,
|
||||
### so we're going to use curl to automatically fill the fields and submit the
|
||||
### forms.
|
||||
{% endif -%}
|
||||
|
||||
#### TODO in Yunohost App Generator
|
||||
# Installation with curl
|
||||
ynh_script_progression --message="Finalizing installation..." --weight=1
|
||||
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
|
||||
{% if version == "tutorial" -%}
|
||||
### `ynh_systemd_action` is used to start a systemd service for an app.
|
||||
### Only needed if you have configure a systemd service
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
|
||||
### - As well as the section "START SYSTEMD SERVICE" in the restore script
|
||||
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
|
||||
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
|
||||
{% endif -%}
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
179
tools/yunopackage/templates/manifest.j2
Normal file
179
tools/yunopackage/templates/manifest.j2
Normal file
|
@ -0,0 +1,179 @@
|
|||
packaging_format = 2
|
||||
|
||||
id = "{{ parameters['app_id'] }}"
|
||||
name = "{{ parameters['app_name'] }}"
|
||||
|
||||
{% if parameters['tutorial'] -%}
|
||||
{% endif -%}
|
||||
|
||||
|
||||
description.en = "{{ parameters['description_en'] }}"
|
||||
description.fr = "{{ parameters['description_fr'] }}"
|
||||
|
||||
version = "{{ parameters['version'] }}"
|
||||
|
||||
maintainers = ["{{ parameters['maintainers'] }}"]
|
||||
|
||||
[upstream]
|
||||
# NB: Only the "license" key is mandatory. Remove entries for which there's no relevant data
|
||||
license = "{{ parameters['license'] }}"
|
||||
website = "{{ parameters['website'] }}"
|
||||
demo = "{{ parameters['demo'] }}"
|
||||
admindoc = "{{ parameters['admindoc'] }}"
|
||||
userdoc = "{{ parameters['userdoc'] }}"
|
||||
code = "{{ parameters['code'] }}"
|
||||
# FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, YunoHost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||
cpe = "???"
|
||||
# FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||
fund = "???"
|
||||
|
||||
|
||||
[integration]
|
||||
{% if parameters['yunohost_required_version'] -%}
|
||||
yunohost = '>= {{ parameters['yunohost_required_version'] }}'
|
||||
{% else -%}
|
||||
yunohost = ">= 11.1.21"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters['tutorial'] -%}
|
||||
# List of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386']
|
||||
{% endif -%}
|
||||
architectures = "{{ parameters['architectures'] }}" # TODO : handle the "all" option (no ["all"])
|
||||
multi_instance = {{ parameters['multi_instance'] }}
|
||||
ldap = {{ parameters['ldap'] }}
|
||||
sso = {{ parameters['sso'] }}
|
||||
# FIXME: replace with an **estimate** minimum disk and RAM requirements. e.g. 20M, 400M, 1G... You may have have a look at CI results
|
||||
disk = "50M"
|
||||
ram.build = "50M"
|
||||
ram.runtime = "50M"
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
{% endif -%}
|
||||
type = "domain"
|
||||
|
||||
{% if not parameters['use_whole_domain'] -%}
|
||||
[install.path]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
{% endif -%}
|
||||
type = "path"
|
||||
default = "/example"
|
||||
{% endif -%}
|
||||
|
||||
[install.init_main_permission]
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
# This won't be saved as setting and will instead be used to initialize the SSOwat permission
|
||||
type = "group"
|
||||
default = "{{ parameters['visibility'] }}"
|
||||
|
||||
[install.language]
|
||||
ask.en = "Choose the application language"
|
||||
ask.fr = "Choisissez la langue de l'application"
|
||||
type = "select"
|
||||
choices = {{ parameters['language'] |safe }}
|
||||
default = "{{ parameters['default_language'] }}"
|
||||
|
||||
[install.admin]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
type = "user"
|
||||
{% endif -%}
|
||||
|
||||
[install.password]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
# Note that user-provided passwords questions are not automatically saved as setting
|
||||
{% endif -%}
|
||||
help.en = "Use the help field to add an information for the admin about this question."
|
||||
help.fr = "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
|
||||
type = "password"
|
||||
|
||||
[resources]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# See the packaging documentation for the full set
|
||||
# of explanation regarding the behavior and properties for each of those
|
||||
{% endif -%}
|
||||
|
||||
[resources.sources]
|
||||
|
||||
[resources.sources.main]
|
||||
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
|
||||
# ynh_setup_source --dest_dir="$install_dir"
|
||||
# You can also define other assets than "main" and add --source_id="foobar" in the previous command
|
||||
url = "{{parameters['source_url']}}"
|
||||
sha256 = "{{parameters['sha256sum']}}"
|
||||
|
||||
# These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py
|
||||
# to auto-update the previous asset urls and sha256sum + manifest version
|
||||
# assuming the upstream's code repo is on github and relies on tags or releases
|
||||
# See the 'sources' resource documentation for more details
|
||||
|
||||
{% if parameters['auto_update'] -%}
|
||||
autoupdate.strategy = "latest_github_tag"
|
||||
{% else -%}
|
||||
# autoupdate.strategy = "latest_github_tag"
|
||||
{% endif -%}
|
||||
|
||||
[resources.system_user]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will provision/deprovision a unix system user
|
||||
{% endif -%}
|
||||
|
||||
[resources.install_dir]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will create/remove the install dir as /var/www/$app
|
||||
# and store the corresponding setting $install_dir
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters['data_dir'] %}
|
||||
[resources.data_dir]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will create/remove the data dir as /home/yunohost.app/$app
|
||||
# and store the corresponding setting $data_dir
|
||||
{% endif -%}
|
||||
{% if parameters['data_subdirs'] -%}
|
||||
subdirs = {{ parameters['data_subdirs'].split(",") |safe}}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
|
||||
[resources.permissions]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will configure SSOwat permission for $domain/$path/
|
||||
# The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users)
|
||||
{% endif -%}
|
||||
main.url = "/"
|
||||
|
||||
[resources.ports]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will pick a random port for reverse-proxying and store it as the $port setting
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters['dependencies'] or parameters['use_nodejs_needs_yarn'] -%}
|
||||
[resources.apt]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will automatically install/uninstall the following apt packages
|
||||
# and implicitly define the $phpversion setting as 8.0 (if phpX.Y-foobar dependencies are listed)
|
||||
{% endif -%}
|
||||
packages = "{{ parameters['dependencies'] }} {% if parameters['use_db'] != 'false' -%} {{ parameters['use_db'] }} {% endif -%}"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters['tutorial'] -%}
|
||||
{% if parameters['use_nodejs_needs_yarn'] -%}
|
||||
# This will configure an extra repository to install yarn dependency
|
||||
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
|
||||
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
extras.yarn.packages = "yarn"
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters['use_db'] != 'false' -%}
|
||||
[resources.database]
|
||||
{% if parameters['tutorial'] -%}
|
||||
# This will automatically provision/deprovison a database and store the corresponding credentials in settings $db_user, $db_name, $db_pwd
|
||||
{% endif -%}
|
||||
type = "{{ parameters['use_db'] }}"
|
||||
{% endif -%}
|
||||
|
79
tools/yunopackage/templates/remove.j2
Normal file
79
tools/yunopackage/templates/remove.j2
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# Settings are automatically loaded as bash variables
|
||||
# in every app script context, therefore typically these will exist:
|
||||
# - $domain
|
||||
# - $path
|
||||
# - $language
|
||||
# - $install_dir
|
||||
# - $port
|
||||
# ...
|
||||
|
||||
# For remove operations :
|
||||
# - the core will deprovision every resource defined in the manifest **after** this script is ran
|
||||
# this includes removing the install directory, and data directory (if --purge was used)
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# This should be a symetric version of what happens in the install script
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
ynh_remove_systemd_config
|
||||
{% endif -%}
|
||||
|
||||
ynh_remove_nginx_config
|
||||
|
||||
{% if parameters["use_php"] -%}
|
||||
ynh_remove_fpm_config
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_logrotate"] -%}
|
||||
ynh_remove_logrotate
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_fail2ban"] -%}
|
||||
ynh_remove_fail2ban_config
|
||||
{% endif -%}
|
||||
|
||||
# Remove other various files specific to the app... such as :
|
||||
{% if parameters["use_cron"] -%}
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
{% endif -%}
|
||||
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
115
tools/yunopackage/templates/restore.j2
Normal file
115
tools/yunopackage/templates/restore.j2
Normal file
|
@ -0,0 +1,115 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# $install_dir will automatically be initialized with some decent
|
||||
# permission by default ... however, you may need to recursively reapply
|
||||
# ownership to all files such as after the ynh_setup_source step
|
||||
{% endif -%}
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
{% if parameters["data_dir"] -%}
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
|
||||
# (Same as for install dir)
|
||||
chown -R $app:www-data "$data_dir"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_db"] -%}
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
{% if parameters["use_db"] == 'mysql' -%}
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_db"] == 'postgresql' -%}
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
|
||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
# This should be a symetric version of what happens in the install script
|
||||
|
||||
{% if parameters["use_php"] -%}
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
{% endif -%}
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
yunohost service add $app --description="{{ parameters['systemd_service_description'] }}" --log="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_logrotate"] -%}
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
{% endif -%}
|
||||
{% if parameters["use_fail2ban"] -%}
|
||||
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||
{% endif -%}
|
||||
# Other various files...
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
ynh_restore_file --origin_path="/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
# Typically you only have either $app or php-fpm but not both at the same time...
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
{% if parameters["use_php"] -%}
|
||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||
{% endif -%}
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
180
tools/yunopackage/templates/upgrade.j2
Normal file
180
tools/yunopackage/templates/upgrade.j2
Normal file
|
@ -0,0 +1,180 @@
|
|||
#!/bin/bash
|
||||
#### App file generated with YoloGen, the Yunohost app generator, version {{ parameters['GENERATOR_VERSION'] }}.
|
||||
{% if parameters["tutorial"] -%} # This is the tutorial version of the app.
|
||||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# Settings are automatically loaded as bash variables
|
||||
# in every app script context, therefore typically these will exist:
|
||||
# - $domain
|
||||
# - $path
|
||||
# - $language
|
||||
# - $install_dir
|
||||
# - $port
|
||||
# ...
|
||||
|
||||
# In the context of upgrade,
|
||||
# - resources are automatically provisioned / updated / deleted (depending on existing resources)
|
||||
# - a safety backup is automatically created by the core and will be restored if the upgrade fails
|
||||
|
||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||
### $upgrade_type can have 2 different values
|
||||
### - UPGRADE_APP if the upstream app version has changed
|
||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||
{% endif -%}
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
{% if parameters["tutorial"] -%}
|
||||
#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
#
|
||||
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
|
||||
# of what you may want to do in some cases (e.g. a setting was not defined on
|
||||
# some legacy installs and you therefore want to initialize stuff during upgrade)
|
||||
#
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
#if [ -z "$db_name" ]; then
|
||||
# db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
#fi
|
||||
|
||||
# If install_dir doesn't exist, create it
|
||||
#if [ -z "$install_dir" ]; then
|
||||
# install_dir=/var/www/$app
|
||||
# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||
#fi
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# $install_dir will automatically be initialized with some decent
|
||||
# permission by default ... however, you may need to recursively reapply
|
||||
# ownership to all files such as after the ynh_setup_source step
|
||||
{% endif -%}
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# This should be a literal copypasta of what happened in the install's "System configuration" section
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_php"] -%}
|
||||
ynh_add_fpm_config
|
||||
{% endif -%}
|
||||
|
||||
ynh_add_nginx_config
|
||||
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
ynh_add_systemd_config
|
||||
|
||||
yunohost service add $app --description="{{ parameters['systemd_service_description'] }}" --log="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_logrotate"] -%}
|
||||
ynh_use_logrotate --non-append
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_fail2ban"] -%}
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="{{ parameters['fail2ban_regex'] }}"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_cron"] -%}
|
||||
#=================================================
|
||||
# UPDATE THE CRON JOB
|
||||
#=================================================
|
||||
cron_path="/etc/cron.d/$app"
|
||||
ynh_add_config --template="../conf/task.cron" --destination="$cron_path"
|
||||
chown root: "$cron_path"
|
||||
chmod 644 "$cron_path"
|
||||
{% endif -%}
|
||||
|
||||
#=================================================
|
||||
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
### Same as during install
|
||||
###
|
||||
### The file will automatically be backed-up if it's found to be manually modified (because
|
||||
### ynh_add_config keeps track of the file's checksum)
|
||||
{% endif -%}
|
||||
|
||||
ynh_add_config --template="{{ parameters['custom_config_file'] }}" --destination="$install_dir/{{ parameters['custom_config_file'] }}"
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
# FIXME: this should be handled by the core in the future
|
||||
# You may need to use chmod 600 instead of 400,
|
||||
# for example if the app is expected to be able to modify its own config
|
||||
{% endif -%}
|
||||
chmod 400 "$install_dir/some_config_file"
|
||||
chown $app:$app "$install_dir/some_config_file"
|
||||
|
||||
{% if parameters["tutorial"] -%}
|
||||
### For more complex cases where you want to replace stuff using regexes,
|
||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||
###
|
||||
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||
{% endif -%}
|
||||
|
||||
{% if parameters["use_systemd_service"] -%}
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
{% endif -%}
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
Loading…
Add table
Reference in a new issue