Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store
Empty file removed conf/extra_php-fpm.conf
Empty file.
4 changes: 2 additions & 2 deletions conf/invoiceninja.cron
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0 8 * * * __APP__ /usr/bin/php__PHPVERSION__ __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-invoices -q
0 8 * * * __APP__ /usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/artisan ninja:send-reminders -q

2 changes: 1 addition & 1 deletion conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ location ^~ __PATH__/ {
location ~ ^__PATH__/index\.php(/.*|)$ {
fastcgi_split_path_info ^(.+?\.php)(/.*|)$;
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;
include fastcgi_params;
Expand Down
4 changes: 3 additions & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ code = "https://github.com/invoiceninja/invoiceninja"
cpe = "cpe:2.3:a:invoiceninja:invoice_ninja"

[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true

Expand Down Expand Up @@ -67,6 +68,7 @@ ram.runtime = "50M"
[resources.system_user]

[resources.install_dir]
group = "www-data:r-x"

[resources.permissions]
main.url = "/"
Expand Down
21 changes: 5 additions & 16 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash

#=================================================
# COMMON VARIABLES
#=================================================

#=================================================
# PERSONAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

_install_phantomjs() {
Expand All @@ -14,16 +10,9 @@ _install_phantomjs() {
ynh_setup_source --dest_dir="$source_dir" --source_id="phantomjs"

pushd "$source_dir"
ynh_exec_warn_less env PREFIX="$destdir" ./configure
ynh_exec_warn_less make -j "$(nproc)"
ynh_exec_warn_less make install
ynh_hide_warnings env PREFIX="$destdir" ./configure
ynh_hide_warnings make -j "$(nproc)"
ynh_hide_warnings make install
popd
ynh_secure_remove --file="$source_dir"
ynh_safe_rm "$source_dir"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
25 changes: 8 additions & 17 deletions scripts/backup
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."

#=================================================
# BACKUP THE APP MAIN DIR
#=================================================

ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"

#=================================================
# 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
#=================================================

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
#=================================================
# BACKUP VARIOUS FILES
#=================================================

ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup "/etc/cron.d/$app"

#=================================================
# 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
#=================================================

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)."
22 changes: 7 additions & 15 deletions scripts/change_url
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
#!/bin/bash

#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# STANDARD MODIFICATIONS
#=================================================
#=================================================
# 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
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_script_progression "Updating configuration..."

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
#=================================================

ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"
53 changes: 23 additions & 30 deletions scripts/install
Original file line number Diff line number Diff line change
@@ -1,63 +1,56 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# 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
ynh_setup_source --dest_dir="$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"
#=================================================
# 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)"
app_key="$(ynh_string_random --length=32)"
phantomjs_key=$(ynh_string_random --length=32)
mail_from_address="$(ynh_user_get_info "$admin" mail)"
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 --app=$app --key=app_key --value=$app_key
ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key
ynh_app_setting_set --app=$app --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=api_secret --value=$api_secret
ynh_app_setting_set --key=app_key --value=$app_key
ynh_app_setting_set --key=phantomjs_key --value=$phantomjs_key
ynh_app_setting_set --key=mail_from_address --value=$mail_from_address
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"
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 | 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 | chown $app:$app "$install_dir/.env"

#=================================================
# INSTALL PHANTOMJS
#=================================================
ynh_script_progression --message="Installing PhantomJS..." --weight=1
ynh_script_progression "Installing PhantomJS..."

_install_phantomjs

#=================================================
# BUILD THE APPLICATION
#=================================================
ynh_script_progression --message="Building the application..." --weight=1
ynh_script_progression "Building the application..."

pushd "$install_dir"
# Run the database migrations and initially fill the db
"php$phpversion" artisan migrate --force
"php$phpversion" artisan db:seed --force
"php$php_version" artisan migrate --force
"php$php_version" artisan db:seed --force

# thanks to cloudron for this!
# This comments the check at https://github.com/invoiceninja/invoiceninja/blob/cadd1a3b44aed3dc5bd28d623efd4bb51c6d895a/app/Http/Controllers/AppController.php#L47
Expand All @@ -68,20 +61,20 @@ popd
#=================================================
# 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
ynh_add_nginx_config
ynh_config_add_nginx

# 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"
chmod 644 "/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
ynh_config_add --template="invoiceninja.cron" --destination="/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"
#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
#=================================================

ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"
16 changes: 5 additions & 11 deletions scripts/remove
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# 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
ynh_remove_nginx_config
ynh_config_remove_nginx

# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
ynh_config_remove_phpfpm

# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
ynh_safe_rm "/etc/cron.d/$app"

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"
Loading