Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
gnuhealth.11469
demo.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File demo.diff of Package gnuhealth.11469
diff --git a/scripts/demo/install_demo_database.sh b/scripts/demo/install_demo_database.sh --- a/scripts/demo/install_demo_database.sh +++ b/scripts/demo/install_demo_database.sh @@ -1,47 +1,71 @@ #!/usr/bin/env bash # Script to download/unpack and locally install the GNU Health demo database -URL="http://health.gnu.org/downloads/postgres_dumps/gnuhealth-3.0.1-demo-data.tar.gz" -DB="gnuhealth_demo" +URL="https://www.gnuhealth.org/downloads/postgres_dumps/gnuhealth-$1-demo.sql.gz" +DB="ghdemo$1" -if [[ $USER != "gnuhealth" ]]; then - echo "Run script as gnuhealth user" +help() +{ + cat << EOF + +GNU Health HMIS demo database installer + +usage: `basename $0` <db_version> + + Example: + $ bash ./install_demo_dabase.sh 36 + + will install the latest demo db for version 3.6.x +EOF + exit 0 +} + +bailout () { + echo "Error" + echo "Cleaning up..." + cleanup exit 1 + } + + +if [ $# -eq 0 ]; then + help fi +cleanup () { + rm -f gnuhealth_demo_database.sql.gz + rm -f gnuhealth_demo_database.sql + } -if psql -l | grep -q "$DB"; then + +if psql -l | grep -wq "$DB"; then echo "$DB database already exists" echo " delete it/change target database before proceeding" - exit 1 + bailout fi -function cleanup { - rm -f demo_database.sql.gz - rm -f demo_database.sql - exit - } -trap cleanup SIGHUP SIGINT SIGTERM EXIT -echo -n 'Downloading the demo database...' -wget -q "$URL" -O demo_database.sql.gz -echo 'COMPLETE' +echo -n "Downloading the demo database..." +wget "$URL" -O gnuhealth_demo_database.sql.gz || bailout +echo 'SUCCESS...' -echo -n 'Unpacking the database...' -gunzip -q demo_database.sql.gz -echo 'COMPLETE' +echo -n "Unpacking the database..." +gunzip -q gnuhealth_demo_database.sql.gz || bailout +echo 'SUCCESS...' -echo -n 'Initializing empty database...' -psql -q -d template1 -c "create database $DB encoding='unicode'" -echo 'COMPLETE' +echo -n "Initializing empty database..." +createdb $DB +echo 'SUCCESS...' -echo -n 'Importing demo database...' -psql -q "$DB" < demo_database.sql > /dev/null 2>&1 -echo 'COMPLETE' +echo "Importing demo database..." +psql -q "$DB" < gnuhealth_demo_database.sql > /dev/null 2>&1 || bailout +echo "IMPORT OF DEMO DATABASE $DB COMPLETED SUCCESFULLY !" -echo 'Use Tryton to access (with non-gnuhealth user!)...' +echo "Login Info:" echo " Database: $DB" -echo ' Username: admin' -echo ' Password: gnusolidario' +echo " Username: admin" +echo " Password: gnusolidario" exit 0 + +
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor