Skip to content

Commit

Permalink
Update package installation to support custom packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfschmidt committed Mar 24, 2023
1 parent 6fe6a0c commit 295f6f2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/app/views/package.jst.eco
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<% if @package_installation: %>
<% if @local_gemfiles: %>
<li><code>root> zammad config:set BUNDLE_DEPLOYMENT=0</code></li>
<li><code>root> zammad run bundle install --no-deployment</code></li>
<li><code>root> bundle config set --local deployment 'false'</code></li>
<li><code>root> zammad run bundle install</code></li>
<% end %>
<li><code>root> zammad run rake zammad:package:migrate</code></strong></li>
<li><code>root> zammad run rake assets:precompile</code></strong></li>
Expand Down
42 changes: 41 additions & 1 deletion contrib/packager.io/functions
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,56 @@ function elasticsearch_searchindex_rebuild () {
fi
}

function detect_local_gemfiles () {
if ls ${ZAMMAD_DIR}/Gemfile.local* 1> /dev/null 2>&1; then
zammad config:set BUNDLE_DEPLOYMENT=0
zammad run bundle config set --local deployment 'false'
zammad run bundle install
fi
}

function detect_zammad_packages () {
if [ "$(zammad run rails r 'puts Package.count.positive?')" == "true" ] && [ -n "$(which yarn 2> /dev/null)" ] && [ -n "$(which node 2> /dev/null)" ]; then
echo "# Detected custom packages..."
ZAMMAD_PACKAGES="yes"
else
echo "# No custom packages detected..."
ZAMMAD_PACKAGES="no"
fi
}

function zammad_packages_uninstall_all_files () {
detect_zammad_packages

if [ "${ZAMMAD_PACKAGES}" == "yes" ]; then
echo "# Remove custom packages files temporarily..."
zammad run rake zammad:package:uninstall_all_files
fi
}

function zammad_packages_reinstall_all () {
detect_zammad_packages

if [ "${ZAMMAD_PACKAGES}" == "yes" ]; then
echo "# Setup custom packages files..."
zammad run rake zammad:package:reinstall_all
detect_local_gemfiles
zammad run rake zammad:package:migrate
zammad run rake assets:precompile
fi
}

function update_or_install () {

if [ -f ${ZAMMAD_DIR}/config/database.yml ]; then

echo "# Clear cache..."
zammad run rails r Cache.clear

update_database

update_translations

zammad_packages_reinstall_all
else
REBUILD_ES_SEARCHINDEX="yes"
create_database_password
Expand Down
13 changes: 12 additions & 1 deletion contrib/packager.io/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
# packager.io preinstall script
#

PATH=/opt/zammad/bin:/opt/zammad/vendor/bundle/bin:/sbin:/bin:/usr/sbin:/usr/bin:

# import config
. /opt/zammad/contrib/packager.io/config

# import functions
. /opt/zammad/contrib/packager.io/functions

#
# Make sure that after installation/update there can be only one sprockets manifest,
# the one coming from the package. The package manager will ignore any duplicate files
# which might come from a backup restore and/or a manual 'assets:precompile' command run.
# These duplicates can cause the application to fail, however.
#
rm -f /opt/zammad/public/assets/.sprockets-manifest-*.json || true
rm -f /opt/zammad/public/assets/.sprockets-manifest-*.json || true

# remove local files of the packages
zammad_packages_uninstall_all_files

0 comments on commit 295f6f2

Please sign in to comment.