Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9340862
D442.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D442.diff
View Options
diff --git a/sql/bin/db-init b/sql/bin/db-init
--- a/sql/bin/db-init
+++ b/sql/bin/db-init
@@ -26,31 +26,20 @@
fi
if [ -z "$1" ] ; then
- echo "Usage: bin/db-init DB_NAME [DB_USER [DB_PORT]]"
+ echo "Usage: bin/db-init DB_NAME [DB_PORT]"
echo "Example: bin/db-init softwareheritage-dev"
- echo "Note: DB_NAME should not exist and will be created; DB_USER can exist."
+ echo "Note: DB_NAME should not exist and will be created"
exit 2
fi
db_name="$1"
-db_user="${2:-$USER}"
+port=${2:-5432}
-conn_flags=""
-if [ -n "$3" ]; then
- conn_flags="--port $3"
-fi
-
-user_exists=$( psql postgres -tAc "SELECT 1 FROM pg_roles
- WHERE rolname='$db_user'" )
-if [ "$user_exists" != "1" ]; then
- echo "I: creating Postgres user ${db_user} ..."
- createuser $conn_flags --pwprompt "$db_user" || true
-fi
+conn_flags="--port $port"
echo "I: creating Postgres database ${db_name} ..."
createdb $conn_flags \
--encoding "$DB_ENCODING" --locale "$DB_LOCALE" \
- --template "$DB_TEMPLATE" \
- --owner "$db_user" "$db_name"
+ --template "$DB_TEMPLATE" "$db_name"
sqls_flags=''
for f in $SQLS ; do
@@ -60,10 +49,4 @@
echo "I: initializing DB ${db_name} ..."
psql $conn_flags ${sqls_flags} "$db_name"
-echo "I: granting privileges to user ${db_user} on DB ${db_name} ..."
-echo "grant all privileges on all tables in schema public to ${db_user}" | \
- psql $conn_flags "$db_name"
-echo "grant all privileges on all sequences in schema public to ${db_user}" | \
- psql $conn_flags "$db_name"
-
echo "I: all done."
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 11:15 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217321
Attached To
D442: sql/bin/db-init: remove createuser and privileges (we now assume a peer superuser)
Event Timeline
Log In to Comment