Skip to content

Commit

Permalink
Merge pull request #15 from aktin/feature/update-from-1.5.1rc1
Browse files Browse the repository at this point in the history
Feature/update from 1.5.1rc1
  • Loading branch information
akomii authored Nov 22, 2024
2 parents 57cb196 + 36b38a6 commit 00db565
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ prepare_management_scripts_and_files() {

# Replace placeholders
sed -e "s|__PACKAGE_NAME__|${PACKAGE_NAME}|g" -e "s|__PACKAGE_VERSION__|${PACKAGE_VERSION}|g" "${DIR_CURRENT}/control" > "${DIR_BUILD}/DEBIAN/control"
sed -e "s|__TRIGGER_PREFIX__|${TRIGGER_PREFIX}|g" "${DIR_CURRENT}/postinst" > "${DIR_BUILD}/DEBIAN/postinst"
sed -e "s|__TRIGGER_PREFIX__|${TRIGGER_PREFIX}|g" -e "s|__POSTGRES_JDBC_VERSION__|${POSTGRES_JDBC_VERSION}|g" "${DIR_CURRENT}/postinst" > "${DIR_BUILD}/DEBIAN/postinst"
sed -e "/^__I2B2_DROP_STATEMENT__/{r ${DIR_RESOURCES}/sql/i2b2_drop.sql" -e "d;}" "${DIR_CURRENT}/postrm" > "${DIR_BUILD}/DEBIAN/postrm"

# Copy necessary scripts
Expand Down
26 changes: 26 additions & 0 deletions src/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,38 @@ set_wildfly_permissions() {
log_success "WildFly user permissions set"
}

update_aktin_ds_jdbc_version() {
local deploy_dir="${1:-/opt/wildfly/standalone/deployments}"
local new_driver="${2:-}"
local ds_file="${deploy_dir}/aktin-ds.xml"
log_info "Updating JDBC driver version in aktin-ds.xml..."

if [[ ! -f "${ds_file}" ]]; then
log_info "aktin-ds.xml not found, skipping driver update"
return 0
fi
if ! sed -i "s|<driver>postgresql-.*\.jar</driver>|<driver>postgresql-${new_driver}.jar</driver>|" "${ds_file}" 2>/dev/null; then
log_error "Failed to update JDBC driver version"
return 1
fi
log_success "JDBC driver version updated to ${new_driver}"
return 0
}

main() {
set -euo pipefail
case "$OPERATION" in
configure)
# Runs during installation/upgrade after files have been unpacked
source_helper_script
local version="${2}"
if [ "${version}" = "1.5.3" ]; then
# Runs only on update of package 1.5.3
stop_service "wildfly"
cleanup_wildfly_deployment_markers
remove_datasource_files "" "crc-ds" "im-ds" "ont-ds" "pm-ds" "work-ds"
update_aktin_ds_jdbc_version "" "__POSTGRES_JDBC_VERSION__"
fi
systemctl enable apache2
check_and_start_service "apache2"
activate_php_curl_extension
Expand Down
22 changes: 2 additions & 20 deletions src/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,18 @@ backup_wildfly_logs() {
done
}

cleanup_wildfly_deployment_markers() {
local deploy_dir="/opt/wildfly/standalone/deployments"
log_info "Cleaning up WildFly deployment markers..."

if [[ ! -d "${deploy_dir}" ]]; then
log_warn "Deployment directory not found"
return 0
fi

# Remove all deployment markers while preserving the actual artifacts
find "${deploy_dir}" -type f \( \
-name "*.deployed" -o \
-name "*.dodeploy" -o \
-name "*.failed" -o \
-name "*.undeployed" \
\) -delete
log_success "Deployment markers cleaned up"
}

main() {
set -euo pipefail
source_helper_script
case "$OPERATION" in
remove)
# Runs during package removal before files are deleted
source_helper_script
stop_service "wildfly"
create_temp_helper
;;
upgrade)
# Runs during package upgrade before old files are deleted
source_helper_script
stop_service "wildfly"
backup_wildfly_logs
cleanup_wildfly_deployment_markers
Expand Down
41 changes: 41 additions & 0 deletions src/resources/helper.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,44 @@ stop_service() {
done
log_success "Service ${service} stopped successfully"
}

cleanup_wildfly_deployment_markers() {
local deploy_dir="${1:-/opt/wildfly/standalone/deployments}"
log_info "Cleaning up WildFly deployment markers..."

if [[ ! -d "${deploy_dir}" ]]; then
log_warn "Deployment directory not found"
return 0
fi

# Remove all deployment markers while preserving the actual artifacts
find "${deploy_dir}" -type f \( \
-name "*.deployed" -o \
-name "*.dodeploy" -o \
-name "*.failed" -o \
-name "*.undeployed" \
-name "*.swp" \
\) -delete
log_success "Deployment markers cleaned up"
}

# Removes specified datasource files from deployment directory
# (as datasources moved to standalone.xml in V1.6)
# @param $1 Deployment directory path (optional, defaults to WildFly deployments)
# @param $2... One or more datasource names without .xml extension
remove_datasource_files() {
local deploy_dir="${1:-/opt/wildfly/standalone/deployments}"
shift
local -r datasources=("$@")
log_info "Removing datasource files..."

for ds in "${datasources[@]}"; do
echo "${deploy_dir}/${ds}.xml"
if ! rm -f "${deploy_dir}/${ds}.xml" 2>/dev/null; then
log_error "Failed to remove ${ds} datasource files"
return 1
fi
done
log_success "Datasource files removed successfully"
return 0
}

0 comments on commit 00db565

Please sign in to comment.