Skip to content

Commit c10047a

Browse files
committed
remote ssh: add custom serverInstallPath setting
1 parent 847867c commit c10047a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

extensions/open-remote-ssh/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
"description": "**Experimental:** The name of the server binary, use this **only if** you are using a client without a corresponding server release",
104104
"scope": "application",
105105
"default": ""
106+
},
107+
"remoteSSH.serverInstallPath": {
108+
"type": "string",
109+
"markdownDescription": "A custom directory to install the Positron server data on the remote machine. By default, the server data is installed in `~/.positron-server`.",
110+
"scope": "application",
111+
"default": ""
106112
}
107113
}
108114
},

extensions/open-remote-ssh/src/serverConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export async function getVSCodeServerConfig(): Promise<IServerConfig> {
3535
const productJson = await getVSCodeProductJson();
3636

3737
const customServerBinaryName = vscode.workspace.getConfiguration('remoteSSH.experimental').get<string>('serverBinaryName', '');
38+
const customDataFolderName = vscode.workspace.getConfiguration('remoteSSH').get<string>('serverInstallPath', '');
3839

3940
const version = `${positron.version}-${positron.buildNumber}`;
4041

@@ -44,7 +45,7 @@ export async function getVSCodeServerConfig(): Promise<IServerConfig> {
4445
quality: productJson.quality,
4546
release: productJson.release,
4647
serverApplicationName: customServerBinaryName || productJson.serverApplicationName,
47-
serverDataFolderName: productJson.serverDataFolderName,
48+
serverDataFolderName: customDataFolderName || productJson.serverDataFolderName,
4849
serverDownloadUrlTemplate: productJson.serverDownloadUrlTemplate
4950
};
5051
}

extensions/open-remote-ssh/src/serverSetup.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ export async function installCodeServer(conn: SSHConnection, serverDownloadUrlTe
9494

9595
let commandOutput: { stdout: string; stderr: string };
9696
if (platform === 'windows') {
97+
// If the default was not changed, adjust the path for PowerShell on Windows
98+
if (installOptions.serverDataFolderName === '$HOME/.positron-server') {
99+
installOptions.serverDataFolderName = '$HOME\\.positron-server';
100+
}
97101
const installServerScript = generatePowerShellInstallScript(installOptions);
98102

99103
logger.trace('Server install command:', installServerScript);
100104

101-
const installDir = `$HOME\\${vscodeServerConfig.serverDataFolderName}\\install`;
105+
const installDir = `${vscodeServerConfig.serverDataFolderName}\\install`;
102106
const installScript = `${installDir}\\${vscodeServerConfig.commit}.ps1`;
103107
const endRegex = new RegExp(`${scriptId}: end`);
104108
// investigate if it's possible to use `-EncodedCommand` flag
@@ -226,7 +230,7 @@ DISTRO_VSCODIUM_RELEASE="${release ?? ''}"
226230
SERVER_APP_NAME="${serverApplicationName}"
227231
SERVER_INITIAL_EXTENSIONS="${extensions}"
228232
SERVER_LISTEN_FLAG="${useSocketPath ? `--socket-path="$TMP_DIR/vscode-server-sock-${crypto.randomUUID()}"` : '--port=0'}"
229-
SERVER_DATA_DIR="$HOME/${serverDataFolderName}"
233+
SERVER_DATA_DIR="${serverDataFolderName}"
230234
SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"
231235
SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"
232236
SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"
@@ -467,7 +471,7 @@ $DISTRO_VSCODIUM_RELEASE="${release ?? ''}"
467471
$SERVER_APP_NAME="${serverApplicationName}"
468472
$SERVER_INITIAL_EXTENSIONS="${extensions}"
469473
$SERVER_LISTEN_FLAG="${useSocketPath ? `--socket-path="$TMP_DIR/vscode-server-sock-${crypto.randomUUID()}"` : '--port=0'}"
470-
$SERVER_DATA_DIR="$(Resolve-Path ~)\\${serverDataFolderName}"
474+
$SERVER_DATA_DIR="${serverDataFolderName}"
471475
$SERVER_DIR="$SERVER_DATA_DIR\\bin\\$DISTRO_COMMIT"
472476
$SERVER_SCRIPT="$SERVER_DIR\\bin\\$SERVER_APP_NAME.cmd"
473477
$SERVER_LOGFILE="$SERVER_DATA_DIR\\.$DISTRO_COMMIT.log"

product.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"serverLicense": [],
1515
"serverLicensePrompt": "",
1616
"serverApplicationName": "positron-server",
17-
"serverDataFolderName": ".positron-server",
17+
"serverDataFolderName": "$HOME/.positron-server",
1818
"serverDownloadUrlTemplate": "https://cdn.posit.co/positron/dailies/reh/${arch-long}/positron-reh-${os}-${arch}-${version}.tar.gz",
1919
"tunnelApplicationName": "positron-tunnel",
2020
"win32DirName": "Positron",

0 commit comments

Comments
 (0)