mirror of
https://github.com/YunoHost-Apps/zap_ynh.git
synced 2024-09-03 20:36:07 +02:00
fix
This commit is contained in:
parent
15821d889d
commit
0cfad2a85c
8 changed files with 65 additions and 64 deletions
|
@ -7,7 +7,7 @@ location __PATH__/ {
|
||||||
rewrite ^(.*)$ /index.php?req=$1;
|
rewrite ^(.*)$ /index.php?req=$1;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_max_body_size 20m;
|
client_max_body_size 50m;
|
||||||
client_body_buffer_size 128k;
|
client_body_buffer_size 128k;
|
||||||
|
|
||||||
# Default indexes and catch-all
|
# Default indexes and catch-all
|
||||||
|
@ -31,15 +31,6 @@ location __PATH__/ {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# statically serve these file types when possible
|
|
||||||
# otherwise fall back to front controller
|
|
||||||
# allow browser to cache them
|
|
||||||
# added .htm for advanced source code editor library
|
|
||||||
# location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|map|ttf|woff|woff2|svg)$ {
|
|
||||||
# expires 30d;
|
|
||||||
# try_files $uri /index.php?q=$uri&$args;
|
|
||||||
# }
|
|
||||||
|
|
||||||
# block these file types
|
# block these file types
|
||||||
location ~* \.(tpl|md|tgz|log|out)$ {
|
location ~* \.(tpl|md|tgz|log|out)$ {
|
||||||
deny all;
|
deny all;
|
||||||
|
|
|
@ -38,11 +38,11 @@ ram.runtime = "50M"
|
||||||
type = "user"
|
type = "user"
|
||||||
|
|
||||||
[install.database]
|
[install.database]
|
||||||
ask.en = "Choose the database to be used for the Zap [mysql:1,postgresql:2]"
|
ask.en = "Do you need a database?"
|
||||||
ask.fr = "Choisissez la database de l'Zap [mysql:1,postgresql:2]"
|
ask.fr = "Avez-vous besoin d'une base de données ?"
|
||||||
type = "select"
|
type = "select"
|
||||||
choices = ["1", "2"]
|
choices = [ "mysql", "postgresql" ]
|
||||||
default = "1"
|
default = "mysql"
|
||||||
|
|
||||||
[resources]
|
[resources]
|
||||||
[resources.sources]
|
[resources.sources]
|
||||||
|
@ -64,7 +64,14 @@ ram.runtime = "50M"
|
||||||
main.url = "/"
|
main.url = "/"
|
||||||
|
|
||||||
[resources.apt]
|
[resources.apt]
|
||||||
packages = "postgresql postgresql-contrib php7.4-mbstring php7.4-cli php7.4-imagick php7.4-xml php7.4-zip php7.4-pgsql php7.4-mysql php7.4-json php7.4-gd"
|
packages = "php7.4-mbstring, php7.4-cli, php7.4-imagick, php7.4-xml, php7.4-zip, php7.4-json, php7.4-gd"
|
||||||
|
|
||||||
[resources.database]
|
packages_from_raw_bash = """
|
||||||
type = "mysql"
|
if [[ "$database" == "mysql" ]]; then
|
||||||
|
echo "mariadb-server, php7.4-mysql"
|
||||||
|
|
||||||
|
elif [[ "$database" == "postgresql" ]]; then
|
||||||
|
echo "postgresql, postgresql-contrib, php7.4-pgsql"
|
||||||
|
|
||||||
|
fi
|
||||||
|
"""
|
||||||
|
|
|
@ -55,12 +55,11 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||||
# BACKUP OF THE DATABASE
|
# BACKUP OF THE DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $database -eq 1 ]; then
|
if [ $database == "mysql" ]; then
|
||||||
ynh_print_info --message="Backup of the MySQL database..."
|
ynh_print_info --message="Backup of the MySQL database..."
|
||||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||||
elif [ $database -eq 2 ]; then
|
else
|
||||||
# Removing postgresSQL database
|
ynh_print_info --message="Backup of the PostgreSQL database..."
|
||||||
ynh_print_info --message="Backup of the postgreSQL database..."
|
|
||||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -101,27 +101,24 @@ chown -R $app:www-data "$install_dir"
|
||||||
# CREATE A DATABASE
|
# CREATE A DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $database -eq 1 ]; then
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..."
|
db_user=$db_name
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_pwd=$(ynh_string_random --length=30)
|
||||||
db_user=$db_name
|
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
|
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
|
||||||
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||||
ynh_script_progression --message="Importing database..."
|
|
||||||
|
if [ $database == "mysql" ]; then
|
||||||
|
ynh_script_progression --message="Creating a MySQL database..."
|
||||||
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql
|
||||||
elif [ $database -eq 2 ]; then
|
|
||||||
# Create postgresql database
|
|
||||||
ynh_script_progression --message="Creating a postgresql database..."
|
|
||||||
ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config"
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
db_user=$app
|
|
||||||
#REMOVEME? ynh_psql_test_if_first_run
|
|
||||||
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
|
||||||
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
ynh_script_progression --message="Importing database..."
|
|
||||||
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_postgres.sql
|
|
||||||
else
|
else
|
||||||
ynh_die --message="Some problem occured in creating the database, contact maintainer"
|
# Create postgresql database
|
||||||
|
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||||
|
ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config"
|
||||||
|
ynh_psql_test_if_first_run
|
||||||
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
|
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_postgres.sql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -13,13 +13,11 @@ source /usr/share/yunohost/helpers
|
||||||
# REMOVE THE DATABASE
|
# REMOVE THE DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $database -eq 1 ]; then
|
# Remove a database if it exists, along with the associated user
|
||||||
#REMOVEME? ynh_script_progression --message="Removing MySQL database..."
|
if [ $database == "mysql" ]; then
|
||||||
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
elif [ $database -eq 2 ]; then
|
else
|
||||||
# Removing postgresql database
|
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
#REMOVEME? ynh_script_progression --message="Removing postgreSQL database..."
|
|
||||||
#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -24,23 +24,18 @@ chown -R $app:www-data "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..."
|
ynh_script_progression --message="Restoring the MySQL database..."
|
||||||
|
|
||||||
if [ $database -eq 1 ]; then
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
#REMOVEME? ynh_script_progression --message="Restoring MySQL database..."
|
db_user=$db_name
|
||||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
|
if [ $database == "mysql" ]; then
|
||||||
elif [ $database -eq 2 ]; then
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
# Removing postgresql database
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
|
else
|
||||||
# Define and install dependencies
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
#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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
version=$(grep STD_VERSION $install_dir/boot.php | cut -c 38- | rev | cut -c 5- | rev)
|
version=$(grep STD_VERSION $install_dir/boot.php | cut -c 38- | rev | cut -c 5- | rev)
|
||||||
last_update=$(grep update_time: /etc/yunohost/apps/$app/settings.yml | cut -c 14-)
|
last_update=$(grep update_time: /etc/yunohost/apps/$app/settings.yml | cut -c 14-)
|
||||||
|
|
14
tests.toml
Normal file
14
tests.toml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
test_format = 1.0
|
||||||
|
|
||||||
|
[default]
|
||||||
|
|
||||||
|
# -------------------------------
|
||||||
|
# Default args to use for install
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
args.database = "mysql"
|
||||||
|
|
||||||
|
[postgresql_test]
|
||||||
|
|
||||||
|
only = ["install.subdir", "backup_restore", "upgrade" ]
|
||||||
|
args.database = "postgresql"
|
Loading…
Add table
Reference in a new issue