Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#!/bin/bash | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public License, | ||
# v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
# obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
# the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
# | ||
# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
# graphic logo is a trademark of OpenMRS Inc. | ||
# | ||
|
||
function create_and_drop_database() { | ||
# Run MySQL command with input from the specified SQL file | ||
mysql -u "${1}" -p"${2}" < "liquibase/scripts/drop_openmrs_schema.sql" | ||
mysql -u "${1}" -p"${2}" < "liquibase/scripts/create_openmrs_database.sql" | ||
|
||
} | ||
|
||
function run_openmrs_core_application() { | ||
# Change directory to the specified root folder | ||
# Run 'mvn clean install' | ||
mvn clean install | ||
|
||
# Change directory to the 'webapp' folder | ||
cd webapp | ||
|
||
# Remove the ~/.OpenMRS directory | ||
rm -r ~/.OpenMRS | ||
|
||
# Run 'mvn jetty:run' | ||
mvn jetty:run & | ||
|
||
sleep 20 | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
function open_web_browser_and_kill_java_server() { | ||
# Open the installation URL in the default web browser | ||
installation_url="http://localhost:8080/openmrs/initialsetup" | ||
if command -v xdg-open &> /dev/null; then | ||
xdg-open "$installation_url" | ||
elif command -v open &> /dev/null; then | ||
open "$installation_url" | ||
else | ||
echo "Unsupported operating system" | ||
fi | ||
|
||
# Optionally, you can add cleanup steps or additional actions here. | ||
|
||
# Pause to keep the script running while the browser opens | ||
read -p "Press Enter to continue..." | ||
|
||
# Stop Jetty (assuming the installation process is complete) | ||
killall java | ||
This comment has been minimized.
Sorry, something went wrong.
ibacher
|
||
cd .. | ||
} | ||
|
||
function generate_liquibase_snapshots_and_update() { | ||
cd liquibase/ | ||
. scripts/create_liquibase_snapshots.sh "${1}" "${2}" | ||
. scripts/fix_liquibase_snapshots.sh | ||
cd .. | ||
} | ||
|
||
function move_updated_snapshots() { | ||
mv liquibase/snapshots/liquibase-core-data-UPDATED-SNAPSHOT.xml api/src/main/resources/org/openmrs/liquibase/snapshots/core-data/"liquibase-core-data-$openMRS_version.x.xml" | ||
mv liquibase/snapshots/liquibase-schema-only-UPDATED-SNAPSHOT.xml api/src/main/resources/org/openmrs/liquibase/snapshots/schema-only/"liquibase-schema-only-$openMRS_version.x.xml" | ||
} | ||
|
||
function create_new_liquibase_update_file() { | ||
new_liquibase_file="liquibase-update-to-latest-${new_openmrs_version}.x.xml" | ||
cp "api/src/main/resources/liquibase-update-to-latest-template.xml" "api/src/main/resources/org/openmrs/liquibase/updates/$new_liquibase_file" | ||
|
||
database_updater_class="api/src/test/java/org/openmrs/util/DatabaseUpdaterDatabaseIT.java" | ||
variable_name="CHANGE_SET_COUNT_FOR_GREATER_THAN_2_1_X" | ||
|
||
# Increase the variable value by 1 | ||
sed -i "s/\($variable_name *= *\)[0-9]\+/\1$(( $(grep -o "$variable_name *= *[0-9]\+" "$database_updater_class" | awk '{print $NF}') + 1 ))/" "$database_updater_class" | ||
|
||
insert_line=" <include file=\"org/openmrs/liquibase/updates/$new_liquibase_file\"/>" | ||
sed -i -e '$!N;$!N;$i\'"$insert_line" "api/src/main/resources/liquibase-update-to-latest-from-1.9.x.xml" | ||
|
||
} | ||
|
||
function update_log_files_with_new_snapshots() { | ||
sed -i 's/\(<include file="org\/openmrs\/liquibase\/snapshots\/schema-only\/liquibase-schema-only-\)\([^"]*\)\.x\.xml"\/>/\1'"$openMRS_version"'\.x.xml"\/>/' "api/src/main/resources/liquibase-schema-only.xml" | ||
sed -i 's/\(<include file="org\/openmrs\/liquibase\/snapshots\/core-data\/liquibase-core-data-\)\([^"]*\)\.x\.xml"\/>/\1'"$openMRS_version"'\.x.xml"\/>/' "api/src/main/resources/liquibase-core-data.xml" | ||
sed -i 's/\(<include file="org\/openmrs\/liquibase\/updates\/liquibase-update-to-latest-\)\([^"]*\)\.x\.xml"\/>/\1'"${new_openmrs_version}"'\.x.xml"\/>/' "api/src/main/resources/liquibase-update-to-latest.xml" | ||
} | ||
|
||
function update_snapshot_tests() { | ||
change_log_java_file="api/src/main/java/org/openmrs/liquibase/ChangeLogVersions.java" | ||
# Use sed to add the new version to the lists in the Java class | ||
sed -i '/private static final List<String> SNAPSHOT_VERSIONS = Arrays.asList(/s/);/,\ "'"${openMRS_version}"'"\);/' "$change_log_java_file" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ManojLL
Author
Owner
|
||
sed -i '/private static final List<String> UPDATE_VERSIONS = Arrays.asList(/s/);/,\ "'"${new_openmrs_version}"'"\);/' "$change_log_java_file" | ||
|
||
sed -i "s/\(openmrs_version.txt=\).*/\1${new_openmrs_version}.0-SNAPSHOT/" "liquibase/scripts/fix_liquibase_snapshots.sh" | ||
|
||
} | ||
|
||
function echo_usage() { | ||
echo "usage: . scripts/test_liquibase_snapshots.sh <username> <password>" | ||
} | ||
|
||
config_file="liquibase/scripts/openmrs_version.txt" | ||
|
||
# Function to read the value of a key from the config file | ||
read_config() { | ||
key=$1 | ||
value=$(grep "^$key=" "$config_file" | cut -d '=' -f 2) | ||
echo "$value" | ||
} | ||
|
||
# Function to update the value of a key in the config file | ||
update_config() { | ||
key=$1 | ||
new_value=$2 | ||
sed -i "s/^$key=.*/$key=$new_value/" "$config_file" | ||
} | ||
|
||
# Read the current openmrs_version from the config file | ||
openMRS_version=$(read_config "openmrs_version") | ||
new_openmrs_version=$(echo "$openMRS_version + 0.1" | bc) | ||
|
||
create_and_drop_database "${1}" "${2}" | ||
run_openmrs_core_application | ||
open_web_browser_and_kill_java_server | ||
generate_liquibase_snapshots_and_update "${1}" "${2}" | ||
move_updated_snapshots | ||
create_new_liquibase_update_file | ||
update_log_files_with_new_snapshots | ||
update_snapshot_tests | ||
|
||
update_config "openmrs_version" "$new_openmrs_version" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public License, | ||
# v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
# obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
# the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
# | ||
# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
# graphic logo is a trademark of OpenMRS Inc. | ||
# | ||
|
||
openmrs_version=2.7 | ||
This comment has been minimized.
Sorry, something went wrong.
ibacher
|
I'm not sure the
sleep
should be part of this function. Let it be part of the script, so it's obvious where it's happening.