1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/invoiceninja_ynh.git synced 2024-09-03 19:26:22 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:19:54 +02:00 committed by GitHub
commit 635d1a3174
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 93 additions and 164 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~ *~
*.sw[op] *.sw[op]
.DS_Store

View file

@ -1,3 +1,3 @@
0 8 * * * __APP__ /usr/bin/php__PHPVERSION__ __INSTALL_DIR__/artisan ninja:send-invoices -q 0 8 * * * __APP__ /usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/artisan ninja:send-invoices -q
0 8 * * * __APP__ /usr/bin/php__PHPVERSION__ __INSTALL_DIR__/artisan ninja:send-reminders -q 0 8 * * * __APP__ /usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/artisan ninja:send-reminders -q

View file

@ -22,7 +22,7 @@ location ^~ __PATH__/ {
location ~ ^__PATH__/index\.php(/.*|)$ { location ~ ^__PATH__/index\.php(/.*|)$ {
fastcgi_split_path_info ^(.+?\.php)(/.*|)$; fastcgi_split_path_info ^(.+?\.php)(/.*|)$;
set $path_info $fastcgi_path_info; set $path_info $fastcgi_path_info;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;

View file

@ -20,7 +20,8 @@ code = "https://github.com/invoiceninja/invoiceninja"
cpe = "cpe:2.3:a:invoiceninja:invoice_ninja" cpe = "cpe:2.3:a:invoiceninja:invoice_ninja"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
@ -67,6 +68,7 @@ ram.runtime = "50M"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]
group = "www-data:r-x"
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"

View file

@ -1,11 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
#=================================================
# PERSONAL HELPERS
#================================================= #=================================================
_install_phantomjs() { _install_phantomjs() {
@ -14,16 +10,9 @@ _install_phantomjs() {
ynh_setup_source --dest_dir="$source_dir" --source_id="phantomjs" ynh_setup_source --dest_dir="$source_dir" --source_id="phantomjs"
pushd "$source_dir" pushd "$source_dir"
ynh_exec_warn_less env PREFIX="$destdir" ./configure ynh_hide_warnings env PREFIX="$destdir" ./configure
ynh_exec_warn_less make -j "$(nproc)" ynh_hide_warnings make -j "$(nproc)"
ynh_exec_warn_less make install ynh_hide_warnings make install
popd popd
ynh_secure_remove --file="$source_dir" ynh_safe_rm "$source_dir"
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,37 +1,28 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
@ -39,17 +30,17 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup "/etc/cron.d/$app"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the MySQL database..." ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql ynh_mysql_dump_db > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,40 +1,32 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_script_progression "Updating configuration..."
config="$install_dir/.env" config="$install_dir/.env"
ynh_backup_if_checksum_is_different --file="$install_dir/CONFIG_FILE" ynh_backup_if_checksum_is_different "$install_dir/CONFIG_FILE"
ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$config" ynh_replace --match="$old_domain$old_path" --replace="$new_domain$new_path" --file="$config"
ynh_store_file_checksum --file="$config" ynh_store_file_checksum "$config"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -1,29 +1,22 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression "Setting up source files..."
# 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 --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression "Adding $app's configuration..."
api_secret="$(ynh_string_random --length=32)" api_secret="$(ynh_string_random --length=32)"
app_key="$(ynh_string_random --length=32)" app_key="$(ynh_string_random --length=32)"
@ -31,33 +24,33 @@ phantomjs_key=$(ynh_string_random --length=32)
mail_from_address="$(ynh_user_get_info "$admin" mail)" mail_from_address="$(ynh_user_get_info "$admin" mail)"
mail_from_name="$(ynh_user_get_info "$admin" firstname) $(ynh_user_get_info "$admin" lastname)" mail_from_name="$(ynh_user_get_info "$admin" firstname) $(ynh_user_get_info "$admin" lastname)"
ynh_app_setting_set --app=$app --key=api_secret --value=$api_secret ynh_app_setting_set --key=api_secret --value=$api_secret
ynh_app_setting_set --app=$app --key=app_key --value=$app_key ynh_app_setting_set --key=app_key --value=$app_key
ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key ynh_app_setting_set --key=phantomjs_key --value=$phantomjs_key
ynh_app_setting_set --app=$app --key=mail_from_address --value=$mail_from_address ynh_app_setting_set --key=mail_from_address --value=$mail_from_address
ynh_app_setting_set --app=$app --key=mail_from_name --value=$mail_from_name ynh_app_setting_set --key=mail_from_name --value=$mail_from_name
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" ynh_config_add --template=".env" --destination="$install_dir/.env"
chmod 600 "$install_dir/.env" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.env"
chown $app:$app "$install_dir/.env" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.env"
#================================================= #=================================================
# INSTALL PHANTOMJS # INSTALL PHANTOMJS
#================================================= #=================================================
ynh_script_progression --message="Installing PhantomJS..." --weight=1 ynh_script_progression "Installing PhantomJS..."
_install_phantomjs _install_phantomjs
#================================================= #=================================================
# BUILD THE APPLICATION # BUILD THE APPLICATION
#================================================= #=================================================
ynh_script_progression --message="Building the application..." --weight=1 ynh_script_progression "Building the application..."
pushd "$install_dir" pushd "$install_dir"
# Run the database migrations and initially fill the db # Run the database migrations and initially fill the db
"php$phpversion" artisan migrate --force "php$php_version" artisan migrate --force
"php$phpversion" artisan db:seed --force "php$php_version" artisan db:seed --force
# thanks to cloudron for this! # thanks to cloudron for this!
# This comments the check at https://github.com/invoiceninja/invoiceninja/blob/cadd1a3b44aed3dc5bd28d623efd4bb51c6d895a/app/Http/Controllers/AppController.php#L47 # This comments the check at https://github.com/invoiceninja/invoiceninja/blob/cadd1a3b44aed3dc5bd28d623efd4bb51c6d895a/app/Http/Controllers/AppController.php#L47
@ -68,20 +61,20 @@ popd
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_config_add_phpfpm
ynh_add_config --template="../conf/invoiceninja.cron" --destination="/etc/cron.d/$app" ynh_config_add --template="invoiceninja.cron" --destination="/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app"
chown root: "/etc/cron.d/$app" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,30 +1,24 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_config_remove_nginx
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_config_remove_phpfpm
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_safe_rm "/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,50 +7,47 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir" ynh_restore "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore "/etc/cron.d/$app"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_db_shell < ./db.sql
#================================================= #=================================================
# INSTALL PHANTOMJS # INSTALL PHANTOMJS
#================================================= #=================================================
ynh_script_progression --message="Installing PhantomJS..." --weight=1 ynh_script_progression "Installing PhantomJS..."
_install_phantomjs _install_phantomjs
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemctl --service=php$php_version-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -1,43 +1,31 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression "Ensuring downward compatibility..."
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then # FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
ynh_script_progression --message="Upgrading source files..." --weight=1 if ynh_app_upstream_version_changed; then
ynh_script_progression "Upgrading source files..."
# 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 --dest_dir="$install_dir" --keep=".env" ynh_setup_source --dest_dir="$install_dir" --keep=".env"
fi fi
chmod -R o-rwx "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# INSTALL PHANTOMJS # INSTALL PHANTOMJS
#================================================= #=================================================
ynh_script_progression --message="Installing PhantomJS..." --weight=1 ynh_script_progression "Installing PhantomJS..."
_install_phantomjs _install_phantomjs
@ -45,48 +33,49 @@ _install_phantomjs
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then # FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
ynh_script_progression --message="Updating a configuration file..." --weight=1 if ynh_app_upstream_version_changed; then
ynh_script_progression "Updating configuration..."
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" ynh_config_add --template=".env" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.env"
fi fi
#================================================= #=================================================
# UPGRADE DATABASE # UPGRADE DATABASE
#================================================= #=================================================
ynh_script_progression --message="Upgrading the database..." --weight=1 ynh_script_progression "Upgrading the database..."
pushd "$install_dir" pushd "$install_dir"
# Put the application into maintenance mode # Put the application into maintenance mode
php$phpversion artisan down php$php_version artisan down
# Optimize the framework for better performance # Optimize the framework for better performance
php$phpversion artisan optimize php$php_version artisan optimize
# Run the database migrations # Run the database migrations
php$phpversion artisan migrate --force php$php_version artisan migrate --force
php$phpversion artisan db:seed --force php$php_version artisan db:seed --force
# Bring the application out of maintenance mode # Bring the application out of maintenance mode
php$phpversion artisan up php$php_version artisan up
popd popd
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_config_add_phpfpm
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"

View file

@ -1,2 +0,0 @@
*~
*.sw[op]

View file

@ -1,11 +0,0 @@
--- a/public/index.php
+++ b/public/index.php
@@ -34,7 +34,7 @@
$app = require_once __DIR__.'/../bootstrap/app.php';
-// require_once __DIR__.'/../app/Constants.php';
+require_once __DIR__.'/../app/Constants.php';
/*
|--------------------------------------------------------------------------
| Run The Application