Skip to content

Instantly share code, notes, and snippets.

@koush
Created February 13, 2023 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koush/675cb9f652d334205cf2ff6679d5df46 to your computer and use it in GitHub Desktop.
Save koush/675cb9f652d334205cf2ff6679d5df46 to your computer and use it in GitHub Desktop.
koush@Koushik-MacStudio docker % git diff b61b14f9d3c05b1fe9e464e824bdb7006a1544cc install-scrypted-dependencies-win.ps1
diff --git a/docker/install-scrypted-dependencies-win.ps1 b/docker/install-scrypted-dependencies-win.ps1
index 9360fffe..f22200cd 100644
--- a/docker/install-scrypted-dependencies-win.ps1
+++ b/docker/install-scrypted-dependencies-win.ps1
@@ -1,18 +1,26 @@
+# Set-PSDebug -Trace 1
+
+# stop existing service if any
+sc.exe stop scrypted.exe
+
# Install Chocolatey
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install node.js
-choco upgrade -y nodejs-lts --version=18.13.0
+choco upgrade -y nodejs-lts --version=18.14.0
# Install Python
-choco upgrade -y python
+choco upgrade -y python39
+# Run py.exe with a specific version
+$SCRYPTED_WINDOWS_PYTHON_VERSION="-3.9"
# Refresh environment variables for py and npx to work
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
-py -m pip install --upgrade pip
-py -m pip install aiofiles debugpy typing_extensions typing opencv-python
+
+py $SCRYPTED_WINDOWS_PYTHON_VERSION -m pip install --upgrade pip
+py $SCRYPTED_WINDOWS_PYTHON_VERSION -m pip install aiofiles debugpy typing_extensions typing opencv-python
npx -y scrypted@latest install-server
@@ -21,6 +29,9 @@ $SCRYPTED_HOME = $env:USERPROFILE + '\.scrypted'
$SCRYPTED_HOME_ESCAPED_PATH = $SCRYPTED_HOME.replace('\', '\\')
npm install --prefix $SCRYPTED_HOME node-windows@1.0.0-beta.8 --save
+$NPX_PATH = (Get-Command npx).Path
+$NPX_PATH_ESCAPED = $NPX_PATH.replace('\', '\\')
+
$SERVICE_JS = @"
const fs = require('fs');
try {
@@ -29,7 +40,7 @@ try {
catch (e) {
}
const child_process = require('child_process');
-child_process.spawn('npx.cmd', ['-y', 'scrypted', 'serve'], {
+child_process.spawn('$($NPX_PATH_ESCAPED)', ['-y', 'scrypted', 'serve'], {
stdio: 'inherit',
});
"@
@@ -49,6 +60,10 @@ const svc = new Service({
name: "USERPROFILE",
value: '$($USER_HOME_ESCAPED)'
},
+ {
+ name: "SCRYPTED_WINDOWS_PYTHON_VERSION",
+ value: '$($SCRYPTED_WINDOWS_PYTHON_VERSION)'
+ }
]
});
svc.on('alreadyinstalled', () => {
@@ -79,6 +94,7 @@ $INSTALL_SERVICE_JS_PATH = $SCRYPTED_HOME + '\install-service.js'
$INSTALL_SERVICE_JS | Out-File -Encoding ASCII -FilePath $INSTALL_SERVICE_JS_PATH
node $INSTALL_SERVICE_JS_PATH
+del $INSTALL_SERVICE_JS_PATH
Write-Output "Scrypted is now running at: https://localhost:10443/"
Write-Output "Note that it is https and that you'll be asked to approve/ignore the website certificate."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment