mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
[web] CE script to verify TexLive versions on startup (#19653)
* [web] CE script to verify TexLive versions on startup --------- Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> GitOrigin-RevId: b99001d38468a775991a7284611aa333e956b919
This commit is contained in:
committed by
Copybot
co-authored by
Jakob Ackermann
parent
b4ad1ed35d
commit
0346ba2698
@@ -3,6 +3,44 @@ const { batchedUpdateWithResultHandling } = require('./helpers/batchedUpdate')
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const commit = argv.commit !== undefined
|
||||
let imageName = argv._[0]
|
||||
|
||||
function usage() {
|
||||
console.log(
|
||||
'Usage: node backfill_project_image_name.js --commit <texlive_docker_image>'
|
||||
)
|
||||
console.log(
|
||||
'Argument <texlive_docker_image> is not required when TEX_LIVE_DOCKER_IMAGE is set.'
|
||||
)
|
||||
console.log(
|
||||
'Environment variable ALL_TEX_LIVE_DOCKER_IMAGES must contain <texlive_docker_image>.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!imageName && process.env.TEX_LIVE_DOCKER_IMAGE) {
|
||||
imageName = process.env.TEX_LIVE_DOCKER_IMAGE
|
||||
}
|
||||
|
||||
if (!imageName) {
|
||||
usage()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!process.env.ALL_TEX_LIVE_DOCKER_IMAGES) {
|
||||
console.error(
|
||||
'Error: environment variable ALL_TEX_LIVE_DOCKER_IMAGES is not defined.'
|
||||
)
|
||||
usage()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!process.env.ALL_TEX_LIVE_DOCKER_IMAGES.split(',').includes(imageName)) {
|
||||
console.error(
|
||||
`Error: ALL_TEX_LIVE_DOCKER_IMAGES doesn't contain ${imageName}`
|
||||
)
|
||||
usage()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!commit) {
|
||||
console.error('DOING DRY RUN. TO SAVE CHANGES PASS --commit')
|
||||
@@ -12,5 +50,5 @@ if (!commit) {
|
||||
batchedUpdateWithResultHandling(
|
||||
'projects',
|
||||
{ imageName: null },
|
||||
{ $set: { imageName: 'quay.io/sharelatex/texlive-full:2014.2' } }
|
||||
{ $set: { imageName } }
|
||||
)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
const { batchedUpdate } = require('./helpers/batchedUpdate')
|
||||
|
||||
const oldImage = process.argv[2]
|
||||
const newImage = process.argv[3]
|
||||
|
||||
function usage() {
|
||||
console.log(
|
||||
`Usage: update_project_image_name.js <old_texlive_image> <new_texlive_image>`
|
||||
)
|
||||
console.log(
|
||||
'Environment variable ALL_TEX_LIVE_DOCKER_IMAGES must contain <new_texlive_image>.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!oldImage || !newImage) {
|
||||
usage()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!process.env.ALL_TEX_LIVE_DOCKER_IMAGES) {
|
||||
console.error(
|
||||
'Error: environment variable ALL_TEX_LIVE_DOCKER_IMAGES is not defined.'
|
||||
)
|
||||
usage()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!process.env.ALL_TEX_LIVE_DOCKER_IMAGES.split(',').includes(newImage)) {
|
||||
console.error(`Error: ALL_TEX_LIVE_DOCKER_IMAGES doesn't contain ${newImage}`)
|
||||
usage()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
batchedUpdate(
|
||||
'projects',
|
||||
{ imageName: oldImage },
|
||||
{ $set: { imageName: newImage } }
|
||||
)
|
||||
.then(() => {
|
||||
console.log('Done')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user