Skip to content

Commit

Permalink
Implemented authentication (#1)
Browse files Browse the repository at this point in the history
* feat: implemented authentication

* fix: wrong line commented out

* docs: script ussage
  • Loading branch information
zark0-UwU authored Feb 1, 2022
1 parent 371d569 commit 5afd0f9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions script.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
#!/bin/bash
###########################################################
# Ussage ( * = optional ): #
# ./script <db-address> <db-port> *<username> *<password> #
###########################################################

if [ ! -z "$3" ]; then
if [ ! -z "$4" ]; then
echo "Using password authentication!"
auth="--authenticationDatabase admin -u $3 -p $4"
fi
fi

#echo $auth

for coll in *; do
if [ -d "${coll}" ] ; then
echo "$coll"
for file in $coll/*; do
mongoimport --drop --host $1 --port $2 --db "$coll" --collection "$(basename $file .json)" --file $file
mongoimport --drop --host $1 --port $2 --db "$coll" --collection "$(basename $file .json)" --file $file $auth
#echo "$(basename $file .json)"
#echo "$file"
done
fi
done

0 comments on commit 5afd0f9

Please sign in to comment.