#!/usr/bin/env bash if [ "$USER" != "root" ] then echo "Installation must be run as 'root' (use sudo)." exit 1 fi echo "Stopping existing service if it is running..." systemctl stop scrypted.service # bad hack to run a dockerfile like a shell script. RUN() { # echo "Running: $@" $@ if [ $? -ne 0 ] then echo 'Error during previous command.' exit 1 fi } # The Dockefile.common contains an S6 overlay that should not be installed. # Do not run anything until the ENTRYPOINT directive is sent. ENTRYPOINT() { ALLOW_RUN=1 } COPY() { echo "ignoring COPY $1" } FROM() { echo "ignoring FROM $1" } # process ARG for script variables but ignore ENV ARG() { export $@ } ENV() { echo "ignoring ENV $1" } source <(curl -s https://raw.githubusercontent.com/koush/scrypted/main/docker/template/Dockerfile.common.header) if [ -z "$SERVICE_USER" ] then echo "Scrypted SERVICE_USER environment variable was not specified. Service will not be installed." exit 0 fi if [ "$SERVICE_USER" == "root" ] then echo "Scrypted SERVICE_USER root is not allowed." exit 1 fi # this is not RUN as we do not care about the result echo "Setting permissions on /home/$SERVICE_USER/.scrypted" chown -R $SERVICE_USER /home/$SERVICE_USER/.scrypted echo "Installing Scrypted..." RUN sudo -u $SERVICE_USER npx -y scrypted@latest install-server cat > /etc/systemd/system/scrypted.service <