Skip to content

Commit

Permalink
🐛 Add .gitattributes file to ensure LF endings for .sh files
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaharBand committed Jun 21, 2024
1 parent c1fa2b7 commit 2a17271
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ DB_USER=sentinel
DB_PASSWORD=12345678
DB_PORT=27017
DB_NAME=sentinel

DB_ROOT_USER=root123
DB_ROOT_PASSWORD=12345678
DB_SERVER=localhost
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.sh text eol=lf
7 changes: 7 additions & 0 deletions deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ You can initialize the MongoDB user by either:
sh scripts/mongo-setup.sh
```

If the setup script has incorrect line endings (`CRLF`) and you want to convert them to Unix (`LF`), you can use a tool or command to do so:

```bash
sed -i 's/\r$//' ./scripts/mongo-setup.sh
```
afterwards you can run the shell file again.

- Manually creating a user using the mongosh CLI.

# URLs
Expand Down
4 changes: 2 additions & 2 deletions scripts/mongo-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -z "$DB_USER" ] || [ -z "$DB_PASSWORD" ] || [ -z "$DB_SERVER" ] || [ -z "$D
exit 1
fi

mongosh --host $DB_SERVER --port $DB_PORT -u $DB_USER -p $DB_PASSWORD --authenticationDatabase admin <<EOF
mongosh --host $DB_SERVER --port $DB_PORT --authenticationDatabase admin <<EOF
use $DB_NAME
db.dropUser("$DB_USER")
db.createUser({
Expand All @@ -15,4 +15,4 @@ db.createUser({
{ role: "readWrite", db: "$DB_NAME" }
]
})
EOF
EOF

0 comments on commit 2a17271

Please sign in to comment.