1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/galette_ynh.git synced 2024-09-03 18:36:28 +02:00

Make install and upgrae manual as Galette suggests it

This commit is contained in:
Jean-Baptiste Holcroft 2018-03-20 23:34:46 +01:00
parent 834617bb59
commit b25344fe63
5 changed files with 89 additions and 92 deletions

View file

@ -1,26 +0,0 @@
<?php
/*
This is an example for your configuration file,
read comments and replace the "blanks".
You can then copy the file in GALETTE_CONFIG_PATH/config.inc.php
$Id$
*/
/* choose your database engine, values : pgsql|mysql */
define("TYPE_DB", "mysql");
/* hostname for the database */
define("HOST_DB", "localhost");
/* tcp port for the database */
define("PORT_DB", "3306");
/* the username for the database */
define("USER_DB", "__USER_DB__");
/* password for the username define above */
define("PWD_DB", "__PWD_DB__");
/* the database name */
define("NAME_DB", "__NAME_DB__");
/* tables name prefix (default is galette_) */
define("PREFIX_DB", "");
/* FIXME will disappear soon */
define("STOCK_FILES", "tempimages");

View file

@ -41,22 +41,6 @@
"example": "/galette",
"default": "/galette"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Admin login"
},
"example": "jibec"
},
{
"name": "password",
"type": "password",
"ask": {
"en": "Admin password"
},
"example": ""
},
{
"name": "is_public",
"ask": {

View file

@ -1,3 +1,50 @@
#!/bin/bash
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific information...}"
local recipients="${2:-root}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$app_message
---
Automatic diagnosis data from YunoHost
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
# Send the email to the recipients
echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}

View file

@ -24,8 +24,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
#=================================================
@ -49,7 +47,6 @@ ynh_webpath_register "$app" "$domain" "$path_url"
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" path "$path_url"
ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" is_public "$is_public"
#=================================================
@ -95,39 +92,14 @@ ynh_system_user_create "$app"
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
#=================================================
# MODIFY A CONFIG FILE
#=================================================
configpath="$final_path"/config/config.inc.php
cp ../conf/config.inc.php "$configpath"
ynh_replace_string "__NAME_DB__" "$db_name" "$configpath"
ynh_replace_string "__PWD_DB__" "$db_pwd" "$configpath"
ynh_replace_string "__USER_DB__" "$db_name" "$configpath"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$configpath"
#=================================================
# CREATE DATABASE
#=================================================
script_for_db="$final_path"/install/scripts/mysql.sql
ynh_mysql_execute_file_as_root "$script_for_db" "$db_name"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# TODO: improve permissions
chown "$app" "$final_path/config"
chmod 750 "$final_path/config"
for folder in attachments cache exports files imports logs photos templates_c tempimages
do
@ -171,3 +143,28 @@ fi
#=================================================
systemctl reload nginx
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message="Galette need you to finish the installation manually.
Please open "https://$domain$path_url"
Database information you'll need:
Type: mysql
Host: localhost
Port: 3306
User: "$db_name"
Password: "$db_pwd"
Name: "$db_name"
Important: after the installation, you _should_ run:
\`chmod -R 500 "$final_path/config"\`
\`rm -rf "$final_path/install"\`
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/galette_ynh"
ynh_send_readme_to_admin "$message"

View file

@ -24,12 +24,10 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin)
is_public=$(ynh_app_setting_get "$app" is_public)
final_path=$(ynh_app_setting_get "$app" final_path)
db_name=$(ynh_app_setting_get "$app" db_name)
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
password=$(ynh_app_setting_get "$app" password)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@ -44,8 +42,6 @@ elif [ "$is_public" = "No" ]; then
is_public=0
fi
# mysqlpassword --> mysqlpwd
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid "$app")
@ -112,22 +108,6 @@ ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
configpath="$final_path"/config/config.inc.php
cp ../conf/config.inc.php "$configpath"
ynh_replace_string "__NAME_DB__" "$db_name" "$configpath"
ynh_replace_string "__PWD_DB__" "$db_pwd" "$configpath"
ynh_replace_string "__USER_DB__" "$db_name" "$configpath"
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$configpath"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$configpath"
#=================================================
# SETUP LOGROTATE
#=================================================
@ -144,6 +124,10 @@ ynh_use_logrotate --non-append
# TODO: improve permissions
chown -R root:root "$final_path"
chown "$app" "$final_path/config"
chmod 750 "$final_path/config"
for folder in attachments cache exports files imports logs photos templates_c tempimages
do
chown "$app" "$final_path/data/$folder"
@ -179,3 +163,14 @@ fi
#=================================================
systemctl reload nginx
message="Galette need you to finish the update manually.
Please open "$domain/$path_url" and finish the upgrade process.
\`chmod -R 500 "$final_path/config"\`
\`rm -rf "$final_path/install"\`
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/galette_ynh"
ynh_send_readme_to_admin "$message"