When setting up a new Koha instance with `koha-create`, you have the option of specifying an SQL file with default data to load. This is done by setting the DEFAULTSQL variable in /etc/koha/koha-sites.conf to point to a filename of your choice. However, if you set the DEFAULTSQL variable to something like this: DEFAULTSQL="/home/user/dump.sql" and then run `koha-create --create-db instance`, you get this error: gzip: /home/user/dump.sql: not in gzip format This is due to the following code from debian/scripts/koha-create, where the call to `zcat` fails if the file is not in gzip format. if [ -e "$DEFAULTSQL" ] then # Populate the database with default content. zcat "$DEFAULTSQL" | sed "s/__KOHASITE__/koha_$name/g" | mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpwd" "$mysqldb"
Created attachment 79541 [details] [review] Bug 21440: koha-create expects the file passed by $DEFAULTSQL to be in gzip format koha-create contains a call to `zcat` which fails if the file passed as an argument is not in gzip format. This patch fixes the issue by adding the -f flag to the zcat call in koha-create, as per the top-voted answers in the following SE URLs: https://unix.stackexchange.com/a/77309 https://unix.stackexchange.com/a/131944 Test plan: 1) in /etc/koha/koha-sites.conf, set the DEFAULTSQL variable to point to an _uncompressed_ SQL database dump 2) run `koha-create --create-db instance` and notice how it fails with: gzip: /path/to/dump.sql: not in gzip format 3) apply the patch 4) notice the extra line of information "The SQL file can be optionally compressed with gzip" in koha-sites.conf 5) run the `koha-create` command again, this time it should work 6) repeat with DEFAULTSQL pointing to a gzip'd dump, it should work too
Created attachment 80216 [details] [review] Bug 21440: koha-create expects the file passed by $DEFAULTSQL to be in gzip format koha-create contains a call to `zcat` which fails if the file passed as an argument is not in gzip format. This patch fixes the issue by adding the -f flag to the zcat call in koha-create, as per the top-voted answers in the following SE URLs: https://unix.stackexchange.com/a/77309 https://unix.stackexchange.com/a/131944 Test plan: 1) in /etc/koha/koha-sites.conf, set the DEFAULTSQL variable to point to an _uncompressed_ SQL database dump 2) run `koha-create --create-db instance` and notice how it fails with: gzip: /path/to/dump.sql: not in gzip format 3) apply the patch 4) notice the extra line of information "The SQL file can be optionally compressed with gzip" in koha-sites.conf 5) run the `koha-create` command again, this time it should work 6) repeat with DEFAULTSQL pointing to a gzip'd dump, it should work too Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Nice little fix that works well, signing off.
Created attachment 80235 [details] [review] Bug 21440: koha-create expects the file passed by $DEFAULTSQL to be in gzip format koha-create contains a call to `zcat` which fails if the file passed as an argument is not in gzip format. This patch fixes the issue by adding the -f flag to the zcat call in koha-create, as per the top-voted answers in the following SE URLs: https://unix.stackexchange.com/a/77309 https://unix.stackexchange.com/a/131944 Test plan: 1) in /etc/koha/koha-sites.conf, set the DEFAULTSQL variable to point to an _uncompressed_ SQL database dump 2) run `koha-create --create-db instance` and notice how it fails with: gzip: /path/to/dump.sql: not in gzip format 3) apply the patch 4) notice the extra line of information "The SQL file can be optionally compressed with gzip" in koha-sites.conf 5) run the `koha-create` command again, this time it should work 6) repeat with DEFAULTSQL pointing to a gzip'd dump, it should work too Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Awesome work all! Pushed to master for 18.11
Pushed to 18.05.x for 18.05.05
Pushed to 17.11.x for 17.11.11