Prosody AppImage: extract in a dedicated folder
This commit is contained in:
parent
27e8fbf05f
commit
8f5b2ae565
@ -33,6 +33,10 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
|||||||
let execCtl
|
let execCtl
|
||||||
let execCtlArgs: string[]
|
let execCtlArgs: string[]
|
||||||
let appImageToExtract
|
let appImageToExtract
|
||||||
|
|
||||||
|
// this one is always needed (must create the directory on startup)
|
||||||
|
const appImageExtractPath = path.resolve(dir, '..', 'prosodyAppImage')
|
||||||
|
|
||||||
if (settings['use-system-prosody']) {
|
if (settings['use-system-prosody']) {
|
||||||
exec = 'prosody'
|
exec = 'prosody'
|
||||||
execArgs = []
|
execArgs = []
|
||||||
@ -40,11 +44,12 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
|||||||
execCtlArgs = []
|
execCtlArgs = []
|
||||||
} else {
|
} else {
|
||||||
appImageToExtract = path.resolve(__dirname, '../../prosody/livechat-prosody-x86_64.AppImage')
|
appImageToExtract = path.resolve(__dirname, '../../prosody/livechat-prosody-x86_64.AppImage')
|
||||||
exec = path.resolve(dir, 'squashfs-root/AppRun') // the AppImage will be extracted in the working dir
|
exec = path.resolve(appImageExtractPath, 'squashfs-root/AppRun')
|
||||||
execArgs = ['prosody']
|
execArgs = ['prosody']
|
||||||
execCtl = exec
|
execCtl = exec
|
||||||
execCtlArgs = ['prosodyctl']
|
execCtlArgs = ['prosodyctl']
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dir: dir,
|
dir: dir,
|
||||||
pid: path.resolve(dir, 'prosody.pid'),
|
pid: path.resolve(dir, 'prosody.pid'),
|
||||||
@ -58,7 +63,8 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
|||||||
execArgs,
|
execArgs,
|
||||||
execCtl,
|
execCtl,
|
||||||
execCtlArgs,
|
execCtlArgs,
|
||||||
appImageToExtract
|
appImageToExtract,
|
||||||
|
appImageExtractPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ interface ProsodyFilePaths {
|
|||||||
execCtl: string
|
execCtl: string
|
||||||
execCtlArgs: string[]
|
execCtlArgs: string[]
|
||||||
appImageToExtract?: string
|
appImageToExtract?: string
|
||||||
|
appImageExtractPath: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -8,10 +8,11 @@ import * as child_process from 'child_process'
|
|||||||
async function _ensureWorkingDir (
|
async function _ensureWorkingDir (
|
||||||
options: RegisterServerOptions,
|
options: RegisterServerOptions,
|
||||||
workingDir: string,
|
workingDir: string,
|
||||||
dataDir: string
|
dataDir: string,
|
||||||
|
appImageExtractPath: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const logger = options.peertubeHelpers.logger
|
const logger = options.peertubeHelpers.logger
|
||||||
logger.debug('Calling ensureworkingDir')
|
logger.debug('Calling _ensureworkingDir')
|
||||||
|
|
||||||
if (!fs.existsSync(workingDir)) {
|
if (!fs.existsSync(workingDir)) {
|
||||||
logger.info(`The working dir ${workingDir} does not exists, trying to create it`)
|
logger.info(`The working dir ${workingDir} does not exists, trying to create it`)
|
||||||
@ -25,7 +26,13 @@ async function _ensureWorkingDir (
|
|||||||
if (!fs.existsSync(dataDir)) {
|
if (!fs.existsSync(dataDir)) {
|
||||||
logger.info(`The data dir ${dataDir} does not exists, trying to create it`)
|
logger.info(`The data dir ${dataDir} does not exists, trying to create it`)
|
||||||
await fs.promises.mkdir(dataDir)
|
await fs.promises.mkdir(dataDir)
|
||||||
logger.debug(`Working dir ${dataDir} was created`)
|
logger.debug(`data dir ${dataDir} was created`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs.existsSync(appImageExtractPath)) {
|
||||||
|
logger.info(`The appImageExtractPath dir ${appImageExtractPath} does not exists, trying to create it`)
|
||||||
|
await fs.promises.mkdir(appImageExtractPath)
|
||||||
|
logger.debug(`appImageExtractPath dir ${appImageExtractPath} was created`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return workingDir
|
return workingDir
|
||||||
@ -42,7 +49,7 @@ async function prepareProsody (options: RegisterServerOptions): Promise<void> {
|
|||||||
const filePaths = await getProsodyFilePaths(options)
|
const filePaths = await getProsodyFilePaths(options)
|
||||||
|
|
||||||
logger.debug('Ensuring that the working dir exists')
|
logger.debug('Ensuring that the working dir exists')
|
||||||
await _ensureWorkingDir(options, filePaths.dir, filePaths.data)
|
await _ensureWorkingDir(options, filePaths.dir, filePaths.data, filePaths.appImageExtractPath)
|
||||||
|
|
||||||
const appImageToExtract = filePaths.appImageToExtract
|
const appImageToExtract = filePaths.appImageToExtract
|
||||||
if (!appImageToExtract) {
|
if (!appImageToExtract) {
|
||||||
@ -51,7 +58,7 @@ async function prepareProsody (options: RegisterServerOptions): Promise<void> {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const spawned = child_process.spawn(appImageToExtract, ['--appimage-extract'], {
|
const spawned = child_process.spawn(appImageToExtract, ['--appimage-extract'], {
|
||||||
cwd: filePaths.dir,
|
cwd: filePaths.appImageExtractPath,
|
||||||
env: {
|
env: {
|
||||||
...process.env
|
...process.env
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user