From 29ea671a2368a0a0a4775f41856c0dc95ff5b5d9 Mon Sep 17 00:00:00 2001 From: Witherking25 Date: Mon, 20 Feb 2023 15:06:36 -0500 Subject: [PATCH] feat: add sshpass support --- src/deck.ts | 3 +++ src/index.ts | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/deck.ts b/src/deck.ts index 06fe568..2bcf197 100644 --- a/src/deck.ts +++ b/src/deck.ts @@ -14,6 +14,9 @@ export class Deck extends JSONObject @optional('-i ${env:HOME}/.ssh/id_rsa') deckkey!: string + @optional('ssap') + decksshpass!: string + @optional('/home/deck') deckdir!: string } diff --git a/src/index.ts b/src/index.ts index 9414122..ae252e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -396,12 +396,12 @@ function deploy(args: yargs.ArgumentsCamelCase<{ reload: boolean, dev: boolean } } else throw new Error(`${path.join(process.cwd(), 'deck.json')} or ${path.join(process.cwd(), '.vscode', 'settings.json')} does not exist`); build(args) const deploy = path.join(process.cwd(), 'build', `${plugin.name}-${package_.version}${args.dev ? '-dev':''}`); - child_process.execSync(`ssh deck@${deck.deckip} -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')} 'mkdir -p ${deck.deckdir}/homebrew/pluginloader && mkdir -p ${deck.deckdir}/homebrew/plugins'`) - child_process.execSync(`ssh deck@${deck.deckip} -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')} 'echo "${deck.deckpass}" | sudo -S chmod -R ug+rw ${deck.deckdir}/homebrew/'`) - child_process.execSync(`rsync -azp --delete --chmod=D0755,F0755 --rsh='ssh -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')}' "${path.join(deploy, plugin.name)}" deck@${deck.deckip}:${deck.deckdir}/homebrew/plugins`) + child_process.execSync(`sshpass -p ${deck.decksshpass} ssh deck@${deck.deckip} -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')} 'mkdir -p ${deck.deckdir}/homebrew/pluginloader && mkdir -p ${deck.deckdir}/homebrew/plugins'`) + child_process.execSync(`sshpass -p ${deck.decksshpass} ssh deck@${deck.deckip} -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')} 'echo "${deck.deckpass}" | sudo -S chmod -R ug+rw ${deck.deckdir}/homebrew/'`) + child_process.execSync(`rsync -azp --delete --chmod=D0755,F0755 --rsh='sshpass -p ${deck.decksshpass} ssh -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')}' "${path.join(deploy, plugin.name)}" deck@${deck.deckip}:${deck.deckdir}/homebrew/plugins`) if (args.reload) { - child_process.execSync(`ssh deck@${deck.deckip} -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')} 'echo "${deck.deckpass}" | sudo -S systemctl restart plugin_loader.service'`) + child_process.execSync(`sshpass -p ${deck.decksshpass} ssh deck@${deck.deckip} -p ${deck.deckport} ${deck.deckkey.replace('$HOME', process.env.HOME ? process.env.HOME:'')} 'echo "${deck.deckpass}" | sudo -S systemctl restart plugin_loader.service'`) } }