Skip to content

Commit

Permalink
build: copy template config files when build
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Mar 17, 2023
1 parent 532dad4 commit 9dcf102
Showing 1 changed file with 35 additions and 45 deletions.
80 changes: 35 additions & 45 deletions build_raccoon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,67 @@ DCM2JPEG_PYTHONAPI_PORT=5000
`;
async function main() {
if (!fs.existsSync('./temp')) {
mkdirp.sync('./temp' , 0o775);
let oldMask = process.umask(0);
mkdirp.sync('./temp' , "0755");
process.umask(oldMask);
}

let userOS = OS.type().toLowerCase();
if (userOS.includes("windows")) {
await genDCMTK("windows");
osFunc["windows"].checkHaveDCMTK();
} else if (userOS.includes("linux")) {
await genDCMTK("linux");
}

// Generate .env
if (!fs.existsSync(".env")) {
console.log(`create .env in ${path.join(__dirname, "../.env")}`);
fs.writeFileSync(".env" , envText);
}

let frontendConfigPath = path.join(__dirname, "../public/scripts/config.js");
if (!fs.existsSync(frontendConfigPath)) {
console.log(`copy config.template.js to ${frontendConfigPath}`);
fs.copyFileSync(
path.join(__dirname, "../public/scripts/config.template.js"),
frontendConfigPath
);
}

let pluginConfigPath = path.join(__dirname, "../plugins/config.js");
if (!fs.existsSync(pluginConfigPath)) {
console.log(`copy config.template.js to ${pluginConfigPath}`);
fs.copyFileSync(
path.join(__dirname, "../plugins/config.template.js"),
pluginConfigPath
);
}
}
const osFunc = {
linux : {
checkHaveDCMTK : () => {
return new Promise((resolve)=> {
exec("dcm2json" , function (err , stdout , stderr) {
if (err) {
console.error("checkHaveDCMTK is broken");
console.error(err);
process.exit(1);
if (err.message.includes("not found")) {
console.error("Please install DCMTK, more information from: https://dicom.offis.de/en/dcmtk/dcmtk-tools/\r\nif you just need to create config files, please ignore this error");
return resolve(true);
} else {
console.error("checkHaveDCMTK is broken");
console.error(err);
process.exit(1);
}
}
if (!stdout.includes("not found")) {
console.error("Please install DCMTK, more information from: https://dicom.offis.de/en/dcmtk/dcmtk-tools/\r\nif you just need to create config files, please ignore this error");
return resolve(true);
}
return resolve(false);
});
});
} ,
genDCMTK : () => {
console.log("Doloading DCMTK");
exec("sudo apt-get install dcmtk" , function (err , stdout , stderr) {
if (err) {
console.error(err);
process.exit(1);
}
});
}
genDCMTK : () => {}
} ,
windows : {
checkHaveDCMTK : () => {
Expand All @@ -89,38 +111,6 @@ const osFunc = {
process.exit(1);
}
if (files.length > 0 ) {
envText = `
MONGODB_NAME="raccoon"
MONGODB_HOSTS=["mongodb"]
MONGODB_PORTS=[27017]
MONGODB_USER="root"
MONGODB_PASSWORD="Raccoon#Admin2Mongo"
MONGODB_SLAVEMODE=false
SERVER_HOST="0.0.0.0"
SERVER_PORT=8081
DICOM_STORE_ROOTPATH='/dicomFiles'
DICOMWEB_PROTOCOL="http"
DICOMWEB_HOST="localhost"
DICOMWEB_PORT=8081
DICOMWEB_API="dicom-web"
FHIRSERVER_HTTP="http"
FHIRSERVER_APIPATH="api/fhir"
FHIRSERVER_HOST="localhost"
FHIRSERVER_PORT=8081
FHIR_NEED_PARSE_PATIENT=true
USE_CONDA=false
CONDA_PATH="path/conda.exe"
CONDA_GDCM_ENV_NAME="gdcm"
USE_DCM2JPEG_PYTHONAPI=true
DCM2JPEG_PYTHONAPI_HOST="127.0.0.1"
DCM2JPEG_PYTHONAPI_PORT=5000
`;
return resolve(true);
}
return resolve(false);
Expand Down

0 comments on commit 9dcf102

Please sign in to comment.