mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
Add title for each part of code and use helper upstream_version
This commit is contained in:
parent
a40fb4f373
commit
effd760f8b
9 changed files with 123 additions and 14 deletions
|
@ -6,7 +6,7 @@
|
||||||
"en": "Manage PostgreSQL databases over the web",
|
"en": "Manage PostgreSQL databases over the web",
|
||||||
"fr": "Application web de gestion des bases de données PostgreSQL"
|
"fr": "Application web de gestion des bases de données PostgreSQL"
|
||||||
},
|
},
|
||||||
"version": "4-2.1",
|
"version": "4-2.1~ynh1",
|
||||||
"url": "https://www.pgadmin.org",
|
"url": "https://www.pgadmin.org",
|
||||||
"license": "PostgreSQL",
|
"license": "PostgreSQL",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
|
#=================================================
|
||||||
|
# SET ALL CONSTANTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path=/opt/yunohost/$app
|
final_path=/opt/yunohost/$app
|
||||||
pgadmin_user="pgadmin"
|
pgadmin_user="pgadmin"
|
||||||
|
|
||||||
get_app_version_from_json() {
|
[[ -e "../settings/manifest.json" ]] || [[ -e "../manifest.json" ]] && \
|
||||||
manifest_path="../manifest.json"
|
APP_VERSION=$(ynh_app_upstream_version)
|
||||||
if [ ! -e "$manifest_path" ]; then
|
|
||||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
||||||
fi
|
|
||||||
echo $(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
|
||||||
}
|
|
||||||
APP_VERSION=$(get_app_version_from_json)
|
|
||||||
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)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEFINE ALL COMMON FONCTIONS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
install_dependance() {
|
install_dependance() {
|
||||||
ynh_install_app_dependencies python-pip build-essential python-dev python-virtualenv postgresql uwsgi uwsgi-plugin-python expect
|
ynh_install_app_dependencies python-pip build-essential python-dev python-virtualenv postgresql uwsgi uwsgi-plugin-python expect
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,14 +11,18 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/psql.sh
|
|
||||||
|
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,6 +11,7 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
|
source ./experimental_helper.sh
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
# Retrive arguments
|
# Retrive arguments
|
||||||
|
@ -37,7 +42,10 @@ then
|
||||||
change_path=1
|
change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
|
|
@ -146,3 +146,50 @@ ynh_psql_test_if_first_run() {
|
||||||
systemctl reload postgresql
|
systemctl reload postgresql
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# OTHERS HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Read the value of a key in a ynh manifest file
|
||||||
|
#
|
||||||
|
# usage: ynh_read_manifest manifest key
|
||||||
|
# | arg: manifest - Path of the manifest to read
|
||||||
|
# | arg: key - Name of the key to find
|
||||||
|
ynh_read_manifest () {
|
||||||
|
manifest="$1"
|
||||||
|
key="$2"
|
||||||
|
python3 -c "import sys, json;print(json.load(open('$manifest'))['$key'])"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read the upstream version from the manifest
|
||||||
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
|
# For example : 4.3-2~ynh3
|
||||||
|
# This include the number before ~ynh
|
||||||
|
# In the last example it return 4.3-2
|
||||||
|
#
|
||||||
|
# usage: ynh_app_upstream_version
|
||||||
|
ynh_app_upstream_version () {
|
||||||
|
manifest_path="../manifest.json"
|
||||||
|
if [ ! -e "$manifest_path" ]; then
|
||||||
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||||
|
fi
|
||||||
|
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||||
|
echo "${version_key/~ynh*/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read package version from the manifest
|
||||||
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
|
# For example : 4.3-2~ynh3
|
||||||
|
# This include the number after ~ynh
|
||||||
|
# In the last example it return 3
|
||||||
|
#
|
||||||
|
# usage: ynh_app_package_version
|
||||||
|
ynh_app_package_version () {
|
||||||
|
manifest_path="../manifest.json"
|
||||||
|
if [ ! -e "$manifest_path" ]; then
|
||||||
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||||
|
fi
|
||||||
|
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||||
|
echo "${version_key/*~ynh/}"
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,8 +11,8 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
|
source ./experimental_helper.sh
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
source ./psql.sh
|
|
||||||
|
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
@ -40,6 +44,10 @@ ynh_app_setting_set $app admin_pwd "$admin_pwd"
|
||||||
ynh_app_setting_set $app db_user "$db_user"
|
ynh_app_setting_set $app db_user "$db_user"
|
||||||
ynh_app_setting_set $app db_pwd "$db_pwd"
|
ynh_app_setting_set $app db_pwd "$db_pwd"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Install dependance
|
# Install dependance
|
||||||
install_dependance
|
install_dependance
|
||||||
|
|
||||||
|
@ -77,6 +85,10 @@ su --command="psql -c\"CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSE
|
||||||
$final_path/bin/python2.7 config_database.py "$db_user" "$db_pwd"
|
$final_path/bin/python2.7 config_database.py "$db_user" "$db_pwd"
|
||||||
deactivate
|
deactivate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Set permission after initialisation
|
# Set permission after initialisation
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,14 +11,18 @@ source /usr/share/yunohost/helpers
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
|
source ./experimental_helper.sh
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
source ./psql.sh
|
|
||||||
|
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
db_user="pgadmin"
|
db_user="pgadmin"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Remove db user
|
# Remove db user
|
||||||
ynh_psql_drop_user $db_user
|
ynh_psql_drop_user $db_user
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,8 +11,8 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/psql.sh
|
|
||||||
|
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
@ -19,6 +23,10 @@ db_name=$(ynh_app_setting_get $app db_name)
|
||||||
db_user=$(ynh_app_setting_get $app db_user)
|
db_user=$(ynh_app_setting_get $app db_user)
|
||||||
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD RESTORATION STEPS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Install dependance
|
# Install dependance
|
||||||
install_dependance
|
install_dependance
|
||||||
|
|
||||||
|
@ -32,6 +40,10 @@ ynh_restore
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
su --command="psql -c\"CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION\"" postgres
|
su --command="psql -c\"CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION\"" postgres
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Set the permission
|
# Set the permission
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -7,8 +11,8 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
|
source ./experimental_helper.sh
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
source ./psql.sh
|
|
||||||
|
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
@ -21,6 +25,10 @@ ynh_clean_setup () {
|
||||||
ynh_restore_upgradebackup # restore it if the upgrade fails
|
ynh_restore_upgradebackup # restore it if the upgrade fails
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
install_source
|
install_source
|
||||||
|
|
||||||
|
@ -30,6 +38,10 @@ config_pgadmin
|
||||||
# Config uwsgi
|
# Config uwsgi
|
||||||
config_uwsgi
|
config_uwsgi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Set permission after initialisation
|
# Set permission after initialisation
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue