mirror of
https://github.com/YunoHost-Apps/ofbiz_ynh.git
synced 2024-09-03 19:46:33 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
0a38912160
commit
cabb109f5b
8 changed files with 123 additions and 139 deletions
|
@ -17,7 +17,8 @@ userdoc = "https://cwiki.apache.org/confluence/display/OFBIZ/Documentation"
|
|||
code = "https://github.com/apache/ofbiz-framework"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = false
|
||||
|
||||
|
@ -43,6 +44,7 @@ ram.runtime = "50M"
|
|||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.ports]
|
||||
|
||||
|
|
|
@ -1,24 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
_ci_fix_nginx() {
|
||||
# Ofbiz returns a 404 on its root, so let's redirect to another path also served
|
||||
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
|
||||
if ynh_in_ci_tests; then
|
||||
echo 'rewrite ^/$ /catalog/;' >> "../conf/nginx.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -8,40 +8,37 @@
|
|||
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 SYSTEM 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 systemd service unit
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
# Backup the logrotate configuration
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/var/log/$app/"
|
||||
ynh_backup "/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
ynh_print_info "Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="${db_name}" > db.sql
|
||||
ynh_psql_dump_db --database="${db_name}olap" > dbolap.sql
|
||||
|
@ -51,4 +48,4 @@ ynh_psql_dump_db --database="${db_name}tenant" > dbtenant.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)."
|
||||
|
|
|
@ -10,27 +10,27 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="$app" --action="stop"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
_ci_fix_nginx
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="$app" --action="start"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app"
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -10,81 +10,80 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
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"
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a PostgreSQL database..."
|
||||
ynh_script_progression "Configuring a PostgreSQL database..."
|
||||
|
||||
# ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name} WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name}olap WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name}tenant WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
# ynh_psql_db_shell <<< "CREATE DATABASE ${db_name} WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_db_shell <<< "CREATE DATABASE ${db_name}olap WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_db_shell <<< "CREATE DATABASE ${db_name}tenant WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..."
|
||||
ynh_script_progression "Building app..."
|
||||
|
||||
ynh_add_config --template="url.properties" --destination="$install_dir/framework/webapp/config/url.properties"
|
||||
ynh_config_add --template="url.properties" --destination="$install_dir/framework/webapp/config/url.properties"
|
||||
|
||||
ynh_add_config --template="security.properties" --destination="$install_dir/framework/security/config/security.properties"
|
||||
ynh_config_add --template="security.properties" --destination="$install_dir/framework/security/config/security.properties"
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/framework/catalina/ofbiz-component.xml" --match_string="8443" --replace_string="$port"
|
||||
ynh_replace --file="$install_dir/framework/catalina/ofbiz-component.xml" --match="8443" --replace="$port"
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc:postgresql://127.0.0.1/ofbiz" --replace_string="jdbc:postgresql://127.0.0.1:5432/${db_name}"
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc:postgresql://127.0.0.1/ofbizolap" --replace_string="jdbc:postgresql://127.0.0.1:5432/${db_name}olap"
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc:postgresql://127.0.0.1/ofbiztenant" --replace_string="jdbc:postgresql://127.0.0.1:5432/${db_name}tenant"
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc-username=\"ofbiz\"" --replace_string="jdbc-username=\"$db_user\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc-password=\"ofbiz\"" --replace_string="jdbc-password=\"$db_pwd\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match_string="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localderby\"" --replace_string="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localpostgres\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match_string="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localderbyolap\"" --replace_string="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localpostgresolap\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match_string="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localderbytenant\"" --replace_string="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localpostgrestenant\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc:postgresql://127.0.0.1/ofbiz" --replace="jdbc:postgresql://127.0.0.1:5432/${db_name}"
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc:postgresql://127.0.0.1/ofbizolap" --replace="jdbc:postgresql://127.0.0.1:5432/${db_name}olap"
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc:postgresql://127.0.0.1/ofbiztenant" --replace="jdbc:postgresql://127.0.0.1:5432/${db_name}tenant"
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc-username=\"ofbiz\"" --replace="jdbc-username=\"$db_user\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc-password=\"ofbiz\"" --replace="jdbc-password=\"$db_pwd\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localderby\"" --replace="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localpostgres\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localderbyolap\"" --replace="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localpostgresolap\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localderbytenant\"" --replace="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localpostgrestenant\""
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/framework/security/config/security.properties" --match_string="host-headers-allowed=.*" --replace_string="host-headers-allowed=$domain"
|
||||
ynh_replace_string --target_file="$install_dir/framework/security/config/security.properties" --match_string="security.ldap.enable=false" --replace_string="security.ldap.enable=true"
|
||||
ynh_replace_string --target_file="$install_dir/framework/security/config/jndiLdap.properties" --match_string="ldap.dn.template=cn=%u,ou=system" --replace_string="ldap.dn.template=uid=%u,ou=users,dc=yunohost,dc=org"
|
||||
ynh_replace --file="$install_dir/framework/security/config/security.properties" --match="host-headers-allowed=.*" --replace="host-headers-allowed=$domain"
|
||||
ynh_replace --file="$install_dir/framework/security/config/security.properties" --match="security.ldap.enable=false" --replace="security.ldap.enable=true"
|
||||
ynh_replace --file="$install_dir/framework/security/config/jndiLdap.properties" --match="ldap.dn.template=cn=%u,ou=system" --replace="ldap.dn.template=uid=%u,ou=users,dc=yunohost,dc=org"
|
||||
|
||||
ynh_add_config --template="build.gradle" --destination="$install_dir/build.gradle"
|
||||
ynh_config_add --template="build.gradle" --destination="$install_dir/build.gradle"
|
||||
|
||||
pushd "$install_dir"
|
||||
ynh_exec_as "$app" ./gradle/init-gradle-wrapper.sh
|
||||
ynh_exec_as "$app" ./gradlew cleanAll loadAll 2>&1
|
||||
ynh_exec_as_app ./gradle/init-gradle-wrapper.sh
|
||||
ynh_exec_as_app ./gradlew cleanAll loadAll 2>&1
|
||||
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
|
||||
_ci_fix_nginx
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #--line_match="is started and ready"
|
||||
ynh_systemctl --service="$app" --action="start" #--wait_until="is started and ready"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -10,23 +10,23 @@ 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..."
|
||||
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
|
||||
ynh_script_progression "Removing $app service integration..."
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
|
||||
|
||||
# Remove additional databases
|
||||
ynh_psql_drop_db "${db_name}tenant"
|
||||
|
@ -36,4 +36,4 @@ ynh_psql_drop_db "${db_name}olap"
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -10,56 +10,55 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
ynh_restore "$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 THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
ynh_script_progression "Restoring the PostgreSQL database..."
|
||||
|
||||
# ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name} WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name}olap WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name}tenant WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
# ynh_psql_db_shell <<< "CREATE DATABASE ${db_name} WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_db_shell <<< "CREATE DATABASE ${db_name}olap WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
ynh_psql_db_shell <<< "CREATE DATABASE ${db_name}tenant WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
|
||||
|
||||
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="${db_name}" < ./db.sql
|
||||
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="${db_name}olap" < ./dbolap.sql
|
||||
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="${db_name}tenant" < ./dbtenant.sql
|
||||
ynh_psql_db_shell < ./db.sql
|
||||
ynh_psql_db_shell < ./dbolap.sql
|
||||
ynh_psql_db_shell < ./dbtenant.sql
|
||||
|
||||
#=================================================
|
||||
# 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/systemd/system/$app.service"
|
||||
ynh_restore "/etc/systemd/system/$app.service"
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/var/log/$app/"
|
||||
ynh_restore "/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="is started and ready"
|
||||
ynh_systemctl --service="$app" --action="start" --wait_until="is started and ready"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -10,94 +10,93 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped OFBiz Service"
|
||||
ynh_systemctl --service="$app" --action="stop" --log_path="systemd" --wait_until="Stopped OFBiz Service"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# Remove legacy admin key
|
||||
if [ -n "${admin:-}" ]; then
|
||||
ynh_app_setting_delete --app="$app" --key=admin
|
||||
ynh_app_setting_delete --key=admin
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir" --full_replace=1
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
ynh_setup_source --dest_dir="$install_dir" --full_replace
|
||||
|
||||
#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"
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..."
|
||||
ynh_script_progression "Building app..."
|
||||
|
||||
# ynh_replace_string --target_file="$install_dir/framework/webapp/config/url.properties" --match_string="port.https=" --replace_string="port.https=443"
|
||||
# ynh_replace_string --target_file="$install_dir/framework/webapp/config/url.properties" --match_string="force.https.host=" --replace_string="force.https.host=$domain"
|
||||
# ynh_replace_string --target_file="$install_dir/framework/webapp/config/url.properties" --match_string="port.http=8080" --replace_string="port.http=80"
|
||||
# ynh_replace_string --target_file="$install_dir/framework/webapp/config/url.properties" --match_string="force.http.host=" --replace_string="force.http.host=$domain"
|
||||
# ynh_replace --file="$install_dir/framework/webapp/config/url.properties" --match="port.https=" --replace="port.https=443"
|
||||
# ynh_replace --file="$install_dir/framework/webapp/config/url.properties" --match="force.https.host=" --replace="force.https.host=$domain"
|
||||
# ynh_replace --file="$install_dir/framework/webapp/config/url.properties" --match="port.http=8080" --replace="port.http=80"
|
||||
# ynh_replace --file="$install_dir/framework/webapp/config/url.properties" --match="force.http.host=" --replace="force.http.host=$domain"
|
||||
|
||||
ynh_add_config --template="url.properties" --destination="$install_dir/framework/webapp/config/url.properties"
|
||||
ynh_config_add --template="url.properties" --destination="$install_dir/framework/webapp/config/url.properties"
|
||||
|
||||
ynh_add_config --template="security.properties" --destination="$install_dir/framework/security/config/security.properties"
|
||||
ynh_config_add --template="security.properties" --destination="$install_dir/framework/security/config/security.properties"
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/framework/catalina/ofbiz-component.xml" --match_string="8443" --replace_string="$port"
|
||||
ynh_replace --file="$install_dir/framework/catalina/ofbiz-component.xml" --match="8443" --replace="$port"
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc:postgresql://127.0.0.1/ofbiz" --replace_string="jdbc:postgresql://127.0.0.1:5432/${db_name}"
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc:postgresql://127.0.0.1/ofbizolap" --replace_string="jdbc:postgresql://127.0.0.1:5432/${db_name}olap"
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc:postgresql://127.0.0.1/ofbiztenant" --replace_string="jdbc:postgresql://127.0.0.1:5432/${db_name}tenant"
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc-username=\"ofbiz\"" --replace_string="jdbc-username=\"$db_user\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" --match_string="jdbc-password=\"ofbiz\"" --replace_string="jdbc-password=\"$db_pwd\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match_string="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localderby\"" --replace_string="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localpostgres\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match_string="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localderbyolap\"" --replace_string="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localpostgresolap\""
|
||||
ynh_replace_string --target_file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match_string="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localderbytenant\"" --replace_string="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localpostgrestenant\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc:postgresql://127.0.0.1/ofbiz" --replace="jdbc:postgresql://127.0.0.1:5432/${db_name}"
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc:postgresql://127.0.0.1/ofbizolap" --replace="jdbc:postgresql://127.0.0.1:5432/${db_name}olap"
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc:postgresql://127.0.0.1/ofbiztenant" --replace="jdbc:postgresql://127.0.0.1:5432/${db_name}tenant"
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc-username=\"ofbiz\"" --replace="jdbc-username=\"$db_user\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" --match="jdbc-password=\"ofbiz\"" --replace="jdbc-password=\"$db_pwd\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localderby\"" --replace="group-map group-name=\"org.apache.ofbiz\" datasource-name=\"localpostgres\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localderbyolap\"" --replace="group-map group-name=\"org.apache.ofbiz.olap\" datasource-name=\"localpostgresolap\""
|
||||
ynh_replace --file="$install_dir/framework/entity/config/entityengine.xml" \
|
||||
--match="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localderbytenant\"" --replace="group-map group-name=\"org.apache.ofbiz.tenant\" datasource-name=\"localpostgrestenant\""
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/framework/security/config/security.properties" --match_string="host-headers-allowed=.*" --replace_string="host-headers-allowed=$domain"
|
||||
ynh_replace_string --target_file="$install_dir/framework/security/config/security.properties" --match_string="security.ldap.enable=false" --replace_string="security.ldap.enable=true"
|
||||
ynh_replace_string --target_file="$install_dir/framework/security/config/jndiLdap.properties" --match_string="ldap.dn.template=cn=%u,ou=system" --replace_string="ldap.dn.template=uid=%u,ou=users,dc=yunohost,dc=org"
|
||||
ynh_replace --file="$install_dir/framework/security/config/security.properties" --match="host-headers-allowed=.*" --replace="host-headers-allowed=$domain"
|
||||
ynh_replace --file="$install_dir/framework/security/config/security.properties" --match="security.ldap.enable=false" --replace="security.ldap.enable=true"
|
||||
ynh_replace --file="$install_dir/framework/security/config/jndiLdap.properties" --match="ldap.dn.template=cn=%u,ou=system" --replace="ldap.dn.template=uid=%u,ou=users,dc=yunohost,dc=org"
|
||||
|
||||
ynh_add_config --template="build.gradle" --destination="$install_dir/build.gradle"
|
||||
ynh_config_add --template="build.gradle" --destination="$install_dir/build.gradle"
|
||||
|
||||
pushd "$install_dir"
|
||||
ynh_exec_as "$app" ./gradle/init-gradle-wrapper.sh
|
||||
ynh_exec_as "$app" ./gradlew cleanAll loadAll 2>&1
|
||||
ynh_exec_as_app ./gradle/init-gradle-wrapper.sh
|
||||
ynh_exec_as_app ./gradlew cleanAll loadAll 2>&1
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
_ci_fix_nginx
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="is started and ready"
|
||||
ynh_systemctl --service="$app" --action="start" --wait_until="is started and ready"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue