mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
Apply last example_ynh
This commit is contained in:
parent
91a7ee6e18
commit
30597d1375
14 changed files with 518 additions and 228 deletions
|
@ -1,9 +1,9 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld"
|
||||||
path="/path" (PATH)
|
path="/path"
|
||||||
admin="john" (USER)
|
admin="john"
|
||||||
admin_password="Sup3rS3cr3t" (PASSWORD)
|
password="1Strong-Password"
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
|
@ -12,13 +12,11 @@
|
||||||
setup_private=0
|
setup_private=0
|
||||||
setup_public=0
|
setup_public=0
|
||||||
upgrade=1
|
upgrade=1
|
||||||
|
# upgrade=1 from_commit=CommitHash
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
incorrect_path=1
|
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=1
|
change_url=1
|
||||||
;;; Levels
|
|
||||||
Level 5=auto
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=none
|
Notification=none
|
||||||
|
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
1
doc/DESCRIPTION.md
Normal file
1
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL.
|
3
doc/DISCLAIMER.md
Normal file
3
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
### Multi-users support
|
||||||
|
|
||||||
|
This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database.
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
BIN
doc/screenshots/pgadmin4-welcome-light.png
Normal file
BIN
doc/screenshots/pgadmin4-welcome-light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 KiB |
|
@ -8,13 +8,18 @@
|
||||||
},
|
},
|
||||||
"version": "4-5.7~ynh1",
|
"version": "4-5.7~ynh1",
|
||||||
"url": "https://www.pgadmin.org",
|
"url": "https://www.pgadmin.org",
|
||||||
|
"upstream": {
|
||||||
|
"license": "PostgreSQL",
|
||||||
|
"website": "https://www.pgadmin.org",
|
||||||
|
"admindoc": "https://www.pgadmin.org/docs"
|
||||||
|
},
|
||||||
"license": "PostgreSQL",
|
"license": "PostgreSQL",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Josué Tille",
|
"name": "Josué Tille",
|
||||||
"email": "josue@tille.ch"
|
"email": "josue@tille.ch"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 4.0.0.0"
|
"yunohost": ">= 4.3.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -25,40 +30,21 @@
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain"
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain for pgAdmin",
|
|
||||||
"fr": "Choisissez un domaine pour pgAdmin"
|
|
||||||
},
|
|
||||||
"example": "domain.org"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for pgAdmin",
|
|
||||||
"fr": "Choisissez un chemin pour pgAdmin"
|
|
||||||
},
|
|
||||||
"example": "/pgadmin",
|
"example": "/pgadmin",
|
||||||
"default": "/pgadmin"
|
"default": "/pgadmin"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user"
|
||||||
"ask": {
|
|
||||||
"en": "Choose the only allowed admin user",
|
|
||||||
"fr": "Choisissez l'unique utilisateur autorisé"
|
|
||||||
},
|
|
||||||
"example": "johndoe"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin_password",
|
"name": "password",
|
||||||
"type": "password",
|
"type": "password"
|
||||||
"ask": {
|
|
||||||
"en": "Enter a password for the administrator",
|
|
||||||
"fr": "Entrez un mot de passe pour l'administrateur"
|
|
||||||
},
|
|
||||||
"example": "**Sup3rS3cr3t**"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
# SET ALL CONSTANTS
|
# SET ALL CONSTANTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
final_path=/opt/yunohost/$app
|
|
||||||
pgadmin_user="$app"
|
|
||||||
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
|
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
|
||||||
dependances="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev"
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEFINE ALL COMMON FONCTIONS
|
# DEFINE ALL COMMON FONCTIONS
|
||||||
|
|
|
@ -3,45 +3,69 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Import common cmd
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/experimental_helper.sh
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
true
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
ynh_print_info --message="Loading installation settings..."
|
ynh_print_info --message="Loading installation settings..."
|
||||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
|
||||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
|
||||||
app_version=$(ynh_app_upstream_version)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
ynh_print_info --message="Backing up the main app directory..."
|
#=================================================
|
||||||
ynh_backup --src_path "$final_path"
|
|
||||||
|
|
||||||
# Backup config
|
ynh_backup --src_path="$final_path"
|
||||||
ynh_print_info --message="Backing configuration..."
|
|
||||||
ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
ynh_backup --src_path "/etc/uwsgi/apps-available/$app.ini"
|
|
||||||
|
|
||||||
# Backup Data and LOG
|
#=================================================
|
||||||
ynh_print_info --message="Backing up data..."
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
ynh_backup --src_path "/var/lib/pgadmin"
|
#=================================================
|
||||||
ynh_print_info --message="Backing up log..."
|
|
||||||
ynh_backup --src_path "/var/log/pgadmin"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_backup --src_path "/var/log/uwsgi/$app"
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC BACKUP
|
||||||
|
#=================================================
|
||||||
|
# BACKUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
||||||
|
ynh_backup --src_path="/var/lib/pgadmin"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,132 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
source ./experimental_helper.sh
|
source experimental_helper.sh
|
||||||
source ./_common.sh
|
source _common.sh
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Stop script if errors
|
#=================================================
|
||||||
ynh_abort_if_errors
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrive arguments
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
|
old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
domain=$YNH_APP_NEW_DOMAIN
|
domain=$YNH_APP_NEW_DOMAIN
|
||||||
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
|
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
ynh_clean_check_starting
|
||||||
|
# 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
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Updating configuration..."
|
#=================================================
|
||||||
# Update nginx config
|
# MODIFY URL IN NGINX CONF
|
||||||
if [ "$old_domain" != "$domain" ]
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||||
|
|
||||||
|
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
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
ynh_add_nginx_config
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# ...
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Update UWSGI Config
|
# Update UWSGI Config
|
||||||
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
||||||
|
|
||||||
# Reload services
|
#=================================================
|
||||||
ynh_script_progression --message="Restarting $app services..." --weight=3
|
# GENERIC FINALISATION
|
||||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action restart \
|
#=================================================
|
||||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||||
|
|
142
scripts/install
142
scripts/install
|
@ -3,34 +3,52 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Import common cmd
|
|
||||||
source ./experimental_helper.sh
|
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source experimental_helper.sh
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
ynh_clean_check_starting
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
#=================================================
|
||||||
|
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
admin_pwd=$YNH_APP_ARG_PASSWORD
|
||||||
|
|
||||||
db_user="pgadmin"
|
db_user="pgadmin"
|
||||||
admin_pwd=$YNH_APP_ARG_ADMIN_PASSWORD
|
db_pwd=$(ynh_string_random --length 30)
|
||||||
app_version=$(ynh_app_upstream_version)
|
app_version=$(ynh_app_upstream_version)
|
||||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
pgadmin_user="$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating installation parameters..."
|
||||||
|
|
||||||
|
final_path=/opt/yunohost/$app
|
||||||
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
# Get user email and check that the user exist
|
# Get user email and check that the user exist
|
||||||
email=$(ynh_user_get_info --username $admin --key 'mail')
|
email=$(ynh_user_get_info --username $admin --key 'mail')
|
||||||
|
@ -39,37 +57,60 @@ then
|
||||||
ynh_die --message "Can't get user email, check that the user exist or that the user have an email"
|
ynh_die --message "Can't get user email, check that the user exist or that the user have an email"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build user password
|
#=================================================
|
||||||
ynh_script_progression --message="Defining db password..."
|
|
||||||
db_pwd=$(ynh_string_random --length 30)
|
|
||||||
|
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
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=domain --value=$domain
|
||||||
ynh_app_setting_set --app $app --key admin --value $admin
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app $app --key db_user --value "$db_user"
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set --app $app --key final_path --value $final_path
|
ynh_app_setting_set --app=$app --key=admin_pwd --value="$admin_pwd"
|
||||||
ynh_app_setting_set --app $app --key admin_pwd --value "$admin_pwd"
|
ynh_app_setting_set --app=$app --key=db_user --value="$db_user"
|
||||||
ynh_app_setting_set --app $app --key db_pwd --value "$db_pwd"
|
ynh_app_setting_set --app=$app --key=db_pwd --value="$db_pwd"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
# Install dependance
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=7
|
ynh_script_progression --message="Installing dependencies..." --weight=7
|
||||||
ynh_install_app_dependencies $dependances
|
|
||||||
|
|
||||||
# Create user
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..."
|
ynh_script_progression --message="Configuring system user..."
|
||||||
ynh_system_user_create --username $pgadmin_user --home_dir $final_path
|
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create --username=$pgadmin_user --home_dir=$final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Setting up source files..."
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_script_progression --message="Installing sources files..." --weight=10
|
ynh_script_progression --message="Installing sources files..." --weight=10
|
||||||
setup_dir
|
setup_dir
|
||||||
install_source
|
install_source
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# ...
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Configuring application..."
|
ynh_script_progression --message="Configuring application..."
|
||||||
|
|
||||||
# CONFIGURE PGADMIN
|
# CONFIGURE PGADMIN
|
||||||
|
@ -78,9 +119,6 @@ config_pgadmin
|
||||||
# Config uwsgi
|
# Config uwsgi
|
||||||
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
ynh_script_progression --message="Configuring sqlite database..."
|
ynh_script_progression --message="Configuring sqlite database..."
|
||||||
|
|
||||||
# initialisation sqlite database for pgadmin
|
# initialisation sqlite database for pgadmin
|
||||||
|
@ -104,26 +142,44 @@ set +u;
|
||||||
deactivate
|
deactivate
|
||||||
set -u;
|
set -u;
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Set permission after initialisation
|
# Set permission after initialisation
|
||||||
ynh_script_progression --message="Protecting directory"
|
ynh_script_progression --message="Protecting directory"
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
# Restrict access to admin only
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring permissions"
|
# GENERIC FINALIZATION
|
||||||
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
# Configuration de logrotate
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
ynh_script_progression --message="Configuring log rotation..."
|
||||||
ynh_use_logrotate --logfile /var/log/pgadmin
|
|
||||||
|
|
||||||
# reload uwsgi
|
ynh_use_logrotate --logfile="/var/log/pgadmin"
|
||||||
ynh_script_progression --message="Starting $app services..." --weight=3
|
|
||||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
#=================================================
|
||||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring permissions..."
|
||||||
|
|
||||||
|
# Restrict access to admin only
|
||||||
|
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
113
scripts/remove
113
scripts/remove
|
@ -3,19 +3,23 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Import common cmd
|
source experimental_helper.sh
|
||||||
source ./experimental_helper.sh
|
source _common.sh
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
|
||||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
db_user="$app"
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -24,38 +28,73 @@ db_user="$app"
|
||||||
# Stop service
|
# Stop service
|
||||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
||||||
|
|
||||||
# Remove db user
|
|
||||||
ynh_script_progression --message="Cleaning the PostgreSQL database..."
|
|
||||||
ynh_psql_drop_user $db_user
|
|
||||||
|
|
||||||
# Remove depandance
|
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=10
|
|
||||||
ynh_remove_app_dependencies || true
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=4
|
|
||||||
ynh_secure_remove --file="$final_path"
|
|
||||||
|
|
||||||
# Remove app data
|
|
||||||
ynh_secure_remove --file=/var/lib/$app
|
|
||||||
|
|
||||||
# Remove logrotate
|
|
||||||
ynh_script_progression --message="Removing logrotate configuration..."
|
|
||||||
ynh_remove_logrotate
|
|
||||||
|
|
||||||
# Remove logs
|
|
||||||
ynh_script_progression --message="Removing logs..."
|
|
||||||
ynh_secure_remove --file=/var/log/$app
|
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
|
||||||
ynh_script_progression --message="Removing configuration..."
|
|
||||||
ynh_remove_nginx_config
|
|
||||||
|
|
||||||
# Remove uwsgi config
|
# Remove uwsgi config
|
||||||
ynh_remove_uwsgi_service
|
ynh_remove_uwsgi_service
|
||||||
|
|
||||||
# Delete a system user
|
#=================================================
|
||||||
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing logrotate configuration..."
|
||||||
|
|
||||||
|
# Remove the app-specific logrotate config
|
||||||
|
ynh_remove_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DB_USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Cleaning the PostgreSQL database..."
|
||||||
|
|
||||||
|
ynh_psql_drop_user $db_user
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..." --weight=4
|
||||||
|
|
||||||
|
# Remove the app directory securely
|
||||||
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||||
|
|
||||||
|
# Remove the dedicated NGINX config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..." --weight=10
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
ynh_remove_app_dependencies || true
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing various files..."
|
||||||
|
|
||||||
|
# Remove app data
|
||||||
|
ynh_secure_remove --file="/var/lib/$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..."
|
ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
ynh_system_user_delete $app
|
|
||||||
|
# Delete a system user
|
||||||
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
118
scripts/restore
118
scripts/restore
|
@ -3,45 +3,78 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Import common cmd
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/experimental_helper.sh
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
ynh_clean_check_starting
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
ynh_script_progression --message="Loading settings..."
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
path_url=$(ynh_app_setting_get --app $app --key path)
|
|
||||||
admin=$(ynh_app_setting_get --app $app --key admin)
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
|
||||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_user=$(ynh_app_setting_get --app $app --key db_user)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
db_pwd=$(ynh_app_setting_get --app $app --key db_pwd)
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
|
|
||||||
app_version=$(ynh_app_upstream_version)
|
app_version=$(ynh_app_upstream_version)
|
||||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||||
|
|
||||||
|
pgadmin_user="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||||
|
|
||||||
# Install dependance
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
|
||||||
ynh_install_app_dependencies $dependances
|
|
||||||
|
|
||||||
# Create user
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||||
ynh_system_user_create --username $pgadmin_user --home_dir $final_path
|
|
||||||
|
|
||||||
# Restore all config and data
|
# Create the dedicated user (if not existing)
|
||||||
ynh_script_progression --message="Restoring files..." --weight=5
|
ynh_system_user_create --username=$pgadmin_user --home_dir=$final_path
|
||||||
ynh_restore
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..." --weight=5
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||||
|
|
||||||
|
# Define and install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Check that the good python version is installed
|
# Check that the good python version is installed
|
||||||
# If not upgrade the source
|
# If not upgrade the source
|
||||||
|
@ -50,34 +83,47 @@ install_source
|
||||||
# POPULATE THE DATABASE
|
# POPULATE THE DATABASE
|
||||||
ynh_script_progression --message="Reconfiguring Postgresql database..."
|
ynh_script_progression --message="Reconfiguring Postgresql database..."
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_execute_as_root \
|
ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||||
--sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring various files..."
|
||||||
|
|
||||||
# Restore systemd configuration
|
# Restore systemd configuration
|
||||||
ynh_script_progression --message="Reconfiguring application..."
|
ynh_script_progression --message="Reconfiguring application..."
|
||||||
ynh_restore_uwsgi_service
|
ynh_restore_uwsgi_service
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Set the permission
|
# Set the permission
|
||||||
ynh_script_progression --message="Protecting directory..."
|
ynh_script_progression --message="Protecting directory..."
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
# Restrict access to admin only
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring permissions"
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||||
|
|
||||||
# Configuration de logrotate
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
|
||||||
ynh_use_logrotate --logfile /var/log/pgadmin
|
|
||||||
|
|
||||||
# reload uwsgi and nginx
|
#=================================================
|
||||||
ynh_script_progression --message="Starting pgadmin services..." --weight=3
|
# START SYSTEMD SERVICE
|
||||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
#=================================================
|
||||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||||
systemctl reload nginx
|
|
||||||
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
116
scripts/upgrade
116
scripts/upgrade
|
@ -3,48 +3,92 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Import common cmd
|
|
||||||
source ./experimental_helper.sh
|
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source experimental_helper.sh
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
#=================================================
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
|
||||||
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
admin=$(ynh_app_setting_get --app $app --key admin)
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
app_version=$(ynh_app_upstream_version)
|
app_version=$(ynh_app_upstream_version)
|
||||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||||
|
|
||||||
|
pgadmin_user="$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Checking version..."
|
||||||
|
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
#=================================================
|
||||||
ynh_backup_before_upgrade # Backup the current version of the app
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_restore_upgradebackup # restore it if the upgrade fails
|
ynh_clean_check_starting
|
||||||
|
# Restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..."
|
||||||
|
|
||||||
test -e /etc/uwsgi/apps-available/$app.ini && \
|
test -e /etc/uwsgi/apps-available/$app.ini && \
|
||||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
if ! grep -q "$final_path" /etc/passwd; then
|
if ! grep -q "$final_path" /etc/passwd; then
|
||||||
sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd
|
sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||||
|
|
||||||
# Install dependance
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
ynh_install_app_dependencies $dependances
|
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# ...
|
||||||
|
#=================================================
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||||
install_source
|
install_source
|
||||||
|
@ -56,28 +100,40 @@ config_pgadmin
|
||||||
# Config uwsgi
|
# Config uwsgi
|
||||||
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
# Clean old uwsgi config
|
# Clean old uwsgi config
|
||||||
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Set permission after initialisation
|
# Set permission after initialisation
|
||||||
ynh_script_progression --message="Protecting directory..."
|
ynh_script_progression --message="Protecting directory..."
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
# Configuration de logrotate
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
|
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
|
||||||
|
|
||||||
# reload uwsgi
|
#=================================================
|
||||||
ynh_script_progression --message="Restarting $app services..." --weight=3
|
# START SYSTEMD SERVICE
|
||||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
#=================================================
|
||||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Add table
Reference in a new issue