Compare commits

...

17 Commits

Author SHA1 Message Date
Koushik Dutta
f5a32489d7 server: prevent windows from clobbering python path 2024-01-24 23:46:58 -08:00
Koushik Dutta
135ad8e3a8 rebroadcast: add id suffix to rtsp urls to determine ffmpeg usage 2024-01-24 13:52:35 -08:00
Koushik Dutta
3c4021c66b videoanalysis: disable filters for objects that are in detector provided zones 2024-01-23 21:42:36 -08:00
Koushik Dutta
669ab17772 docker: remove nvr storage config prompt 2024-01-23 15:47:48 -08:00
Koushik Dutta
1860d7d8ea Merge branch 'main' of github.com:koush/scrypted 2024-01-23 15:46:53 -08:00
Koushik Dutta
fa266e9dd1 docker: validate the storage directory 2024-01-23 20:10:02 +00:00
Koushik Dutta
4e2f3bf2c7 docker: finish drive setup script 2024-01-23 19:40:16 +00:00
Koushik Dutta
146e27fd13 install: initial pass at disk setup 2024-01-23 19:00:51 +00:00
Koushik Dutta
e4bb50375f postbeta 2024-01-22 20:15:16 -08:00
Koushik Dutta
9686315c02 postbeta 2024-01-22 19:57:24 -08:00
Koushik Dutta
520895f3aa postbeta 2024-01-22 19:50:20 -08:00
Koushik Dutta
ddffc49bcf postbeta 2024-01-22 19:22:20 -08:00
Koushik Dutta
a07f52445d postbeta 2024-01-22 19:13:41 -08:00
Koushik Dutta
5e7b203f11 postbeta 2024-01-22 19:01:13 -08:00
Koushik Dutta
d752298960 postbeta 2024-01-22 17:45:46 -08:00
Koushik Dutta
5253f29831 remove usage of NODE_* env variables which get sanitized by electron. 2024-01-22 17:45:26 -08:00
Koushik Dutta
58d674746d postrelease 2024-01-22 17:22:09 -08:00
15 changed files with 182 additions and 39 deletions

View File

@@ -54,15 +54,6 @@ fi
echo "Setting permissions on $SCRYPTED_HOME"
chown -R $SERVICE_USER $SCRYPTED_HOME
echo "Optional:"
readyn "Edit docker-compose.yml to add external storage for Scrypted NVR?"
if [ "$yn" == "y" ]
then
apt install nano
nano $DOCKER_COMPOSE_YML
fi
set +e
echo "docker compose down"
@@ -85,3 +76,6 @@ echo "Scrypted is now running at: https://localhost:10443/"
echo "Note that it is https and that you'll be asked to approve/ignore the website certificate."
echo
echo
echo "Optional:"
echo "Scrypted NVR Recording storage directory can be configured with an additional script:"
echo "https://docs.scrypted.app/scrypted-nvr/installation.html#docker-volume"

View File

