1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/osada_ynh.git synced 2024-09-03 19:46:30 +02:00

Manifestv2

This commit is contained in:
Salamandar 2024-02-26 17:38:43 +01:00
parent 640c839221
commit 0197c09fad
18 changed files with 208 additions and 371 deletions

View file

@ -1,47 +0,0 @@
;; Test complet mysql
; Manifest
domain="domain.tld"
admin="john"
database="mysql"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=0
setup_public=1
upgrade=1
backup_restore=1
multi_instance=1
port_already_use=0
change_url=0
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=81e4171acaa44520d0f527e6af445f4f33f2bca0
name=21.05.21~ynh1
manifest_arg=domain=DOMAIN&admin=USER&database=1&
; commit=c49f7f56b47a6a00da257ac7e4fd066dba51dcbf
name=21.05.21~ynh2
manifest_arg=domain=DOMAIN&admin=USER&database=1&
;; Test complet postgresql
; Manifest
domain="domain.tld"
admin="john"
database="postgresql"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=0
setup_public=1
upgrade=1
backup_restore=1
multi_instance=1
port_already_use=0
change_url=0
;;; Options
Email=
Notification=none

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://codeberg.org/zot-archive/osada/archive/dc8537520e0753a98bd2e2eeb1f0a16b50b954c3.tar.gz
SOURCE_SUM=cfed73d7d4648f4fe4e567d533d3d44dce3d36e2423c7ec32e9878f743ce2144
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://codeberg.org/zot-archive/osada-addons/archive/2a39590048b3d93795918f20dc5170e9c2a4bcde.tar.gz
SOURCE_SUM=ba2c83145d98c2948a33eb3250bc29f3116c156f936ca56e7e3051e393804be4
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

2
conf/cron.conf Executable file
View file

@ -0,0 +1,2 @@
# Run poller periodically to update Osada
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ __INSTALL_DIR__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
alias __INSTALL_DIR__/;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?req=$1;

View file

@ -358,7 +358,7 @@ request_terminate_timeout = 1d
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = __FINALPATH__
chdir = __INSTALL_DIR__
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.

View file

@ -1,2 +0,0 @@
# Run poller periodically to update Osada
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1

View file

@ -1,9 +1,3 @@
## This app claims following features:
- [X] LDAP integration
- [X] Multi-instance
- [X] Adeed php.log in the root folder for debugging PHP, with logrotate applied on it (can be accesssed by **admin->logs** and entering the **php.log**).
- [X] Fail2Ban
- [X] Option to choose between **Mysql** and **PostgreSQL** for the Osada
## Ldap Admin user rights, logs and failed database updates

View file

@ -1,2 +1 @@
## Overview
[Osada](http://zotlabs.com/osada/) uses **Zot6 protocol** which is next version of **zot5 protocol**. Osada has native support for the **ActivityPub protocol** (W3C standard) as well as the more advanced features. It can inter-operate with other social networking applications and projects in either of these spaces, including **Mastodon, Pleroma, Pixelfed, PeerTube, Funkwhale, Zap, Friendica, Hubzilla,** and many more.
[Osada](http://zotlabs.com/osada/) uses **Zot6 protocol** which is next version of **zot5 protocol**. Osada has native support for the **ActivityPub protocol** (W3C standard) as well as the more advanced features. It can inter-operate with other social networking applications and projects in either of these spaces, including **Mastodon, Pleroma, Pixelfed, PeerTube, Funkwhale, Zap, Friendica, Hubzilla,** and many more.

View file

@ -1,53 +0,0 @@
{
"name": "Osada",
"id": "osada",
"packaging_format": 1,
"description": {
"en": "Decentralized publication platform and social network",
"fr": "Plateforme de publication décentralisée et un réseau social"
},
"version": "23.12.17~ynh1",
"url": "http://zotlabs.com/osada/",
"upstream": {
"license": "MIT",
"website": "http://zotlabs.com/osada/",
"code": "https://codeberg.org/zot-archive/osada"
},
"license": "MIT",
"maintainer": {
"name": "Anmol Sharma",
"email": ""
},
"requirements": {
"yunohost": ">= 11.2"
},
"multi_instance": true,
"services": [
"nginx",
"php7.3-fpm",
"mysql",
"postgresql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "admin",
"type": "user"
},
{
"name": "database",
"type": "select",
"ask": {
"en": "Choose the database to be used for the Osada]",
"fr": "Choisissez la database de Osada"
},
"choices": ["mysql", "postgresql"],
"default": "mysql"
}
]
}
}

69
manifest.toml Normal file
View file

@ -0,0 +1,69 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "osada"
name = "Osada"
description.en = "Decentralized publication platform and social network"
description.fr = "Plateforme de publication décentralisée et un réseau social"
version = "23.12.17~ynh1"
maintainers = ["Anmol Sharma"]
[upstream]
license = "MIT"
website = "http://zotlabs.com/osada/"
code = "https://codeberg.org/zot-archive/osada"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = true
ldap = true
sso = true
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.admin]
type = "user"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://codeberg.org/zot-archive/osada/archive/dc8537520e0753a98bd2e2eeb1f0a16b50b954c3.tar.gz"
sha256 = "cfed73d7d4648f4fe4e567d533d3d44dce3d36e2423c7ec32e9878f743ce2144"
[resources.sources.app_addons]
url = "https://codeberg.org/zot-archive/osada-addons/archive/2a39590048b3d93795918f20dc5170e9c2a4bcde.tar.gz"
sha256 = "ba2c83145d98c2948a33eb3250bc29f3116c156f936ca56e7e3051e393804be4"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = [
"postgresql",
"postgresql-contrib",
"php7.3-mbstring",
"php7.3-cli",
"php7.3-imagick",
"php7.3-xml",
"php7.3-zip",
"php7.3-pgsql",
"php7.3-json",
"php7.3-gd",
]
[resources.database]
type = "postgresql"

