Skip to content

Commit e3a087f

Browse files
committed
Add option to change server data directory
1 parent 8191939 commit e3a087f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@
104104
"description": "**Experimental:** The name of the server binary, use this **only if** you are using a client without a corresponding server release",
105105
"scope": "application",
106106
"default": ""
107+
},
108+
"remote.SSH.serverDataFolder": {
109+
"type": "string",
110+
"description": "The base path to install the server to instead of `~/.vscodium-server`.",
111+
"scope": "application",
112+
"default": ""
107113
}
108114
}
109115
},

src/serverConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ export async function getVSCodeServerConfig(): Promise<IServerConfig> {
2626
const productJson = await getVSCodeProductJson();
2727

2828
const customServerBinaryName = vscode.workspace.getConfiguration('remote.SSH.experimental').get<string>('serverBinaryName', '');
29+
const customServerDataFolder = vscode.workspace.getConfiguration('remote.SSH').get<string>('serverDataFolder', '');
2930

3031
return {
3132
version: vscode.version.replace('-insider',''),
3233
commit: productJson.commit,
3334
quality: productJson.quality,
3435
release: productJson.release,
3536
serverApplicationName: customServerBinaryName || productJson.serverApplicationName,
36-
serverDataFolderName: productJson.serverDataFolderName,
37+
serverDataFolderName: customServerDataFolder || productJson.serverDataFolderName,
3738
serverDownloadUrlTemplate: productJson.serverDownloadUrlTemplate
3839
};
3940
}

src/serverSetup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as crypto from 'crypto';
2+
import { isAbsolute } from 'path';
23
import Log from './common/logger';
34
import { getVSCodeServerConfig } from './serverConfig';
45
import SSHConnection from './ssh/sshConnection';
@@ -213,7 +214,7 @@ DISTRO_VSCODIUM_RELEASE="${release ?? ''}"
213214
SERVER_APP_NAME="${serverApplicationName}"
214215
SERVER_INITIAL_EXTENSIONS="${extensions}"
215216
SERVER_LISTEN_FLAG="${useSocketPath ? `--socket-path="$TMP_DIR/vscode-server-sock-${crypto.randomUUID()}"` : '--port=0'}"
216-
SERVER_DATA_DIR="$HOME/${serverDataFolderName}"
217+
SERVER_DATA_DIR="${(isAbsolute(serverDataFolderName) ? '' : '$HOME/') + serverDataFolderName}"
217218
SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"
218219
SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"
219220
SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"
@@ -368,7 +369,7 @@ if [[ -z $SERVER_RUNNING_PROCESS ]]; then
368369
SERVER_CONNECTION_TOKEN="${crypto.randomUUID()}"
369370
echo $SERVER_CONNECTION_TOKEN > $SERVER_TOKENFILE
370371
371-
$SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &
372+
$SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms --server-data-dir $SERVER_DATA_DIR &> $SERVER_LOGFILE &
372373
echo $! > $SERVER_PIDFILE
373374
else
374375
echo "Server script is already running $SERVER_SCRIPT"
@@ -427,7 +428,7 @@ $DISTRO_VSCODIUM_RELEASE="${release ?? ''}"
427428
$SERVER_APP_NAME="${serverApplicationName}"
428429
$SERVER_INITIAL_EXTENSIONS="${extensions}"
429430
$SERVER_LISTEN_FLAG="${useSocketPath ? `--socket-path="$TMP_DIR/vscode-server-sock-${crypto.randomUUID()}"` : '--port=0'}"
430-
$SERVER_DATA_DIR="$(Resolve-Path ~)\\${serverDataFolderName}"
431+
$SERVER_DATA_DIR="${(isAbsolute(serverDataFolderName) ? '' : '$(Resolve-Path ~)\\') + serverDataFolderName}"
431432
$SERVER_DIR="$SERVER_DATA_DIR\\bin\\$DISTRO_COMMIT"
432433
$SERVER_SCRIPT="$SERVER_DIR\\bin\\$SERVER_APP_NAME.cmd"
433434
$SERVER_LOGFILE="$SERVER_DATA_DIR\\.$DISTRO_COMMIT.log"
@@ -533,7 +534,7 @@ else {
533534
$SERVER_CONNECTION_TOKEN="${crypto.randomUUID()}"
534535
[System.IO.File]::WriteAllLines($SERVER_TOKENFILE, $SERVER_CONNECTION_TOKEN)
535536
536-
$SCRIPT_ARGUMENTS="--start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms *> '$SERVER_LOGFILE'"
537+
$SCRIPT_ARGUMENTS="--start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms --server-data-dir $SERVER_DATA_DIR *> '$SERVER_LOGFILE'"
537538
538539
$START_ARGUMENTS = @{
539540
FilePath = "powershell.exe"

0 commit comments

Comments
 (0)