#!/usr/bin/env bash # Run larnyx --update to update Docker image args=() tag='latest' docker='docker' port='5002' 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 "rhasspy/larynx:${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 \ -it \ -p "${port}:${port}" \ -e "HOME=${HOME}" \ -v "$HOME:${HOME}" \ -w "${PWD}" \ --user "$(id -u):$(id -g)" "${docker_run_args[@]}" \ "rhasspy/larynx:${tag}" \ "${args[@]}"