mirror of
https://github.com/YunoHost-Apps/meilisearch_ynh.git
synced 2024-09-03 19:45:59 +02:00
first commit
This commit is contained in:
commit
3ac49da244
19 changed files with 1078 additions and 0 deletions
5
.idea/.gitignore
vendored
Normal file
5
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
12
.idea/meilisearch_ynh.iml
Normal file
12
.idea/meilisearch_ynh.iml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/meilisearch_ynh.iml" filepath="$PROJECT_DIR$/.idea/meilisearch_ynh.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
0
LICENCE
Normal file
0
LICENCE
Normal file
0
README
Normal file
0
README
Normal file
6
conf/app.src
Normal file
6
conf/app.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=__SRC__
|
||||||
|
SOURCE_SUM=__SUM__
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
17
conf/nginx.conf
Normal file
17
conf/nginx.conf
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||||
|
location __PATH__/ {
|
||||||
|
|
||||||
|
proxy_pass http://127.0.0.1:__PORT__;
|
||||||
|
|
||||||
|
# Path to source
|
||||||
|
alias __FINALPATH__/ ;
|
||||||
|
|
||||||
|
# Force usage of https
|
||||||
|
if ($scheme = http) {
|
||||||
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
|
}
|
13
conf/systemd.service
Normal file
13
conf/systemd.service
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine
|
||||||
|
After=systemd-user-sessions.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=__APP__
|
||||||
|
Group=__APP__
|
||||||
|
WorkingDirectory=__FINALPATH__/
|
||||||
|
ExecStart=/usr/bin/mailisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __API_KEY__
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
74
manifest.json
Normal file
74
manifest.json
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
{
|
||||||
|
"name": "MeiliSearch",
|
||||||
|
"id": "meilisearch",
|
||||||
|
"packaging_format": 1,
|
||||||
|
"description": {
|
||||||
|
"en": "Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine.",
|
||||||
|
"fr": "Moteur de recherche rapide, ultra-performant et tolérant aux fautes de frappe."
|
||||||
|
},
|
||||||
|
"version": "0.10.1~ynh1",
|
||||||
|
"url": "https://www.meilisearch.com/",
|
||||||
|
"license": "free",
|
||||||
|
"maintainer": {
|
||||||
|
"name": "Julien Gomes Dias",
|
||||||
|
"email": "abld@abld.info",
|
||||||
|
"url": "https://julien.gomes-dias.dev"
|
||||||
|
},
|
||||||
|
"requirements": {
|
||||||
|
"yunohost": ">= 3.5"
|
||||||
|
},
|
||||||
|
"multi_instance": true,
|
||||||
|
"services": [
|
||||||
|
"nginx"
|
||||||
|
],
|
||||||
|
"arguments": {
|
||||||
|
"install" : [
|
||||||
|
{
|
||||||
|
"name": "domain",
|
||||||
|
"type": "domain",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a domain name for Meilisearch",
|
||||||
|
"fr": "Choisissez un nom de domaine pour Meilisearch"
|
||||||
|
},
|
||||||
|
"example": "example.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "path",
|
||||||
|
"type": "path",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a path for Meilisearch",
|
||||||
|
"fr": "Choisissez un chemin pour Meilisearch"
|
||||||
|
},
|
||||||
|
"example": "/mailisearch",
|
||||||
|
"default": "/mailisearch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is_public",
|
||||||
|
"type": "boolean",
|
||||||
|
"ask": {
|
||||||
|
"en": "Is it a public application?",
|
||||||
|
"fr": "Est-ce une application publique ?"
|
||||||
|
},
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "master_key",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a master API key for Meilisearch",
|
||||||
|
"fr": "Choisissez un nom de domaine pour Meilisearch"
|
||||||
|
},
|
||||||
|
"example": "API-key245678635248795"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "data_path",
|
||||||
|
"type": "path",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a path (existing or not) for Meilisearch data files (absolute path)",
|
||||||
|
"fr": "Choisissez un dossier existant ou non pour les fichiers de données de Meilisearch (chemin absolu)"
|
||||||
|
},
|
||||||
|
"example": "/var/www/mailisearch",
|
||||||
|
"default": "/var/www/mailisearch"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
20
scripts/_common.sh
Normal file
20
scripts/_common.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
latest="v0.10.1"
|
||||||
|
|
||||||
|
installation_mailisearch() {
|
||||||
|
arch=$()
|
||||||
|
url=""
|
||||||
|
if [[ $arch = "amd64" ]]
|
||||||
|
then
|
||||||
|
url="meilisearch-linux-amd64"
|
||||||
|
elif [ $arch = "armv8"]
|
||||||
|
url="meilisearch-linux-armv8"
|
||||||
|
else
|
||||||
|
ynh_die --message="Your OS Architecture is not supported"
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl https://github.com/meilisearch/MeiliSearch/releases/download/$latest/mailisearch-linux-$arch -O mailisearch
|
||||||
|
mv mailisearch /usr/bin/mailisearch
|
||||||
|
|
||||||
|
}
|
99
scripts/backup
Normal file
99
scripts/backup
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP FAIL2BAN CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||||
|
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC BACKUP
|
||||||
|
#=================================================
|
||||||
|
# BACKUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP A CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
|
128
scripts/change_url
Normal file
128
scripts/change_url
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
|
old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
|
new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
|
new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
change_domain=0
|
||||||
|
if [ "$old_domain" != "$new_domain" ]
|
||||||
|
then
|
||||||
|
change_domain=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
change_path=0
|
||||||
|
if [ "$old_path" != "$new_path" ]
|
||||||
|
then
|
||||||
|
change_path=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY URL IN NGINX CONF
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
# Change the path in the nginx config file
|
||||||
|
if [ $change_path -eq 1 ]
|
||||||
|
then
|
||||||
|
# Make a backup of the original nginx config file if modified
|
||||||
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
|
# Set global variables for nginx helper
|
||||||
|
domain="$old_domain"
|
||||||
|
path_url="$new_path"
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change the domain for nginx
|
||||||
|
if [ $change_domain -eq 1 ]
|
||||||
|
then
|
||||||
|
# Delete file checksum for the old conf file location
|
||||||
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
|
# Store file checksum for the new config file location
|
||||||
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALISATION
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
226
scripts/install
Normal file
226
scripts/install
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
master_key=$YNH_APP_ARG_MASTER_KEY
|
||||||
|
data_path=$YNH_APP_ARG_DATA_PATH
|
||||||
|
i_data_path=$YNH_APP_ARG_I_DATA_PATH
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||||
|
|
||||||
|
|
||||||
|
final_path=/var/www/$app
|
||||||
|
|
||||||
|
if [ $i_data_path -ne 0 ]
|
||||||
|
then
|
||||||
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
else
|
||||||
|
test ! -e "$data_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Register (book) web path
|
||||||
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
|
ynh_app_setting_set --app=$app --key=master_key --value=$master_key
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# FIND AND OPEN A PORT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Configuring firewall..." --time --weight=1
|
||||||
|
|
||||||
|
# Find an available port
|
||||||
|
port=$(ynh_find_port --port=8095)
|
||||||
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD AND INSTALL MAILISEARCH
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installing mailisearch..." --time --weight=1
|
||||||
|
installation_mailisearch()
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
### `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
|
||||||
|
|
||||||
|
ynh_replace_string "__PORT__" "$port" "conf/systemd.service"
|
||||||
|
ynh_replace_string "__PORT__" "$port" "conf/systemd.service"
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP APPLICATION WITH CURL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
# Set right permissions for curl install
|
||||||
|
chown -R $app: $final_path
|
||||||
|
|
||||||
|
# Set the app as temporarily public for curl call
|
||||||
|
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
||||||
|
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
|
||||||
|
# Reload SSOwat config
|
||||||
|
yunohost app ssowatconf
|
||||||
|
|
||||||
|
# Reload Nginx
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
# Installation with curl
|
||||||
|
ynh_script_progression --message="Finalizing installation..." --time --weight=1
|
||||||
|
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||||
|
|
||||||
|
# Remove the public access
|
||||||
|
if [ $is_public -eq 0 ]
|
||||||
|
then
|
||||||
|
ynh_app_setting_delete --app=$app --key=skipped_uris
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R $app:$app $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring log rotation..." --time --weight=1
|
||||||
|
|
||||||
|
# Use logrotate to manage application logfile(s)
|
||||||
|
ynh_use_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
### `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 FROM ADMIN PANEL" in the remove script
|
||||||
|
### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
|
||||||
|
|
||||||
|
yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP FAIL2BAN
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring fail2ban..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated fail2ban config
|
||||||
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
if [ $is_public -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed" --time --last
|
123
scripts/remove
Normal file
123
scripts/remove
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# 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..." --time --weight=1
|
||||||
|
yunohost service remove $app
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STOP AND REMOVE SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated systemd config
|
||||||
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the app directory securely
|
||||||
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated nginx config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated php-fpm config
|
||||||
|
ynh_remove_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the app-specific logrotate config
|
||||||
|
ynh_remove_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CLOSE A PORT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Closing port $port..."
|
||||||
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE FAIL2BAN CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated fail2ban config
|
||||||
|
ynh_remove_fail2ban_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE THE CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove a cron file
|
||||||
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
# Remove a directory securely
|
||||||
|
ynh_secure_remove --file="/etc/$app/"
|
||||||
|
|
||||||
|
# Remove the log files
|
||||||
|
ynh_secure_remove --file="/var/log/$app/"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
|
# Delete a system user
|
||||||
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed" --time --last
|
127
scripts/restore
Normal file
127
scripts/restore
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading settings..." --time --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||||
|
if [ $
|
||||||
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||||
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
|
test ! -d $final_path \
|
||||||
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD RESTORATION STEPS
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||||
|
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
|
systemctl enable $app.service
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX AND PHP-FPM
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --time --last
|
203
scripts/upgrade
Normal file
203
scripts/upgrade
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
|
# Fix is_public as a boolean value
|
||||||
|
if [ "$is_public" = "Yes" ]; then
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||||
|
is_public=1
|
||||||
|
elif [ "$is_public" = "No" ]; then
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||||
|
is_public=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If final_path doesn't exist, create it
|
||||||
|
if [ -z "$final_path" ]; then
|
||||||
|
final_path=/var/www/$app
|
||||||
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK THE PATH
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||||
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated php-fpm config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# ...
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
|
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||||
|
ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE FAIL2BAN
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated fail2ban config
|
||||||
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions on app files
|
||||||
|
chown -R root: $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
if [ $is_public -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway
|
||||||
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
Loading…
Reference in a new issue