@@ -0,0 +1,140 @@
if [ -z "$SERVICE_USER" ]
then
echo "Scrypted SERVICE_USER environment variable was not specified. NVR Storage can not be configured."
exit 0
fi
if [ "$USER" != "root" ]
then
echo "$USER"
echo "This script must be run as sudo or root."
exit 1
fi
USER_HOME=$(eval echo ~$SERVICE_USER)
SCRYPTED_HOME=$USER_HOME/.scrypted
DOCKER_COMPOSE_YML=$SCRYPTED_HOME/docker-compose.yml
if [ ! -f "$DOCKER_COMPOSE_YML" ]
then
echo "$DOCKER_COMPOSE_YML not found. Install Scrypted first."
exit 1
fi
NVR_MOUNT_LINE=$(cat "$DOCKER_COMPOSE_YML" | grep :/nvr)
if [ -z "$NVR_MOUNT_LINE" ]
then
echo "Unexpected contents in $DOCKER_COMPOSE_YML. Rerun the Scrypted docker compose installer."
exit 1
fi
function backup() {
BACKUP_FILE="$1".scrypted-bak
if [ ! -f "$BACKUP_FILE" ]
then
cp "$1" "$BACKUP_FILE"
fi
}
backup "$DOCKER_COMPOSE_YML"
function readyn() {
while true; do
read -p "$1 (y/n) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no. (y/n)";;
esac
done
}
if [ -z "$1" ]
then
lsblk
echo ""
echo "Please run the script with an existing mount path or the 'disk' device to format (e.g. sdx)."
exit 1
fi
function stopscrypted() {
cd "$SCRYPTED_HOME"
echo ""
echo "Stopping the Scrypted container. If there are any errors during disk setup, Scrypted will need to be manually restarted with:"
echo "cd $SCRYPTED_HOME && docker compose up -d"
echo ""
docker compose down
}
BLOCK_DEVICE="/dev/$1"
if [ -b "$BLOCK_DEVICE" ]
then
readyn "Format $BLOCK_DEVICE?"
if [ "$yn" == "n" ]
then
exit 1
fi
stopscrypted
umount "$BLOCK_DEVICE"1 2> /dev/null
umount "$BLOCK_DEVICE"2 2> /dev/null
umount /mnt/scrypted-nvr 2> /dev/null
set -e
parted "$BLOCK_DEVICE" --script mklabel gpt
parted -a optimal "$BLOCK_DEVICE" mkpart scrypted-nvr "0%" "100%"
set +e
sync
mkfs -F -t ext4 "$BLOCK_DEVICE"1
sync
# parse/evaluate blkid line as env vars
for attr in $(blkid | grep "$BLOCK_DEVICE")
do
e=$(echo $attr | grep =)
if [ ! -z "$e" ]
then
export "$e"
fi
done
if [ -z "$UUID" ]
then
echo "Error parsing disk UUID."
exit 1
fi
echo "UUID: $UUID"
set -e
backup "/etc/fstab"
grep -v "scrypted-nvr" /etc/fstab > /tmp/fstab && cp /tmp/fstab /etc/fstab
# ensure newline
sed -i -e '$a\' /etc/fstab
mkdir -p /mnt/scrypted-nvr
echo "PARTLABEL=scrypted-nvr /mnt/scrypted-nvr ext4 defaults 0 0" >> /etc/fstab
mount -a
set +e
DIR="/mnt/scrypted-nvr"
else
if [ ! -d "$1" ]
then
echo "$1 is not a valid directory."
exit 1
fi
stopscrypted
DIR="$1"
fi
ESCAPED_DIR=$(echo "$DIR" | sed s/\\//\\\\\\//g)
set -e
sed -i s/'^.*:\/nvr'/" - $ESCAPED_DIR:\/nvr"/ "$DOCKER_COMPOSE_YML"
sed -i s/'^.*SCRYPTED_NVR_VOLUME.*$'/" - SCRYPTED_NVR_VOLUME=\/nvr"/ "$DOCKER_COMPOSE_YML"
set +e
cd "$SCRYPTED_HOME" && docker compose up -d

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/objectdetector",
"version": "0.1.20",
"version": "0.1.21",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/objectdetector",
"version": "0.1.20",
"version": "0.1.21",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/objectdetector",
"version": "0.1.20",
"version": "0.1.21",
"description": "Scrypted Video Analysis Plugin. Installed alongside a detection service like OpenCV or TensorFlow.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -514,10 +514,14 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
if (!o.boundingBox)
continue;
o.zones = []
const box = normalizeBox(o.boundingBox, detection.inputDimensions);
let included: boolean;
// need a way to explicitly include package zone.
if (o.zones)
included = true;
else
o.zones = [];
for (const [zone, zoneValue] of Object.entries(this.zones)) {
if (zoneValue.length < 3) {
// this.console.warn(zone, 'Zone is unconfigured, skipping.');

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.10.11",
"version": "0.10.12",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/prebuffer-mixin",
"version": "0.10.11",
"version": "0.10.12",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.10.11",
"version": "0.10.12",
"description": "Video Stream Rebroadcast, Prebuffer, and Management Plugin for Scrypted.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -1,4 +1,4 @@
import path from 'path'
import { AutoenableMixinProvider } from '@scrypted/common/src/autoenable-mixin-provider';
import { getDebugModeH264EncoderArgs, getH264EncoderArgs } from '@scrypted/common/src/ffmpeg-hardware-acceleration';
import { addVideoFilterArguments } from '@scrypted/common/src/ffmpeg-helpers';
@@ -971,6 +971,7 @@ class PrebufferSession {
const clientPromise = await listenSingleRtspClient({
hostname,
pathToken: path.join(crypto.randomBytes(8).toString('hex'), this.mixin.id),
createServer: duplex => {
sdp = addTrackControls(sdp);
server = new FileRtspServer(duplex, sdp);

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/server",
"version": "0.89.0",
"version": "0.91.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/server",
"version": "0.89.0",
"version": "0.91.0",
"license": "ISC",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.11",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/server",
"version": "0.89.0",
"version": "0.91.6",
"description": "",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.11",
@@ -62,7 +62,7 @@
"build": "tsc --outDir dist",
"postbuild": "node test/check-build-output.js",
"beta": "npm publish --tag beta",
"postbeta": "npm version minor && git add package.json && npm run build && git commit -m postbeta",
"postbeta": "npm version patch && git add package.json && npm run build && git commit -m postbeta",
"release": "npm publish",
"prepublishOnly": "npm run build",
"postrelease": "git tag v$npm_package_version && git push origin v$npm_package_version && npm version minor && git add package.json && git commit -m postrelease",

View File

@@ -21,9 +21,7 @@ export class NodeForkWorker extends ChildProcessWorker {
this.worker = child_process.fork(mainFilename, ['child', this.pluginId], {
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
env: Object.assign({}, process.env, env, {
NODE_PATH: path.join(getPluginNodePath(this.pluginId), 'node_modules'),
}),
env: Object.assign({}, process.env, env),
serialization: 'advanced',
execArgv,
});

View File

@@ -16,9 +16,7 @@ export class NodeThreadWorker extends EventEmitter implements RuntimeWorker {
this.worker = new worker_threads.Worker(mainFilename, {
argv: ['child-thread', this.pluginId],
env: Object.assign({}, process.env, env, {
NODE_PATH: path.join(getPluginNodePath(this.pluginId), 'node_modules'),
}),
env: Object.assign({}, process.env, env),
});
this.worker.on('exit', () => {

View File

@@ -53,10 +53,12 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
const pluginPythonVersion = options.packageJson.scrypted.pythonVersion?.[os.platform()]?.[os.arch()] || options.packageJson.scrypted.pythonVersion?.default;
if (os.platform() === 'win32') {
pythonPath ||= 'py.exe';
const windowsPythonVersion = pluginPythonVersion || process.env.SCRYPTED_WINDOWS_PYTHON_VERSION;
if (windowsPythonVersion)
args.unshift(windowsPythonVersion)
if (!pythonPath) {
pythonPath = 'py.exe';
const windowsPythonVersion = pluginPythonVersion || process.env.SCRYPTED_WINDOWS_PYTHON_VERSION;
if (windowsPythonVersion)
args.unshift(windowsPythonVersion)
}
}
else if (pluginPythonVersion) {
pythonPath = `python${pluginPythonVersion}`;

View File

@@ -1,9 +1,10 @@
import v8 from 'v8';
import vm from 'vm';
import dns from 'dns';
import process from 'process';
import semver from 'semver';
import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
import v8 from 'v8';
import vm from 'vm';
import { PluginError } from './plugin/plugin-error';
import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
import type { Runtime } from './scrypted-server-main';
export function isChildProcess() {
@@ -26,7 +27,7 @@ function start(mainFilename: string, options?: {
// This causes issues with clients that are on "IPv6" networks that are
// actually busted and fail to connect to npm's IPv6 address.
// The workaround is to favor IPv4.
process.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
dns.setDefaultResultOrder('ipv4first');
startPeriodicGarbageCollection();

View File

@@ -1,11 +1,16 @@
import { startPluginRemote } from "./plugin/plugin-remote-worker";
import { RpcMessage } from "./rpc";
import worker_threads from "worker_threads";
import v8 from 'v8';
import net from 'net';
import v8 from 'v8';
import worker_threads from "worker_threads";
import { getPluginNodePath } from "./plugin/plugin-npm-dependencies";
import { startPluginRemote } from "./plugin/plugin-remote-worker";
import { SidebandSocketSerializer } from "./plugin/socket-serializer";
import { RpcMessage } from "./rpc";
function start(mainFilename: string) {
const pluginId = process.argv[3];
console.log('starting plugin', pluginId);
module.paths.push(getPluginNodePath(pluginId));
if (process.argv[2] === 'child-thread') {
const peer = startPluginRemote(mainFilename, process.argv[3], (message, reject) => {
try {