mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Optional key load in make
This commit is contained in:
parent
db6a7bd73b
commit
8b60ba764f
2 changed files with 23 additions and 17 deletions
5
make.sh
5
make.sh
|
@ -44,6 +44,11 @@ if [ "$?" -ne "0" ]; then
|
||||||
echo '{"Subjects":[],"version":"TESET","motd":"hai"}' > ./public/data.json
|
echo '{"Subjects":[],"version":"TESET","motd":"hai"}' > ./public/data.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pushd utils
|
||||||
|
rm -v ../data/dbs/users.db
|
||||||
|
NS_SQL_DEBUG_LOG=true NS_LOGLEVEL=2 node dbSetup.js
|
||||||
|
popd
|
||||||
|
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
echo "npm start {loglevel}"
|
echo "npm start {loglevel}"
|
||||||
echo "To start server"
|
echo "To start server"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
const utils = require('../utils/utils.js')
|
const utils = require('../utils/utils.js')
|
||||||
const logger = require('../utils/logger.js')
|
const logger = require('../utils/logger.js')
|
||||||
const dbtools = require('../utils/dbtools.js')
|
const dbtools = require('../utils/dbtools.js')
|
||||||
|
@ -25,23 +24,25 @@ function CreateDB () {
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const uids = utils.ReadFile('../dbUsers/keys').split('\n')
|
if (utils.FileExists('../dbUsers/keys')) {
|
||||||
|
const uids = utils.ReadFile('../dbUsers/keys').split('\n')
|
||||||
|
|
||||||
uids.forEach((cid, i) => {
|
uids.forEach((cid, i) => {
|
||||||
if (!cid) { return }
|
if (!cid) { return }
|
||||||
logger.Log(`[ ${i} / ${uids.length} ]`)
|
logger.Log(`[ ${i} / ${uids.length} ]`)
|
||||||
try {
|
try {
|
||||||
dbtools.Insert(authDB, 'users', {
|
dbtools.Insert(authDB, 'users', {
|
||||||
pw: uuidv4(),
|
pw: uuidv4(),
|
||||||
oldCID: cid,
|
oldCID: cid,
|
||||||
avaiblePWRequests: 4,
|
avaiblePWRequests: 4,
|
||||||
created: utils.GetDateString()
|
created: utils.GetDateString()
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.Log('Error during inserting', logger.GetColor('redbg'))
|
logger.Log('Error during inserting', logger.GetColor('redbg'))
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue