Add mimic3-client script
This commit is contained in:
parent
824783b05a
commit
b1bb2b3691
8 changed files with 149 additions and 28 deletions
82
docker/mimic3-client
Executable file
82
docker/mimic3-client
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2022 Mycroft AI Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Run mimic3-client --update to update Docker image
|
||||
|
||||
args=()
|
||||
repo='mycroftai/mimic3'
|
||||
tag='latest'
|
||||
docker='docker'
|
||||
port='59125'
|
||||
|
||||
while [[ -n "$1" ]]; do
|
||||
if [[ "$1" == '--update' ]]; then
|
||||
# Update Docker image
|
||||
update='1'
|
||||
elif [[ "$1" == '--port' ]]; then
|
||||
port="$2"
|
||||
args+=('--port' "${port}")
|
||||
shift 1
|
||||
else
|
||||
args+=("$1")
|
||||
fi
|
||||
|
||||
shift 1
|
||||
done
|
||||
|
||||
if [[ -n "${update}" ]]; then
|
||||
docker pull "${repo}:${tag}"
|
||||
fi
|
||||
|
||||
docker_run_args=()
|
||||
|
||||
if [[ -d /etc/ssl/certs ]]; then
|
||||
# This directory seems to usually have symlinks to other directories
|
||||
docker_run_args+=('-v' '/etc/ssl/certs:/etc/ssl/certs:ro')
|
||||
|
||||
# Create temp file with all certificate directories found
|
||||
cert_dirs_file="$(mktemp)"
|
||||
function finish {
|
||||
rm -rf "${cert_dirs_file}"
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
while read -r cert_path; do
|
||||
# Follow symlinks and record directory paths
|
||||
cert_path="$(readlink -f "${cert_path}")"
|
||||
cert_dir="$(dirname "${cert_path}")"
|
||||
echo $cert_dir >> "${cert_dirs_file}"
|
||||
done < <(find /etc/ssl/certs -name '*.pem' -type l)
|
||||
|
||||
# Map unique certificate directories
|
||||
while read -r cert_dir; do
|
||||
docker_run_args+=('-v' "${cert_dir}:${cert_dir}:ro")
|
||||
done < <(sort < "${cert_dirs_file}" | uniq)
|
||||
fi
|
||||
|
||||
"${docker}" run \
|
||||
-i \
|
||||
--network host \
|
||||
-e "HOME=${HOME}" \
|
||||
-v "$HOME:${HOME}" \
|
||||
-w "${PWD}" \
|
||||
--user "$(id -u):$(id -g)" "${docker_run_args[@]}" \
|
||||
--entrypoint '/home/mimic3/app/.venv/bin/python3' \
|
||||
"${repo}:${tag}" \
|
||||
-m mimic3_http.client \
|
||||
--stdout \
|
||||
"${args[@]}"
|
||||
|
|
@ -73,5 +73,5 @@ fi
|
|||
--user "$(id -u):$(id -g)" "${docker_run_args[@]}" \
|
||||
--entrypoint '/home/mimic3/app/.venv/bin/python3' \
|
||||
"${repo}:${tag}" \
|
||||
-m mimic3_download \
|
||||
-m mimic3_tts.download \
|
||||
"${args[@]}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue