Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rebroadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed May 30, 2024
2 parents 72c5690 + 67cec18 commit f65485a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 53 deletions.
64 changes: 20 additions & 44 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,28 @@ on:
workflow_dispatch:

jobs:
test_linux_local:
name: Test Linux local installation
runs-on: ubuntu-latest
test_local:
name: Test local installation on ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner: [ubuntu-latest, macos-14, macos-13, windows-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run install script
run: |
cat ./install/local/install-scrypted-dependencies-linux.sh | sudo SERVICE_USER=$USER bash
- name: Test server is running
run: |
systemctl status scrypted.service
curl -k --retry 20 --retry-all-errors --retry-max-time 600 https://localhost:10443/
test_mac_local:
name: Test Mac local installation
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run install script
run: |
mkdir -p ~/.scrypted
bash ./install/local/install-scrypted-dependencies-mac.sh
- name: Test server is running
run: |
curl -k --retry 20 --retry-all-errors --retry-max-time 600 https://localhost:10443/
test_windows_local:
name: Test Windows local installation
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run install script
run: |
.\install\local\install-scrypted-dependencies-win.ps1
- name: Test server is running

- name: Parse latest server release
id: parse_server
shell: bash
run: |
curl -k --retry 20 --retry-all-errors --retry-max-time 600 https://localhost:10443/
VERSION=$(cat ./server/package-lock.json | jq -r '.version')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Will test @scrypted/server@$VERSION"
- name: Install scrypted server
uses: scryptedapp/setup-scrypted@v0.0.2
with:
branch: ${{ github.sha }}
version: ${{ steps.parse_server.outputs.version }}
7 changes: 6 additions & 1 deletion install/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
# Avahi can be used for network discovery by passing in the host daemon
# or running the daemon inside the container. Choose one or the other.
# Uncomment next line to run avahi-daemon inside the container.
# See volumes section below to use the host daemon.
# See volumes and security_opt section below to use the host daemon.
# - SCRYPTED_DOCKER_AVAHI=true

# NVIDIA (Part 1 of 4)
Expand Down Expand Up @@ -71,11 +71,16 @@ services:
# Ensure Avahi is running on the host machine:
# It can be installed with: sudo apt-get install avahi-daemon
# This is not compatible with running avahi inside the container (see above).
# Also, uncomment the lines under security_opt
# - /var/run/dbus:/var/run/dbus
# - /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket

# Default volume for the Scrypted database. Typically should not be changed.
- ~/.scrypted/volume:/server/volume
# Uncomment the following lines to use Avahi daemon from the host
# Without this, AppArmor will block the container's attempt to talk to Avahi via dbus
# security_opt:
# - apparmor:unconfined
devices: [
# uncomment the common systems devices to pass
# them through to docker.
Expand Down
2 changes: 2 additions & 0 deletions install/docker/install-scrypted-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ then
sudo apt-get -y install avahi-daemon
sed -i 's/'#' - \/var\/run\/dbus/- \/var\/run\/dbus/g' $DOCKER_COMPOSE_YML
sed -i 's/'#' - \/var\/run\/avahi-daemon/- \/var\/run\/avahi-daemon/g' $DOCKER_COMPOSE_YML
sed -i 's/'#' security_opt:/security_opt:/g' $DOCKER_COMPOSE_YML
sed -i 's/'#' - apparmor:unconfined/ - apparmor:unconfined/g' $DOCKER_COMPOSE_YML
fi

echo "Setting permissions on $SCRYPTED_HOME"
Expand Down
12 changes: 11 additions & 1 deletion install/docker/setup-scrypted-nvr-volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@ then
set +e

sync
mkfs -F -t ext4 "$BLOCK_DEVICE"1
PARTITION_DEVICE="$BLOCK_DEVICE"1
if [ ! -e "$PARTITION_DEVICE" ]
then
PARTITION_DEVICE="$BLOCK_DEVICE"p1
if [ ! -e "$PARTITION_DEVICE" ]
then
echo "Unable to determine block device partition from block device: $BLOCK_DEVICE"
exit 1
fi
fi
mkfs -F -t ext4 "$PARTITION_DEVICE"
sync

# parse/evaluate blkid line as env vars
Expand Down
2 changes: 1 addition & 1 deletion install/local/install-scrypted-dependencies-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ echo "docker compose rm -rf"
sudo -u $SERVICE_USER docker rm -f /scrypted /scrypted-watchtower 2> /dev/null

echo "Installing Scrypted..."
RUN sudo -u $SERVICE_USER npx -y scrypted@latest install-server
RUN sudo -u $SERVICE_USER npx -y scrypted@latest install-server $SCRYPTED_INSTALL_VERSION

cat > /etc/systemd/system/scrypted.service <<EOT
Expand Down
2 changes: 1 addition & 1 deletion install/local/install-scrypted-dependencies-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ then
fi

echo "Installing Scrypted..."
RUN $NPX_PATH -y scrypted@latest install-server
RUN $NPX_PATH -y scrypted@latest install-server $SCRYPTED_INSTALL_VERSION

cat > ~/Library/LaunchAgents/app.scrypted.server.plist <<EOT
<?xml version="1.0" encoding="UTF-8"?>
Expand Down
7 changes: 6 additions & 1 deletion install/local/install-scrypted-dependencies-win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";"
py $SCRYPTED_WINDOWS_PYTHON_VERSION -m pip install --upgrade pip
py $SCRYPTED_WINDOWS_PYTHON_VERSION -m pip install debugpy typing_extensions typing opencv-python

npx -y scrypted@latest install-server
$SCRYPTED_INSTALL_VERSION=[System.Environment]::GetEnvironmentVariable("SCRYPTED_INSTALL_VERSION","User")
if ($SCRYPTED_INSTALL_VERSION -eq $null) {
npx -y scrypted@latest install-server
} else {
npx -y scrypted@latest install-server $SCRYPTED_INSTALL_VERSION
}

$USER_HOME_ESCAPED = $env:USERPROFILE.replace('\', '\\')
$SCRYPTED_HOME = $env:USERPROFILE + '\.scrypted'
Expand Down
2 changes: 1 addition & 1 deletion plugins/homekit/src/types/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ addSupportedType({
},
closeRecordingStream(streamId, reason) {
const r = openRecordingStreams.get(streamId);
r?.throw(new Error(reason?.toString()));
console.log(`motion recording closed ${reason > 0 ? `(error code: ${reason})` : ''}`);
openRecordingStreams.delete(streamId);
},
updateRecordingActive(active) {
Expand Down
9 changes: 6 additions & 3 deletions plugins/homekit/src/types/camera/camera-recording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ export async function* handleFragmentsRequests(streamId: number, device: Scrypte
let moov: Buffer[];

for await (const box of generator) {
if (!isOpen())
return;

const { header, type, data } = box;
// console.log('motion fragment box', type);

Expand Down Expand Up @@ -352,6 +355,8 @@ export async function* handleFragmentsRequests(streamId: number, device: Scrypte
needSkip = false;
continue;
}
if (!isOpen())
return;
const fragment = Buffer.concat(pending);
saveFragment(i, fragment);
pending = [];
Expand All @@ -361,16 +366,14 @@ export async function* handleFragmentsRequests(streamId: number, device: Scrypte
data: fragment,
isLast,
}
if (!isOpen())
return;
yield recordingPacket;
if (wasLast)
break;
}
}
}
catch (e) {
console.log(`motion recording completed ${e}`);
console.log(`motion recording error ${e}`);
}
finally {
console.log(`motion recording finished`);
Expand Down

0 comments on commit f65485a

Please sign in to comment.