Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
add shellcheck to CI (#2478)
Meisambb61ffb56a22
diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.ymlindex 6bd7cdf2cb..80f9ce41d4 100644--- a/.github/workflows/go-lint.yml+++ b/.github/workflows/go-lint.yml@@ -1,4 +1,4 @@-name: lint+name: Linton:push:paths-ignore:diff --git a/.github/workflows/javascript-formatting.yml b/.github/workflows/javascript-formatting.ymlindex 055d83c0bd..c32b113b07 100644--- a/.github/workflows/javascript-formatting.yml+++ b/.github/workflows/javascript-formatting.yml@@ -1,4 +1,4 @@-name: Format+Lint Javascript+name: Lint# This action works with pull requests and pusheson:@@ -11,7 +11,7 @@ on:jobs:prettier:- name: Run prettier+ name: Javascript prettierruns-on: ubuntu-latestdefaults:run:@@ -42,7 +42,7 @@ jobs:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}linter:- name: Run linter on changed files+ name: Javascript linterruns-on: ubuntu-latestdefaults:run:diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.ymlnew file mode 100644index 0000000000..bf8f8bf592--- /dev/null+++ b/.github/workflows/shellcheck.yml@@ -0,0 +1,30 @@+name: Lint++on:+ push:+ branches:+ - webv2+ paths:+ - '**.sh'+ pull_request:+ branches:+ - webv2+ paths:+ - '**.sh'++jobs:+ shellcheck:+ runs-on: ubuntu-latest+ env:+ LANG: C.UTF-8+ container:+ image: docker.io/ubuntu:22.04+ steps:+ - uses: actions/checkout@v3++ - name: Install shellcheck+ run: apt update && apt install -y shellcheck bash && shellcheck --version++ - name: Check shell scripts+ run: shopt -s globstar && ls **/*.sh && shellcheck --severity=info **/*.sh+ shell: bashdiff --git a/.gitignore b/.gitignoreindex 3d2a4e1600..d70ff0877c 100644--- a/.gitignore+++ b/.gitignore@@ -27,6 +27,7 @@ webroot/preview.gifwebroot/hlswebroot/static/content.mdhls/+!test/automated/hls/dist/data/transcoder.logdiff --git a/build/release/build.sh b/build/release/build.shdeleted file mode 100755index 260c3a3bd5..0000000000--- a/build/release/build.sh+++ /dev/null@@ -1,118 +0,0 @@-#!/bin/sh--# Human readable names of binary distributions-DISTRO=(macOS-64bit linux-64bit linux-32bit linux-arm7 linux-arm64)-# Operating systems for the respective distributions-OS=(darwin linux linux linux linux)-# Architectures for the respective distributions-ARCH=(amd64 amd64 386 arm-7 arm64)--# Version-VERSION=$1-SHOULD_RELEASE=$2--# Build info-GIT_COMMIT=$(git rev-list -1 HEAD)-GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)--if [[ -z "${VERSION}" ]]; then- echo "Version must be specified when running build"- exit-fi--BUILD_TEMP_DIRECTORY="$(mktemp -d)"-cd $BUILD_TEMP_DIRECTORY--echo "Cloning owncast into $BUILD_TEMP_DIRECTORY..."-git clone https://github.com/owncast/owncast 2> /dev/null-cd owncast--echo "Changing to branch: $GIT_BRANCH"-git checkout $GIT_BRANCH--[[ -z "${VERSION}" ]] && VERSION='unknownver' || VERSION="${VERSION}"--# Change to the root directory of the repository-cd $(git rev-parse --show-toplevel)--echo "Cleaning working directories..."-rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.jpg--echo "Creating version ${VERSION} from commit ${GIT_COMMIT}"--# Create production build of Tailwind CSS-pushd build/javascript >> /dev/null-# Install the tailwind & postcss CLIs-npm install --quiet --no-progress-# Run the tailwind CLI and pipe it to postcss for minification.-# Save it to a temp directory that we will reference below.-NODE_ENV="production" ./node_modules/.bin/tailwind build | ./node_modules/.bin/postcss > "${TMPDIR}tailwind.min.css"-popd--mkdir -p dist--build() {- NAME=$1- OS=$2- ARCH=$3- VERSION=$4- GIT_COMMIT=$5-- echo "Building ${NAME} (${OS}/${ARCH}) release from ${GIT_BRANCH} ${GIT_COMMIT}..."-- mkdir -p dist/${NAME}- mkdir -p dist/${NAME}/data-- cp -R webroot/ dist/${NAME}/webroot/-- # Copy the production pruned+minified css to the build's directory.- cp "${TMPDIR}tailwind.min.css" ./dist/${NAME}/webroot/js/web_modules/tailwindcss/dist/tailwind.min.css- cp README.md dist/${NAME}-- pushd dist/${NAME} >> /dev/null-- CGO_ENABLED=1 ~/go/bin/xgo -go latest --branch ${GIT_BRANCH} -ldflags "-s -w -X github.com/owncast/owncast/config.GitCommit=${GIT_COMMIT} -X github.com/owncast/owncast/config.BuildVersion=${VERSION} -X github.com/owncast/owncast/config.BuildPlatform=${NAME}" -tags enable_updates -targets "${OS}/${ARCH}" github.com/owncast/owncast- mv owncast-*-${ARCH} owncast-- zip -r -q -8 ../owncast-$VERSION-$NAME.zip .- popd >> /dev/null-- rm -rf dist/${NAME}/-}--for i in "${!DISTRO[@]}"; do- build ${DISTRO[$i]} ${OS[$i]} ${ARCH[$i]} $VERSION $GIT_COMMIT-done--echo "Build archives are available in $BUILD_TEMP_DIRECTORY/owncast/dist"-ls -alh "$BUILD_TEMP_DIRECTORY/owncast/dist"--# Use the second argument "release" to create an actual release.-if [ "$SHOULD_RELEASE" != "release" ]; then- echo "Not uploading a release."- exit-fi--# Create the tag-git tag -a "v${VERSION}" -m "Release build v${VERSION}"--# On macOS open the Github page for new releases so they can be uploaded-if test -f "/usr/bin/open"; then- open "https://github.com/owncast/owncast/releases/new"- open dist-fi--# Docker build-# Must authenticate first: https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages#authenticating-to-github-packages-DOCKER_IMAGE="owncast-${VERSION}"-echo "Building Docker image ${DOCKER_IMAGE}..."--# Change to the root directory of the repository-cd $(git rev-parse --show-toplevel)--# Docker build-docker build --build-arg NAME=docker --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=$GIT_COMMIT -t gabekangas/owncast:$VERSION -t gabekangas/owncast:latest -t owncast .--# Dockerhub-# You must be authenticated via `docker login` with your Dockerhub credentials first.-docker push "gabekangas/owncast:${VERSION}"diff --git a/build/release/docker-nightly.sh b/build/release/docker-nightly.shindex 990ea5c1d2..d171bce149 100755--- a/build/release/docker-nightly.sh+++ b/build/release/docker-nightly.sh@@ -9,6 +9,6 @@ VERSION="${DATE}-nightly"echo "Building Docker image ${DOCKER_IMAGE}..."# Change to the root directory of the repository-cd $(git rev-parse --show-toplevel)+cd "$(git rev-parse --show-toplevel)" || exitearthly --ci --push +docker-all --image="ghcr.io/owncast/${DOCKER_IMAGE}" --tag=nightly --version="${VERSION}"diff --git a/build/release/docker-webv2.sh b/build/release/docker-webv2.shindex b75a9d4c93..a5ca31ca2a 100755--- a/build/release/docker-webv2.sh+++ b/build/release/docker-webv2.sh@@ -9,7 +9,7 @@ VERSION="${DATE}-${TAG}"echo "Building Docker image ${DOCKER_IMAGE}..."# Change to the root directory of the repository-cd $(git rev-parse --show-toplevel)+cd "$(git rev-parse --show-toplevel)" || exitgit checkout webv2-earthly --ci --push +docker-all --image="ghcr.io/owncast/${DOCKER_IMAGE}" --tag=${TAG} --version="${VERSION}"+earthly --ci --push +docker-all --image="ghcr.io/owncast/${DOCKER_IMAGE}" --tag="${TAG}" --version="${VERSION}"diff --git a/test/automated/api/run.sh b/test/automated/api/run.shindex dde360cf9e..59979ffabf 100755--- a/test/automated/api/run.sh+++ b/test/automated/api/run.sh@@ -8,21 +8,21 @@ npm install --quiet --no-progress# Download a specific version of ffmpegif [ ! -d "ffmpeg" ]; thenmkdir ffmpeg- pushd ffmpeg >/dev/null+ pushd ffmpeg >/dev/null || exitcurl -sL https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.2.1/ffmpeg-4.2.1-linux-64.zip --output ffmpeg.zip >/dev/nullunzip -o ffmpeg.zip >/dev/nullPATH=$PATH:$(pwd)- popd >/dev/null+ popd >/dev/null || exitfi-pushd ../../.. >/dev/null+pushd ../../.. >/dev/null || exit# Build and run owncast from sourcego build -o owncast main.go-./owncast -database $TEMP_DB &+./owncast -database "$TEMP_DB" &SERVER_PID=$!-popd >/dev/null+popd >/dev/null || exitsleep 5# Start streaming the test file over RTMP to@@ -31,7 +31,7 @@ ffmpeg -hide_banner -loglevel panic -stream_loop -1 -re -i ../test.mp4 -vcodec lFFMPEG_PID=$!function finish {- rm $TEMP_DB+ rm "$TEMP_DB"kill $SERVER_PID $FFMPEG_PID}trap finish EXITdiff --git a/test/automated/browser/run.sh b/test/automated/browser/run.shindex 27fce4e092..a49ef61898 100755--- a/test/automated/browser/run.sh+++ b/test/automated/browser/run.sh@@ -26,7 +26,7 @@ if [ ! -d "ffmpeg" ]; thenecho "Downloading ffmpeg..."mkdir -p /tmp/ffmpegpushd /tmp/ffmpeg >/dev/null- curl -sL https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.2.1/ffmpeg-4.2.1-linux-64.zip --output ffmpeg.zip >/dev/null+ curl -sL --fail https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.2.1/ffmpeg-4.2.1-linux-64.zip --output ffmpeg.zipunzip -o ffmpeg.zip >/dev/nullPATH=$PATH:$(pwd)popd >/dev/null@@ -36,7 +36,7 @@ fiecho "Building owncast..."go build -o owncast main.goecho "Running owncast..."-./owncast -database $TEMP_DB &+./owncast -database "$TEMP_DB" &SERVER_PID=$!pushd test/automated/browser@@ -54,7 +54,7 @@ STREAMING_CLIENT=$!function finish {echo "Cleaning up..."- rm $TEMP_DB+ rm "$TEMP_DB"kill $SERVER_PID $STREAMING_CLIENT}trap finish EXIT SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT SIGTERMdiff --git a/test/automated/hls/run.sh b/test/automated/hls/run.shindex 1eb0e83700..861b222849 100755--- a/test/automated/hls/run.sh+++ b/test/automated/hls/run.sh@@ -37,12 +37,12 @@ pushd ../../.. >/dev/null# Build and run owncast from sourcego build -o owncast main.go-./owncast -database $TEMP_DB &+./owncast -database "$TEMP_DB" &SERVER_PID=$!function finish {echo "Cleaning up..."- rm $TEMP_DB+ rm "$TEMP_DB"kill $SERVER_PID $STREAMING_CLIENT}trap finish EXITdiff --git a/test/ocTestStream.sh b/test/ocTestStream.shindex ab54f7b620..7cc22677b1 100755--- a/test/ocTestStream.sh+++ b/test/ocTestStream.sh@@ -4,31 +4,32 @@# to repeat indefinitely.# Example: ./test/ocTestStream.sh ~/Downloads/*.mp4 rtmp://localhost/live/abc123-if ! ([[ $1 ]])+if ! [[ $1 ]]thenecho "ocTestStream is used for sending pre-recorded content to a RTMP server."echo "Will default to localhost with the stream key of abc123 if one isn't provided."echo "./ocTestStream.sh *.mp4 [RTMPDESINATION]"-exit+ exitfi# Make the destination optional and point to localhost with default key-if [[ ${@: -1} == *"rtmp://"* ]]; then- echo "RTMP is specified"- DESTINATION_HOST=${@: -1}- array=( $@ )- ARGS_LEN=${#array[@]}- CONTENT=${array[@]:0:$ARGS_LEN-1}- DESTINATION_HOST=${@: -1}- FILE_COUNT=$( expr ${#} - 1 )+if [[ ${*: -1} == *"rtmp://"* ]]; then+ echo "RTMP server is specified"+ DESTINATION_HOST=${*: -1}+ FILE_COUNT=$(( ${#} - 1 ))else+ echo "RTMP server is not specified"DESTINATION_HOST="rtmp://localhost/live/abc123"- array=( $@ )- ARGS_LEN=${#array[@]}- CONTENT=${array[@]:0:$ARGS_LEN}- FILE_COUNT=$( expr ${#} )+ FILE_COUNT=${#}fi+if [[ FILE_COUNT -eq 0 ]]; then+ echo "ERROR: ocTestStream needs a video file for sending to the RTMP server."+ exit+fi++CONTENT=${*:1:${FILE_COUNT}}+# Delete the old list of files if it existsif test -f list.txt; thenrm list.txt@@ -44,6 +45,11 @@ function finish {}trap finish EXIT-echo "Streaming a loop of ${FILE_COUNT} videos to $DESTINATION_HOST. Warning: If these files differ greatly in formats transitioning from one to another may not always work correctly... ctl+c to exit"+echo "Streaming a loop of ${FILE_COUNT} videos to $DESTINATION_HOST."+if [[ FILE_COUNT -gt 1 ]]; then+ echo "Warning: If these files differ greatly in formats transitioning from one to another may not always work correctly."+fi+echo "$CONTENT"+echo "...press ctl+c to exit"-ffmpeg -hide_banner -loglevel panic -stream_loop -1 -re -f concat -safe 0 -i list.txt -vcodec libx264 -profile:v high -g 48 -r 24 -sc_threshold 0 -b:v 1300k -preset veryfast -acodec copy -vf drawtext="fontfile=monofonto.ttf: fontsize=96: box=1: [email protected]: boxborderw=5: fontcolor=white: x=(w-text_w)/2: y=((h-text_h)/2)+((h-text_h)/4): text='%{gmtime\:%H\\\\\:%M\\\\\:%S}'" -f flv $DESTINATION_HOST+ffmpeg -hide_banner -loglevel panic -stream_loop -1 -re -f concat -safe 0 -i list.txt -vcodec libx264 -profile:v high -g 48 -r 24 -sc_threshold 0 -b:v 1300k -preset veryfast -acodec copy -vf drawtext="fontfile=monofonto.ttf: fontsize=96: box=1: [email protected]: boxborderw=5: fontcolor=white: x=(w-text_w)/2: y=((h-text_h)/2)+((h-text_h)/4): text='%{gmtime\:%H\\\\\:%M\\\\\:%S}'" -f flv "$DESTINATION_HOST"diff --git a/web/README.md b/web/README.mdindex 2b35a61210..970f828c6e 100644--- a/web/README.md+++ b/web/README.md@@ -25,7 +25,7 @@ isolation.1. Go to the `Canvas` tab of the component you selected and see if there's a Design attached to it.1. If there is a design, then that's a starting point you can use to start building out the component.1. If there isn't, then visit the [Owncast Demo Server](https://watch.owncast.online), the [Owncast Nightly Build](https://nightly.owncast.online), or the proposed [v2 design](https://www.figma.com/file/B6ICOn1J3dyYeoZM5kPM2A/Owncast---Review?node-id=0%3A1) for some ways to start.-1. If no design exists, then you can ask around the Owncast chat for help, for come up with your own ideas!+1. If no design exists, then you can ask around the Owncast chat for help, or come up with your own ideas!1. No designs are stuck in stone, and we're using this as an opportunity to level up the UI of Owncast, so all ideas are welcome.See the extra how-to guide for components here: [Components How-to](./components/_COMPONENT_HOW_TO.md).