diff --git a/demo.diff b/demo.diff new file mode 100644 index 0000000..cd80090 --- /dev/null +++ b/demo.diff @@ -0,0 +1,103 @@ +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` ++ ++ 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 ++ ++ + diff --git a/gnuhealth.changes b/gnuhealth.changes index 9083e6b..c46ac3e 100644 --- a/gnuhealth.changes +++ b/gnuhealth.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Nov 11 18:22:37 UTC 2019 - Axel Braun + +- demo.diff to update installation script for demo-db added + ------------------------------------------------------------------- Tue Jun 11 16:10:20 UTC 2019 - Axel Braun diff --git a/gnuhealth.spec b/gnuhealth.spec index 7d77dcf..b10fb62 100644 --- a/gnuhealth.spec +++ b/gnuhealth.spec @@ -40,6 +40,7 @@ Source3: gnuhealth.service Source4: gnuhealth-webdav@.service Source5: openSUSE-gnuhealth-setup Source6: gnuhealth +Patch0: demo.diff BuildArch: noarch @@ -94,7 +95,7 @@ You would need the GNU Health Client as well, on the same or a different machine %prep %setup -q -n %{name}-%{version} -#%patch0 -p1 +%patch0 -p1 cp %{S:1} . cp %{S:2} . @@ -116,6 +117,10 @@ mkdir -p -m 755 %{buildroot}%{_bindir} install -p -m 755 gnuhealth-control %{buildroot}%{_bindir}/gnuhealth-control install -p -m 755 %{S:5} %{buildroot}%{_bindir}/openSUSE-gnuhealth-setup install -p -m 755 %{S:6} %{buildroot}%{_bindir}/gnuhealth +install -p -m 755 scripts/demo/install_demo_database.sh %{buildroot}%{_bindir}/install_demo_database.sh + +#delete empty demo directory +rm -rf scripts/demo mkdir -p $RPM_BUILD_ROOT%{_unitdir} install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service