View file

@ -4,12 +4,6 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.3"
# dependencies used by the app
pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"
pg_pkg_dependencies="postgresql postgresql-contrib"
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -15,20 +15,20 @@ source /usr/share/yunohost/helpers
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
#REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -39,7 +39,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -10,183 +10,73 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INITIALIZE AND STORE SETTINGS
#=================================================
# 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="/"
admin=$YNH_APP_ARG_ADMIN
database=$YNH_APP_ARG_DATABASE
app=$YNH_APP_INSTANCE_NAME
email=$(ynh_user_get_info --username=$admin --key=mail)
upload="256M"
random_string="$(ynh_string_random --length=48)"
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# 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..."
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=admin --value=$admin
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=upload --value=$upload
ynh_app_setting_set --app=$app --key=random_string --value=$random_string
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A DATABASE
#=================================================
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
if [ $database = "mysql" ]; then
ynh_script_progression --message="Creating a MySQL database..."
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
db_type=0
elif [ $database = "postgresql" ]; then
# Create postgresql database
ynh_script_progression --message="Creating a postgresql database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_type=1
fi
#=================================================
# 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
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
touch "$final_path/php.log"
mkdir -p "$final_path/store"
mkdir -p "$final_path/cache/smarty3"
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R 775 $final_path/store $final_path/cache
touch "$install_dir/php.log"
mkdir -p "$install_dir/store"
mkdir -p "$install_dir/cache/smarty3"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..."
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 775 $install_dir/store $install_dir/cache
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# PROVISION DATABASE
#=================================================
ynh_script_progression --message="Provisionning database..."
if [ $database = "mysql" ]; then
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
elif [ $database = "postgresql" ]; then
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
fi
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < "$install_dir/install/schema_postgres.sql"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
chmod 600 "$final_path/.htconfig.php"
chown $app:$app "$final_path/.htconfig.php"
chmod 600 "$install_dir/.htconfig.php"
chown $app:$app "$install_dir/.htconfig.php"
#=================================================
# SET CRON JOB
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Setuping cron job..."
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Set up cron job
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
# Create a dedicated NGINX config
ynh_add_nginx_config
# Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log"
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Configuring Fail2Ban..."
ynh_use_logrotate "$install_dir/php.log"
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
# Set up cron job
ynh_add_config --template="cron.conf" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# END OF SCRIPT

View file

@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# STANDARD REMOVE
@ -38,21 +38,21 @@ ynh_remove_logrotate
if [ $database = "mysql" ]; then
# Removing MySQL database
ynh_script_progression --message="Removing MySQL database..."
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#REMOVEME? ynh_script_progression --message="Removing MySQL database..."
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database = "postgresql" ]; then
# Removing PostgreSQL database
ynh_script_progression --message="Removing postgresql database..."
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
#REMOVEME? ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#REMOVEME? ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE NGINX CONFIGURATION
@ -73,10 +73,10 @@ ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
#REMOVEME? ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#REMOVEME? ynh_remove_app_dependencies
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
@ -101,10 +101,10 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#REMOVEME? ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT

View file

@ -15,52 +15,52 @@ source /usr/share/yunohost/helpers
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
@ -76,12 +76,12 @@ ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -100,22 +100,22 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..."
if [ $database = "mysql" ]; then
ynh_script_progression --message="Restoring MySQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
#REMOVEME? ynh_script_progression --message="Restoring MySQL database..."
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
elif [ $database = "postgresql" ]; then
# Removing postgresql database
ynh_script_progression --message="Reinstalling dependencies..."
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Restoring the PostgreSQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..."
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
fi

View file

@ -12,20 +12,20 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
upload=$(ynh_app_setting_get --app=$app --key=upload)
random_string=$(ynh_app_setting_get --app=$app --key=random_string)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? upload=$(ynh_app_setting_get --app=$app --key=upload)
#REMOVEME? random_string=$(ynh_app_setting_get --app=$app --key=random_string)
email=$(ynh_user_get_info --username=$admin --key=mail)
@ -39,16 +39,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
#REMOVEME? 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 () {
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
@ -57,21 +57,21 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# 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
# If install_dir doesn't exist, create it
if [ -z "$install_dir" ]; then
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
#REMOVEME? if ynh_legacy_permissions_exists; then
#REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
@ -88,10 +88,10 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -102,26 +102,26 @@ then
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="store/ .htconfig.php php.log"
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
ynh_setup_source --dest_dir="$install_dir" --keep="store/ .htconfig.php php.log"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons"
fi
mkdir -p "$final_path/store"
mkdir -p "$final_path/cache/smarty3"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R 775 $final_path/store $final_path/cache
mkdir -p "$install_dir/store"
mkdir -p "$install_dir/cache/smarty3"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 775 $install_dir/store $install_dir/cache
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
#REMOVEME? ynh_script_progression --message="Installing dependencies..."
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
@ -148,16 +148,16 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
if [ $database = "mysql" ]; then
db_type=0
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
elif [ $database = "postgresql" ]; then
db_type=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
fi
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
chmod 600 "$final_path/.htconfig.php"
chown $app:$app "$final_path/.htconfig.php"
chmod 600 "$install_dir/.htconfig.php"
chown $app:$app "$install_dir/.htconfig.php"
#=================================================
# UPGRADE CRON JOB
@ -185,14 +185,14 @@ ynh_use_logrotate --non-append
ynh_script_progression --message="Reconfiguring Fail2Ban..."
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

5
tests.toml Normal file
View file

@ -0,0 +1,5 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]