From 3fe69ca15d364e7bf09f1a80ef855ad75fb99dbc Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 16 Jun 2021 14:16:44 +0800 Subject: [PATCH] install: add database reset tool --- install/reset.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 install/reset.sh diff --git a/install/reset.sh b/install/reset.sh new file mode 100644 index 00000000..d19c3faa --- /dev/null +++ b/install/reset.sh @@ -0,0 +1,21 @@ +pm2 stop mongodb +rm -rf /data/db /data/file +mkdir /data/db /data/file +pm2 start mongod +sleep 3 +db_password=$(cat /dev/urandom | head -n 10 | md5sum | head -c 20) +echo "db.createUser({ + user: 'hydro', + pwd: '$db_password', + roles: [ + { role: 'readWrite', db: 'hydro' } + ] +})" >/tmp/createUser.js +mongo 127.0.0.1:27017/hydro /tmp/createUser.js +echo "{\"host\":\"127.0.0.1\",\"port\":\"27017\",\"name\":\"hydro\",\"username\":\"hydro\",\"password\":\"$db_password\"}" >~/.hydro/config.json +pm2 stop mongod +pm2 del mongod +pm2 restart minio +pm2 start mongodb +pm2 restart hydrooj +pm2 save