mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
setup fixes
This commit is contained in:
parent
4d3fd3a0af
commit
a4b5dcff37
5 changed files with 84 additions and 102 deletions
|
@ -1,95 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
hr() {
|
|
||||||
if [ -t 0 ]; then
|
|
||||||
printf '\033[0;32m%*s\033[0m\n' "$(tput cols)" '' | tr ' ' '='
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
log() {
|
|
||||||
hr
|
|
||||||
echo -e "\033[0;32m${@}\033[0m"
|
|
||||||
hr
|
|
||||||
}
|
|
||||||
|
|
||||||
checkFile() {
|
|
||||||
if [ ! -f "$@" ]; then
|
|
||||||
log "$@ does not exists, exiting"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupJson() {
|
|
||||||
if [ ! -f "$1" ]; then
|
|
||||||
echo "Setting up ${1}"
|
|
||||||
echo '{}' >"$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
makeNextSubmodule() {
|
|
||||||
log "Making ${1}"
|
|
||||||
pushd "submodules/${1}/" || exit
|
|
||||||
npm install
|
|
||||||
npm audit fix
|
|
||||||
npm run export
|
|
||||||
popd || exit
|
|
||||||
linkTarget="$PWD/nextStatic/${2}"
|
|
||||||
if [ ! -f "${linkTarget}" ]; then
|
|
||||||
ln -sf "$PWD/submodules/${1}/out" "${linkTarget}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
./setup.sh
|
|
||||||
|
|
||||||
log "Making project"
|
|
||||||
npm install
|
|
||||||
npm audit fix
|
|
||||||
npm run export
|
|
||||||
|
|
||||||
log "Seting up next.js static stuff..."
|
|
||||||
mkdir "$PWD/nextStatic"
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------
|
|
||||||
makeNextSubmodule "qmining-page" "qminingPagePublic"
|
|
||||||
makeNextSubmodule "qmining-data-editor" "dataEditorPublic"
|
|
||||||
# ------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
log "Making moodle test userscript"
|
|
||||||
mkdir -pv "$PWD/publicDirs/qminingPublic/moodle-test-userscript"
|
|
||||||
checkFile "$PWD/submodules/moodle-test-userscript/stable.user.js"
|
|
||||||
ln -sfv "$PWD/submodules/moodle-test-userscript/stable.user.js" "$PWD/publicDirs/qminingPublic/moodle-test-userscript/"
|
|
||||||
ln -sfv "$PWD/submodules/moodle-test-userscript/stable.user.js" "$PWD/publicDirs/qminingPublic/"
|
|
||||||
|
|
||||||
log "mkdir-ing/touching :3"
|
|
||||||
|
|
||||||
# TODO: make server create these itself
|
|
||||||
mkdir -p stats
|
|
||||||
mkdir -p stats/logs
|
|
||||||
mkdir -p stats/vlogs
|
|
||||||
mkdir -p data
|
|
||||||
mkdir -p data/dbs
|
|
||||||
touch data/nolog
|
|
||||||
|
|
||||||
#JSONS
|
|
||||||
setupJson stats/stats
|
|
||||||
setupJson stats/vstats
|
|
||||||
setupJson stats/idstats
|
|
||||||
setupJson stats/idvstats
|
|
||||||
setupJson publicDirs/qminingPublic/userSpecificMotd.json
|
|
||||||
setupJson publicDirs/qminingPublic/news.json
|
|
||||||
|
|
||||||
touch publicDirs/qminingPublic/version
|
|
||||||
touch publicDirs/qminingPublic/motd
|
|
||||||
|
|
||||||
if [ -z "$(ls -A ./data/dbs)" ]; then
|
|
||||||
log "Making DB-s"
|
|
||||||
pushd src/standaloneUtils || exit
|
|
||||||
NS_LOGLEVEL=2 node dbSetup.js
|
|
||||||
mv ./*.db ../../data/dbs
|
|
||||||
popd || exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Disabling next telemetry"
|
|
||||||
npx --yes next telemetry disable
|
|
||||||
|
|
||||||
log "Done!"
|
|
|
@ -1,7 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
hr() {
|
hr() {
|
||||||
|
if [ -t 0 ]; then
|
||||||
printf '\033[0;32m%*s\033[0m\n' "$(tput cols)" '' | tr ' ' '='
|
printf '\033[0;32m%*s\033[0m\n' "$(tput cols)" '' | tr ' ' '='
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
|
@ -17,6 +19,26 @@ checkFile() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupJson() {
|
||||||
|
if [ ! -f "$1" ]; then
|
||||||
|
echo "Setting up ${1}"
|
||||||
|
echo '{}' >"$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
makeNextSubmodule() {
|
||||||
|
log "Making ${1}"
|
||||||
|
pushd "submodules/${1}/" || exit
|
||||||
|
npm install
|
||||||
|
npm audit fix > /dev/null 2> /dev/null
|
||||||
|
npm run export
|
||||||
|
popd || exit
|
||||||
|
linkTarget="$PWD/nextStatic/${2}"
|
||||||
|
if [ ! -f "${linkTarget}" ]; then
|
||||||
|
ln -sf "$PWD/submodules/${1}/out" "${linkTarget}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
log 'Updating / Cloning project'
|
log 'Updating / Cloning project'
|
||||||
|
|
||||||
checkFile "$PWD/src/server.ts"
|
checkFile "$PWD/src/server.ts"
|
||||||
|
@ -26,3 +48,56 @@ checkFile "$PWD/package-lock.json"
|
||||||
git pull
|
git pull
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
|
||||||
|
log "Making project"
|
||||||
|
npm install
|
||||||
|
npm audit fix > /dev/null 2> /dev/null
|
||||||
|
npm run export
|
||||||
|
|
||||||
|
log "Seting up next.js static stuff..."
|
||||||
|
mkdir "$PWD/nextStatic"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
makeNextSubmodule "qmining-page" "qminingPagePublic"
|
||||||
|
makeNextSubmodule "qmining-data-editor" "dataEditorPublic"
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
log "Making moodle test userscript"
|
||||||
|
mkdir -pv "$PWD/publicDirs/qminingPublic/moodle-test-userscript"
|
||||||
|
checkFile "$PWD/submodules/moodle-test-userscript/stable.user.js"
|
||||||
|
ln -sfv "$PWD/submodules/moodle-test-userscript/stable.user.js" "$PWD/publicDirs/qminingPublic/moodle-test-userscript/"
|
||||||
|
ln -sfv "$PWD/submodules/moodle-test-userscript/stable.user.js" "$PWD/publicDirs/qminingPublic/"
|
||||||
|
|
||||||
|
log "mkdir-ing/touching :3"
|
||||||
|
|
||||||
|
# TODO: make server create these itself
|
||||||
|
mkdir -p stats
|
||||||
|
mkdir -p stats/logs
|
||||||
|
mkdir -p stats/vlogs
|
||||||
|
mkdir -p data
|
||||||
|
mkdir -p data/dbs
|
||||||
|
touch data/nolog
|
||||||
|
|
||||||
|
#JSONS
|
||||||
|
setupJson stats/stats
|
||||||
|
setupJson stats/vstats
|
||||||
|
setupJson stats/idstats
|
||||||
|
setupJson stats/idvstats
|
||||||
|
setupJson publicDirs/qminingPublic/userSpecificMotd.json
|
||||||
|
setupJson publicDirs/qminingPublic/news.json
|
||||||
|
|
||||||
|
touch publicDirs/qminingPublic/version
|
||||||
|
touch publicDirs/qminingPublic/motd
|
||||||
|
|
||||||
|
if [ -z "$(ls -A ./data/dbs)" ]; then
|
||||||
|
log "Making DB-s"
|
||||||
|
pushd src/standaloneUtils || exit
|
||||||
|
NS_LOGLEVEL=2 node dbSetup.js
|
||||||
|
mv ./*.db ../../data/dbs
|
||||||
|
popd || exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Disabling next telemetry"
|
||||||
|
npx --yes next telemetry disable
|
||||||
|
|
||||||
|
log "Done!"
|
||||||
|
|
|
@ -51,4 +51,4 @@ const DbStruct = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DbStruct
|
exports = DbStruct
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const DBStruct = {
|
const DbStruct = {
|
||||||
users: {
|
users: {
|
||||||
tableStruct: {
|
tableStruct: {
|
||||||
id: {
|
id: {
|
||||||
|
@ -96,4 +96,5 @@ const DBStruct = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
export default DBStruct
|
|
||||||
|
exports = DbStruct
|
|
@ -4,8 +4,8 @@ const dbtools = require('../../dist/utils/dbtools.js').default // eslint-disable
|
||||||
const { v4: uuidv4 } = require('uuid') // eslint-disable-line
|
const { v4: uuidv4 } = require('uuid') // eslint-disable-line
|
||||||
|
|
||||||
const dbStructPaths = [
|
const dbStructPaths = [
|
||||||
{ structPath: '../modules/api/usersDBStruct.json', name: 'users.db' },
|
{ structPath: '../modules/api/usersDBStruct.js', name: 'users.db' },
|
||||||
{ structPath: '../modules/api/msgsDbStruct.json', name: 'msgs.db' },
|
{ structPath: '../modules/api/msgsDbStruct.js', name: 'msgs.db' },
|
||||||
]
|
]
|
||||||
|
|
||||||
dbStructPaths.forEach((data) => {
|
dbStructPaths.forEach((data) => {
|
||||||
|
@ -14,7 +14,8 @@ dbStructPaths.forEach((data) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
function createDB(path, name) {
|
function createDB(path, name) {
|
||||||
const dbStruct = utils.ReadJSON(path)
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const dbStruct = require(path)
|
||||||
const db = dbtools.GetDB(`./${name}`)
|
const db = dbtools.GetDB(`./${name}`)
|
||||||
db.pragma('synchronous = OFF')
|
db.pragma('synchronous = OFF')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue