File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ SCANCODEIO_DB_PASSWORD=scancodeio
37
37
POSTGRES_INITDB_ARGS=--encoding =UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8
38
38
DATE =$(shell date +"% Y-% m-% d_% H% M")
39
39
40
+ # Use sudo for postgres, only on Linux
41
+ UNAME := $(shell uname)
42
+ ifeq ($(UNAME ) , Linux)
43
+ SUDO_POSTGRES=sudo -u postgres
44
+ else
45
+ SUDO_POSTGRES=
46
+ endif
47
+
40
48
virtualenv :
41
49
@echo " -> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE} "
42
50
@${PYTHON_EXE} ${VIRTUALENV_PYZ} --never-download --no-periodic-update .
@@ -99,12 +107,12 @@ migrate:
99
107
postgresdb :
100
108
@echo " -> Configure PostgreSQL database"
101
109
@echo " -> Create database user ${SCANCODEIO_DB_NAME} "
102
- @createuser --no-createrole --no-superuser --login --inherit --createdb ' ${SCANCODEIO_DB_USER}' || true
103
- @psql -c " alter user ${SCANCODEIO_DB_USER} with encrypted password '${SCANCODEIO_DB_PASSWORD} ';" || true
110
+ @${SUDO_POSTGRES} createuser --no-createrole --no-superuser --login --inherit --createdb ' ${SCANCODEIO_DB_USER}' || true
111
+ @${SUDO_POSTGRES} psql -c " alter user ${SCANCODEIO_DB_USER} with encrypted password '${SCANCODEIO_DB_PASSWORD} ';" || true
104
112
@echo " -> Drop ${SCANCODEIO_DB_NAME} database"
105
- @dropdb ${SCANCODEIO_DB_NAME} || true
113
+ @${SUDO_POSTGRES} dropdb ${SCANCODEIO_DB_NAME} || true
106
114
@echo " -> Create ${SCANCODEIO_DB_NAME} database"
107
- @createdb --owner=${SCANCODEIO_DB_USER} ${POSTGRES_INITDB_ARGS} ${SCANCODEIO_DB_NAME}
115
+ @${SUDO_POSTGRES} createdb --owner=${SCANCODEIO_DB_USER} ${POSTGRES_INITDB_ARGS} ${SCANCODEIO_DB_NAME}
108
116
@$(MAKE ) migrate
109
117
110
118
backupdb :
You can’t perform that action at this time.
0 commit comments