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

Rewrite, bug 'Primary script unknown' to fix..

This commit is contained in:
Jean-Baptiste Holcroft 2018-03-07 23:33:32 +01:00
parent 6947bd8a75
commit 8abc01681f
7 changed files with 285 additions and 36 deletions

View file

@ -6,8 +6,8 @@
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
admin="john" (USER) admin="john" (USER)
is_public=1 (PUBLIC|public=Yes|private=No) is_public=1 (PUBLIC|public=1|private=0)
adminPass="miaw!" password="miaw!"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -17,13 +17,6 @@ location __PATH__ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
# If you don't use a dedicated fpm config for your app,
# use a general fpm pool.
# This is to be used INSTEAD of line above
# Don't forget to adjust scripts install/upgrade/remove/backup accordingly
#
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;

View file

@ -1,16 +1,27 @@
{ {
"name": "Galette", "name": "Galette",
"id": "galette", "id": "galette",
"packaging_format": 1,
"url": "https://www.galette.eu",
"license": "GPL-3.0-or-later",
"version": "0.8.2.3-1",
"requirements": {
"yunohost": ">= 2.7.9"
},
"services": [
"nginx",
"php5-fpm",
"mysql"
],
"description": { "description": {
"en": "Membership management web application for non profit organizations", "en": "Membership management web application for non profit organizations",
"fr": "Outil de gestion d'adhérents et de cotisation en ligne pour associations" "fr": "Outil de gestion d'adhérents et de cotisation en ligne pour associations"
}, },
"licence": "free",
"maintainer": { "maintainer": {
"name": "Jean-Baptiste Holcroft", "name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr" "email": "jean-baptiste@holcroft.fr"
}, },
"multi_instance": "false", "multi_instance": false,
"arguments": { "arguments": {
"install": [ "install": [
{ {

3
scripts/_common.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash

View file

@ -23,7 +23,7 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
@ -70,6 +70,9 @@ ynh_mysql_setup_db "$db_name" "$db_name" "$db_pwd"
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set "$app" final_path "$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_setup_source "$final_path" ynh_setup_source "$final_path"
mv "$final_path"/galette/* "$final_path"/
ynh_secure_remove "$final_path"/tests
chown -R root:root "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -85,7 +88,6 @@ ynh_add_nginx_config
# Create a system user # Create a system user
ynh_system_user_create "$app" ynh_system_user_create "$app"
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -99,8 +101,8 @@ ynh_add_fpm_config
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
configpath="$final_path"/config/ configpath="$final_path"/config/config.inc.php
cp ../config.inc.php "$configpath" cp ../conf/config.inc.php "$configpath"
ynh_replace_string "__NAME_DB__" "$db_name" "$configpath" ynh_replace_string "__NAME_DB__" "$db_name" "$configpath"
ynh_replace_string "__PWD_DB__" "$db_pwd" "$configpath" ynh_replace_string "__PWD_DB__" "$db_pwd" "$configpath"
ynh_replace_string "__USER_DB__" "$db_name" "$configpath" ynh_replace_string "__USER_DB__" "$db_name" "$configpath"
@ -110,7 +112,7 @@ ynh_replace_string "__USER_DB__" "$db_name" "$configpath"
#================================================= #=================================================
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/CONFIG_FILE" ynh_store_file_checksum "$configpath"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -118,16 +120,16 @@ ynh_store_file_checksum "$final_path/CONFIG_FILE"
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
# Set permissions # TODO: improve permissions
chown -R root:www-data $final_path chown -R root:www-data "$final_path"
chmod -R o-rwx $final_path chmod -R o-rwx "$final_path"
chmod u+rx $final_path/config chmod u+rx "$final_path/config"
chmod g+rwx $final_path/config chmod g+rwx "$final_path/config"
for folder in attachments cache exports files imports logs photos templates_c tempimages for folder in attachments cache exports files imports logs photos templates_c tempimages
do do
chmod u+rx $final_path/data/$folder chmod u+rx "$final_path/data/$folder"
chmod g+rwx $final_path/data/$folder chmod g+rwx "$final_path/data/$folder"
done done
#================================================= #=================================================

View file

@ -1,16 +1,86 @@
#!/bin/bash #!/bin/bash
app=galette
db_user=galette
db_name=galette
root_pwd=$(cat /etc/yunohost/mysql) #=================================================
domain=$(yunohost app setting galette domain) # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" source _common.sh
rm -rf /var/www/$app source /usr/share/yunohost/helpers
rm -f /etc/nginx/conf.d/$domain.d/$app.conf
# Restart services
service nginx reload #=================================================
yunohost app ssowatconf # LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
port=$(ynh_app_setting_get "$app" port)
db_name=$(ynh_app_setting_get "$app" db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get "$app" final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE DEPENDENCIES
#=================================================
# Remove metapackage and its dependencies
# ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db "$db_user" "$db_name"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
# ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
#=================================================
# Remove the log files
ynh_secure_remove "/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
# Delete a system user
ynh_system_user_delete "$app"

View file

@ -7,5 +7,175 @@
# http://galette.eu/documentation/fr/installation/update.html # http://galette.eu/documentation/fr/installation/update.html
# #
# adminPass --> password #=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
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
#=================================================
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set "$app" is_public 1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set "$app" is_public 0
is_public=0
fi
# mysqlpassword --> mysqlpwd # mysqlpassword --> mysqlpwd
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid "$app")
ynh_app_setting_set "$app" db_name "$db_name"
fi
# If db_name doesn't exist, create it
if [ -z "$db_pwd" ]; then
db_pwd=$(ynh_app_setting_get "$app" mysqlpassword)
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
fi
# If final_path doesn't exist, create it
if [ -z $final_path ]; then
final_path=/var/www/$app
ynh_app_setting_set "$app" final_path "$final_path"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
configpath="$final_path"/config/
cp ../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 "$final_path/CONFIG_FILE"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/CONFIG_FILE"
#=================================================
# SETUP LOGROTATE
#=================================================
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# TODO: improve permissions
chown -R root:www-data "$final_path"
chmod -R o-rwx "$final_path"
chmod u+rx "$final_path/config"
chmod g+rwx "$final_path/config"
for folder in attachments cache exports files imports logs photos templates_c tempimages
do
chmod u+rx "$final_path/data/$folder"
chmod g+rwx "$final_path/data/$folder"
done
#=================================================
# SETUP SSOWAT
#=================================================
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/"
fi
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx