diff --git a/distributed_minio/package.json b/distributed_minio/package.json new file mode 100644 index 0000000..53c2e1a --- /dev/null +++ b/distributed_minio/package.json @@ -0,0 +1,34 @@ +{ + "name": "minio", + "display_name": "Distributed MinIO", + "description": "MinIO is a high performance object storage server. Users can interact with it through its S3 API.", + "parameters": [ + { + "name": "ACCESS_KEY", + "display_name": "Access Key", + "description": "Access key for accessing the S3 cluster", + "type": "string", + "required": true + }, + { + "name": "SECRET_KEY", + "display_name": "Secret Key", + "description": "Secret key for accessing the S3 cluster", + "type": "string", + "required": true + }, + { + "name": "IPS", + "display_name": "Peer IPs", + "description": "IP addresses to use for cluster communication", + "type": "list", + "required": true + } + ], + "main": "distributed_minio/run.sh", + "dependencies": [ + "distributed_minio/run.sh", + "utils/cachengo.sh", + "utils/parameters.sh" + ] +} \ No newline at end of file diff --git a/distributed_minio/run.sh b/distributed_minio/run.sh new file mode 100644 index 0000000..32085b0 --- /dev/null +++ b/distributed_minio/run.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +source "utils/cachengo.sh" +source "utils/parameters.sh" + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + echo $IPS + local IPS_ARR + array_from_json_list IPS_ARR "$IPS" + export MINIO_ACCESS_KEY=$ACCESS_KEY + export MINIO_SECRET_KEY=$SECRET_KEY + + for ((i=0;i<${#IPS_ARR[@]};++i)); do + echo "${IPS_ARR[i]} $GROUPID-$i" + echo "${IPS_ARR[i]} $GROUPID-$i" >> /etc/hosts + done + + echo "Total: $i" + + docker run -p 9000:9000 \ + --name $APPID \ + -d \ + -e "MINIO_ROOT_USER=$ACCESS_KEY" \ + -e "MINIO_ROOT_PASSWORD=$SECRET_KEY" \ + -v /data/$GROUPID:/data \ + --net host \ + --restart unless-stopped \ + minio/minio server http://$GROUPID-{0...$((i-1))}/data/ + + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + rm -rf /data/$GROUPID + sed -i "/$GROUPID/d" /etc/hosts + docker stop $APPID + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/docker-sv/package.json b/docker-sv/package.json new file mode 100644 index 0000000..f30729d --- /dev/null +++ b/docker-sv/package.json @@ -0,0 +1,11 @@ +{ + "name": "bsv-bitcoind", + "display_name": "BSV bitcoind", + "description": "Runs the bitcoind executable from a Docker container.", + "parameters": [], + "main": "docker-sv/run.sh", + "dependencies": [ + "docker-sv/run.sh", + "utils/cachengo.sh" + ] +} diff --git a/docker-sv/run.sh b/docker-sv/run.sh new file mode 100644 index 0000000..b4c5781 --- /dev/null +++ b/docker-sv/run.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + mkdir -p /bitcoin-data + docker run \ + --name $APPID \ + -d \ + -p 8332:8332 \ + -p 8333:8333 \ + -p 9332:9332 \ + -p 9333:9333 \ + -p 18332:18332 \ + -p 18333:18333 \ + -v ~/bitcoin-data:/data \ + --restart unless-stopped \ + registry.cachengo.com/cachengo/docker-sv-aarch64:0.0 + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + docker stop $APPID + docker rm $APPID + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/facerec_example/package.json b/facerec_example/package.json new file mode 100644 index 0000000..7aee9c6 --- /dev/null +++ b/facerec_example/package.json @@ -0,0 +1,11 @@ +{ + "name": "facerec_example", + "display_name": "Facerec Demo", + "description": "Runs a facial-recognition inference engine, a nearest-neighbors search database and a webserver exposed on :5001", + "parameters": [], + "main": "facerec_example/run.sh", + "dependencies": [ + "facerec_example/run.sh", + "utils/cachengo.sh" + ] +} \ No newline at end of file diff --git a/facerec_example/run.sh b/facerec_example/run.sh new file mode 100644 index 0000000..981b5f0 --- /dev/null +++ b/facerec_example/run.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +NETNAME=$APPID-net +DATADIR=/data/$APPID + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + + mkdir -p $DATADIR + docker network create -d bridge $NETNAME + + cachengo-cli updateInstallStatus $APPID "Installing: Search" + docker run -d \ + -v $DATADIR/index256:/db \ + -e "ANN_INDEX_LENGTH=256" \ + --network=$NETNAME \ + --name $APPID-nn_search \ + registry.cachengo.com/cachengo/nn_search:2.0 + + cachengo-cli updateInstallStatus $APPID "Installing: Facerec" + docker run -d \ + --network=$NETNAME \ + --name=$APPID-facerec \ + registry.cachengo.com/cachengo/facerec:1.0 + + cachengo-cli updateInstallStatus $APPID "Installing: Server" + docker run -d \ + -p 5001:5000 \ + -v $DATADIR/sso:/db \ + -e "NN_SEARCH_ADDRESS=$APPID-nn_search:1323" \ + -e "FACEREC_ADDRESS=$APPID-facerec:5000" \ + --network=$NETNAME \ + --name $APPID-sso \ + registry.cachengo.com/cachengo/ford_sso_example:latest + + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + docker network rm $NETNAME + docker stop $APPID-nn_search + docker rm $APPID-nn_search + docker stop $APPID-facerec + docker rm $APPID-facerec + docker stop $APPID-sso + docker rm $APPID-sso + rm -rf $DATADIR + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/minio/package.json b/minio/package.json index 6126be4..b73a529 100644 --- a/minio/package.json +++ b/minio/package.json @@ -1,8 +1,23 @@ { "name": "minio", - "display_name": "Min.io", - "description": "Runs a Min.io S3 server", - "parameters": [], + "display_name": "Standalone MinIO", + "description": "MinIO is a high performance object storage server. Users can interact with it through its S3 API.", + "parameters": [ + { + "name": "ACCESS_KEY", + "display_name": "Access Key", + "description": "Access key for accessing the S3 cluster. Can be any string.", + "type": "string", + "required": true + }, + { + "name": "SECRET_KEY", + "display_name": "Secret Key", + "description": "Secret key for accessing the S3 cluster", + "type": "string", + "required": true + } + ], "main": "minio/run.sh", "dependencies": [ "minio/run.sh", diff --git a/minio/run.sh b/minio/run.sh index 6d3accb..dec3ad6 100755 --- a/minio/run.sh +++ b/minio/run.sh @@ -9,13 +9,19 @@ function do_install { --name $APPID \ -d \ -p 9000:9000 \ - cachengo/minio:latest server /data + -e "MINIO_ACCESS_KEY=$ACCESS_KEY" \ + -e "MINIO_SECRET_KEY=$SECRET_KEY" \ + --restart unless-stopped \ + -v /data/minio:/data \ + registry.cachengo.com/cachengo/minio:latest server /data cachengo-cli updateInstallStatus $APPID "Installed" } function do_uninstall { cachengo-cli updateInstallStatus $APPID "Uninstalling" docker stop $APPID + docker rm $APPID + rm -rf /data/minio/* cachengo-cli updateInstallStatus $APPID "Uninstalled" } diff --git a/new_user/package.json b/new_user/package.json new file mode 100644 index 0000000..bed2c1a --- /dev/null +++ b/new_user/package.json @@ -0,0 +1,26 @@ +{ + "name": "new_user", + "display_name": "New User", + "description": "Adds a new user account to the target devices", + "parameters": [ + { + "name": "TARGET_USER", + "display_name": "User", + "description": "User on which to install the key", + "type": "string", + "required": true + }, + { + "name": "IS_SUDOER", + "display_name": "Sudoer?", + "description": "Should this user be added to the sudoers list?", + "type": "boolean", + "required": false + } + ], + "main": "new_user/run.sh", + "dependencies": [ + "new_user/run.sh", + "utils/cachengo.sh" + ] +} \ No newline at end of file diff --git a/new_user/run.sh b/new_user/run.sh new file mode 100644 index 0000000..2f0ff92 --- /dev/null +++ b/new_user/run.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + # Remove user@host to add our own identifier + useradd -s /path/to/shell -d /home/{dirname} -m -G sudo + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + sed -i "/$APPID/d" /home/*/.ssh/authorized_keys + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/nginx/package.json b/nginx/package.json new file mode 100644 index 0000000..49e816b --- /dev/null +++ b/nginx/package.json @@ -0,0 +1,11 @@ +{ + "name": "nginx", + "display_name": "NGINX", + "description": "Docker version of Nginx reverse proxy server. Serves files located in the node's /data/nginx folder", + "parameters": [], + "main": "nginx/run.sh", + "dependencies": [ + "nginx/run.sh", + "utils/cachengo.sh" + ] +} \ No newline at end of file diff --git a/nginx/run.sh b/nginx/run.sh new file mode 100644 index 0000000..4bb4afb --- /dev/null +++ b/nginx/run.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + docker run \ + --name $APPID \ + -d \ + -p 80:80 \ + --restart unless-stopped \ + -v /data/nginx:/usr/share/nginx/html:ro \ + registry.cachengo.com/library/nginx + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + docker stop $APPID + docker rm $APPID + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/plex/fix_preferences.py b/plex/fix_preferences.py new file mode 100644 index 0000000..f80dc1e --- /dev/null +++ b/plex/fix_preferences.py @@ -0,0 +1,24 @@ +import json +import os +import xml.etree.ElementTree as ET + +APP_ID = os.environ.get('APPID') or 'plex' +IP_ADDRESSES = json.loads(os.environ.get('IP_ADDRESSES') or '[]') + +xmlfile = '/data/{APP_ID}/config/Library/Application Support/Plex Media Server/Preferences.xml'.format(APP_ID=APP_ID) +tree = ET.parse(xmlfile) +root = tree.getroot() + +uuid = root.attrib.get('CertificateUUID', 'uuid') +root.set('allowedNetworks', "fc00:0000:0000:0000:0000:0000:0000:0000/7,172.17.0.0/16,127.0.0.1") +custom_connections = [ + 'https://{ip}.{uuid}.plex.direct:32400'.format(uuid=uuid, ip=ip.replace('.', '-').replace(':', '-')) + for ip in IP_ADDRESSES +] +root.set('customConnections', ','.join(custom_connections)) +print(','.join(custom_connections)) + +header = '\n' +data = ET.tostring(root) +with open(xmlfile, "w") as f: + f.write(header+data) \ No newline at end of file diff --git a/plex/package.json b/plex/package.json new file mode 100644 index 0000000..b6cc4ce --- /dev/null +++ b/plex/package.json @@ -0,0 +1,27 @@ +{ + "name": "plex", + "display_name": "Plex", + "description": "Plex Media Server", + "parameters": [ + { + "name": "PLEX_CLAIM", + "display_name": "Plex Claim", + "description": "Claim for you Plex accout. Get it at plex.tv/claim", + "type": "string", + "required": false + }, + { + "name": "IP_ADDRESSES", + "display_name": "Custom IPs", + "description": "IP addresses to advertise", + "type": "list", + "required": false + } + ], + "main": "plex/run.sh", + "dependencies": [ + "plex/run.sh", + "utils/cachengo.sh", + "plex/fix_preferences.py" + ] +} \ No newline at end of file diff --git a/plex/run.sh b/plex/run.sh new file mode 100644 index 0000000..6da70f5 --- /dev/null +++ b/plex/run.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + + docker run \ + -d --name $APPID \ + -e TZ="America/Puerto_Rico" \ + -e ADVERTISE_IP="http://replace:32400" \ + -v "/data/$APPID/config":/config \ + -v "/data/$APPID/transcode":/transcode \ + -v "/data/$APPID/media":/data \ + -v "$LIBRARY_FOLDER":/library \ + -e PLEX_CLAIM="$PLEX_CLAIM" \ + --network=host \ + cachengo/pms-docker-arm64 + + sleep 60 + ADDRESSES=`python plex/fix_preferences.py` + docker restart $APPID + cachengo-cli declareSecret -i "$APPID" -n Addresses -v "$ADDRESSES" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + docker stop $APPID + docker rm $APPID + rm -rf /data/$APPID + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/public_key/package.json b/public_key/package.json new file mode 100644 index 0000000..7ae0fcb --- /dev/null +++ b/public_key/package.json @@ -0,0 +1,26 @@ +{ + "name": "public_key", + "display_name": "Public Key", + "description": "Install a public key for node access via SSH", + "parameters": [ + { + "name": "TARGET_USER", + "display_name": "User", + "description": "User on which to install the key", + "type": "string", + "required": true + }, + { + "name": "PUBLIC_KEY", + "display_name": "Public Key", + "description": "Public key to add to authorized users", + "type": "string", + "required": true + } + ], + "main": "public_key/run.sh", + "dependencies": [ + "public_key/run.sh", + "utils/cachengo.sh" + ] +} \ No newline at end of file diff --git a/public_key/run.sh b/public_key/run.sh new file mode 100644 index 0000000..8db0d67 --- /dev/null +++ b/public_key/run.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + # Remove user@host to add our own identifier + key="$( cut -d ' ' -f 2 <<< "$PUBLIC_KEY" )" + sed -i -e '$a\' /home/$TARGET_USER/.ssh/authorized_keys + echo "ssh-rsa $key $APPID" >> /home/$TARGET_USER/.ssh/authorized_keys + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + sed -i "/$APPID/d" /home/*/.ssh/authorized_keys + sed -i "/$APPID/d" /home/.*/.ssh/authorized_keys + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac diff --git a/s3_benchmark/package.json b/s3_benchmark/package.json new file mode 100644 index 0000000..6808ab0 --- /dev/null +++ b/s3_benchmark/package.json @@ -0,0 +1,41 @@ +{ + "name": "s3_benchmark", + "display_name": "S3 Benchmark", + "description": "A tool to benchmark S3 clusters in parallel from multiple clients", + "parameters": [ + { + "name": "ACCESS_KEY", + "display_name": "Access Key", + "description": "Access key for accessing the S3 cluster", + "type": "string", + "required": true + }, + { + "name": "SECRET_KEY", + "display_name": "Secret Key", + "description": "Secret key for accessing the S3 cluster", + "type": "string", + "required": true + }, + { + "name": "SERVERS", + "display_name": "Server IPs", + "description": "IP addresses to use for communicating with S3 servers", + "type": "list", + "required": true + }, + { + "name": "CLIENTS", + "display_name": "Client IPs", + "description": "IP addresses to use for the clients", + "type": "list", + "required": true + } + ], + "main": "s3_benchmark/run.sh", + "dependencies": [ + "s3_benchmark/run.sh", + "utils/cachengo.sh", + "utils/parameters.sh" + ] + } \ No newline at end of file diff --git a/s3_benchmark/run.sh b/s3_benchmark/run.sh new file mode 100644 index 0000000..a5261c2 --- /dev/null +++ b/s3_benchmark/run.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +source "utils/cachengo.sh" +source "utils/parameters.sh" + +function do_install { + if [ "$(uname -m)" == 'aarch64' ]; then + ARCH=arm64 + else + ARCH=amd64 + fi + + local CLIENT_ARR + array_from_json_list CLIENT_ARR "$CLIENTS" + + local SERVER_ARR + array_from_json_list SERVER_ARR "$SERVERS" + + apt install -y pssh git + cd /tmp + curl -L -O https://golang.org/dl/go1.16.7.linux-$ARCH.tar.gz + tar -C /tmp -xzf go1.16.7.linux-$ARCH.tar.gz + git clone https://github.com/wasabi-tech/s3-benchmark.git + cd s3-benchmark + sed -i 's/github.com\/pivotal-golang\/bytefmt/code.cloudfoundry.org\/bytefmt/g' s3-benchmark.go + /tmp/go/bin/go mod init github.com/wasabi-tech/s3-benchmark + /tmp/go/bin/go mod tidy + /tmp/go/bin/go build s3-benchmark.go + + for ((i=0;i<${#CLIENT_ARR[@]};++i)); do + ssh -i /etc/cachengo/private.pem cachengo@${CLIENT_ARR[i]} sudo echo "${SERVER_ARR[i]} $GROUPID" >> /etc/hosts + if [[ $string == *":"* ]]; then + scp -i /etc/cachengo/private.pem s3-benchmark cachengo@[${CLIENT_ARR[i]}]:/tmp/s3-benchmark + else + scp -i /etc/cachengo/private.pem s3-benchmark cachengo@${CLIENT_ARR[i]}:/tmp/s3-benchmark + fi + HOSTS="$HOSTS cachengo@${CLIENT_ARR[i]}" + done + + parallel-ssh -O "StrictHostKeyChecking=no" \ + --timeout=0 \ + --host="$HOSTS" \ + -x "-i /etc/cachengo/private.pem" \ + -i "/tmp/s3-benchmark -a "$ACCESS_KEY" -s "$SECRET_KEY" -u http://$GROUPID:9000 -z 10M -t 4 -b `hostname | awk '{print tolower($0)}'` -d 1" + +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + rm -rf /data/dist_minio + sed -i "/$GROUPID/d" /etc/hosts + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac \ No newline at end of file diff --git a/utils/parameters.sh b/utils/parameters.sh index 5e230f5..79ebd1c 100644 --- a/utils/parameters.sh +++ b/utils/parameters.sh @@ -2,10 +2,8 @@ function array_from_json_list { local -n arr=$1 - readarray -td '' arr < <(awk '{ gsub(/, /,"\0"); print; }' <<<"$2, ") - unset 'arr[-1]' - arr=( "${arr[@]##[}" ) - arr=( "${arr[@]##\"}" ) - arr=( "${arr[@]%]}" ) - arr=( "${arr[@]%\"}" ) + echo $2 + while IFS= read -r -d '' item; do + arr+=( "$item" ) + done < <(jq -j '.[] | ((. | sub("\u0000"; "")) + "\u0000")' <<<"$2") } diff --git a/video_object_detection/package.json b/video_object_detection/package.json new file mode 100644 index 0000000..922b7d2 --- /dev/null +++ b/video_object_detection/package.json @@ -0,0 +1,26 @@ +{ + "name": "video_object_detection", + "display_name": "Object Detection Demo", + "description": "Object detection with distributed inferencing. Leader exposes on :5000", + "parameters": [ + { + "name": "LEADER_URL", + "display_name": "Leader URL", + "description": "URL or IP Address where leader node is exposed", + "type": "string", + "required": false + }, + { + "name": "INFERENCE_WORKER", + "display_name": "Inference Worker?", + "description": "Whether to install an inference worker instead of a leader", + "type": "boolean", + "required": false + } + ], + "main": "video_object_detection/run.sh", + "dependencies": [ + "video_object_detection/run.sh", + "utils/cachengo.sh" + ] +} \ No newline at end of file diff --git a/video_object_detection/run.sh b/video_object_detection/run.sh new file mode 100644 index 0000000..d4f36d0 --- /dev/null +++ b/video_object_detection/run.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +source "utils/cachengo.sh" + +NETNAME=$APPID-net +DBNAME=$APPID-postgres +QUEUENAME=$APPID-redis +SERVERNAME=$APPID-server +WORKERNAME=$APPID-worker +INFERENCENAME=$APPID-inference +DATADIR=/data/$APPID + +function do_install { + set -e + cachengo-cli updateInstallStatus $APPID "Installing" + + mkdir -p $DATADIR + docker network create -d bridge $NETNAME + + if [ "$INFERENCE_WORKER" == "false" ]; then + cachengo-cli updateInstallStatus $APPID "Installing: Redis" + docker run -d \ + --name $QUEUENAME \ + --net=$NETNAME \ + --restart unless-stopped \ + -p 6379:6379 \ + redis:alpine; + + cachengo-cli updateInstallStatus $APPID "Installing: Postgres" + docker run -d \ + --name $DBNAME \ + --net $NETNAME \ + --restart unless-stopped \ + -p 5432:5432 \ + -e POSTGRES_PASSWORD=password \ + postgres + + cachengo-cli updateInstallStatus $APPID "Installing: Leader Server" + docker run -d \ + -p 5000:5000 \ + -e CELERY_BROKER_URL=redis://$QUEUENAME:6379 \ + -e CELERY_RESULT_BACKEND=redis://$QUEUENAME:6379 \ + -e CONTAINER_ROLE=server \ + -e DATABASE_URL="postgresql://postgres:password@$DBNAME:5432/postgres" \ + -v $DATADIR:/images \ + --net=$NETNAME \ + --name $SERVERNAME \ + --restart unless-stopped \ + cachengo/video-object-detection:1.0; + + cachengo-cli updateInstallStatus $APPID "Installing: Server Worker" + docker run -d \ + -e CELERY_BROKER_URL=redis://$QUEUENAME:6379 \ + -e CELERY_RESULT_BACKEND=redis://$QUEUENAME:6379 \ + -e CONTAINER_ROLE=server_worker \ + -e DATABASE_URL="postgresql://postgres:password@$DBNAME:5432/postgres" \ + -v $DATADIR:/images \ + --net=$NETNAME \ + --name $WORKERNAME \ + --dns=8.8.8.8 \ + --restart unless-stopped \ + cachengo/video-object-detection:1.0; + else + cachengo-cli updateInstallStatus $APPID "Installing: Inference Worker" + docker run -d \ + --add-host leader:$LEADER_URL \ + --network host \ + --restart unless-stopped \ + -e CELERY_BROKER_URL="redis://leader:6379" \ + -e CELERY_RESULT_BACKEND="redis://leader:6379" \ + -e CONTAINER_ROLE=inference \ + -e LEADER_NODE_URL="http://leader:5000/videos/" \ + -e INFERENCE_MODEL=ssdlite_mobilenet_v2_coco_2018_05_09 \ + -e DATABASE_URL="postgresql://postgres:password@leader:5432/postgres" \ + --name $INFERENCENAME \ + --dns=8.8.8.8 \ + cachengo/video-object-detection:1.0; + fi + + cachengo-cli updateInstallStatus $APPID "Installed" +} + +function do_uninstall { + cachengo-cli updateInstallStatus $APPID "Uninstalling" + docker network rm $NETNAME + docker stop $APPID-postgres + docker rm $APPID-postgres + docker stop $APPID-redis + docker rm $APPID-redis + docker stop $APPID-server + docker rm $APPID-server + docker stop $APPID-worker + docker rm $APPID-worker + docker stop $APPID-inference + docker rm $APPID-inference + rm -rf $DATADIR + cachengo-cli updateInstallStatus $APPID "Uninstalled" +} + + +case "$1" in + install) do_install ;; + uninstall) do_uninstall ;; +esac