Skip to content

postgis.sh: 9 Bad substitution #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
loic-lopez opened this issue Dec 11, 2018 · 7 comments
Closed

postgis.sh: 9 Bad substitution #119

loic-lopez opened this issue Dec 11, 2018 · 7 comments

Comments

@loic-lopez
Copy link

Hello, when the database system start for the first time it displays:

waiting for server to start....2018-12-11 14:59:23.401 UTC [42] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-12-11 14:59:23.528 UTC [43] LOG:  database system was shut down at 2018-12-11 14:59:23 UTC
2018-12-11 14:59:23.575 UTC [42] LOG:  database system is ready to accept connections
 done
server started
/docker-entrypoint-initdb.d/postgis.sh: 9: /docker-entrypoint-initdb.d/postgis.sh: Bad substitution
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgis.sh

So when i tried to create a table with a position datatype:

 SQLSTATE[42704]: Undefined object: 7 ERROR:  type "geography" does not exist at character 91 (SQL: create table "check_points" ("id" uuid not null, "type" varchar(255) not null, "location" GEOGRAPHY(POLYGON, 4326) not null, "run_id" uuid not null, "created_at" timestamp(0) without time zone null, "updated_at" timestamp(0) without time zone null))
@bukowa
Copy link

bukowa commented Dec 12, 2018

    build:
      ./docker-postgis-master/11-2.5
postgis_1  |  done
postgis_1  | server started
postgis_1  | CREATE DATABASE
postgis_1  |
postgis_1  |
postgis_1  | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgis.sh
postgis_1  | /docker-entrypoint-initdb.d/postgis.sh: 9: /docker-entrypoint-initdb.d/postgis.sh: Bad substitution

Same error on my side while building from repo.

    image: mdillon/postgis:11

No errors, runs fine when using image.

@loic-lopez what OS do you run and how you build image?

@loukash
Copy link

loukash commented Dec 14, 2018

Fix:

chmod -x initdb-postgis.sh
chmod -x update-postgis.sh

https://github.com/docker-library/postgres/blob/master/9.6/docker-entrypoint.sh#L132-L144

@md5
Copy link
Contributor

md5 commented Feb 15, 2019

It looks like the repository got checked out somewhere that didn't preserve Unix permissions, so the executable bit was lost. It's there in the Git repository.

@md5 md5 closed this as completed Feb 15, 2019
@md5
Copy link
Contributor

md5 commented Feb 15, 2019

Sorry, I got it backwards.

The initdb-postgis.sh script is intentionally not set with the execute bit so that it will be sourced by the postgres entrypoint instead of executed. This is what makes the ${psql[@]} variable substitution available for use.

I think you may be running into this if you're on Windows and bind mounting in the source code for this image: docker-library/postgres#452 (comment)

@realmhamdy
Copy link

I'm getting this same error too. I'm building on Windows. IDK what to do. Is there a fix that's not Windows-specific somehow?

@bukowa
Copy link

bukowa commented Oct 22, 2019

Take a look at line ending (different for Unix different for Windows). I had some problems with that.

@TOTOleHero
Copy link

TOTOleHero commented Jan 21, 2020

Hello,

Change the shell and ths srcipt work :

Change #!/bin/sh by #!/bin/bash in file initdb-postgis.sh

But after, i have another error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants