mycroft-core/start-mycroft.sh

273 lines
7.4 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
2018-08-03 04:34:44 +00:00
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SOURCE="$0"
2018-08-03 04:34:44 +00:00
script=${0}
script=${script##*/}
Shellcheck scripts in root folder (#3090) * Fix Shellcheck: Add -r flag to read read will mangle backslashes without it. These are not expected characters so not explicitly necessary, but also won't hurt. * Fix Shellcheck SC2086: Double quote variables * Fix Shellcheck SC2004: dollar sign unnecessary on arithmetic vars * Fix Shellcheck SC2129: use curly braces to >> file * Disable shellcheck on sourced venv/bin/activate * Fix Shellcheck SC1004 Simplify sed-expression to be a single line only removing the need for the offending / and linefeed * Fix Shellcheck SC2046 when finding repo root Splits the check into to files to be able to quote the expressions in a good way. * Fix Shellcheck SC2086 Unquoted apt packagaes This converts the variable APT_PACKAGE_LIST from a string to an array. This is a safer way to handle arguments according to BashFAQ (http://mywiki.wooledge.org/BashFAQ/050) * Fix Shellcheck SC2230 by changing which to command -v * CICD: Activate shellcheck job for dev_setup.sh * Shellcheck start-mycroft.sh This fixes the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... - https://www.shellcheck.net/wiki/SC2124 -- Assigning an array to a string! A... The command is added to the CICD run of shellcheck * Shellcheck stop-mycroft.sh Fixes the following issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... The file is now automatically checked by the CICD job * Shellcheck venv-activate.sh Fix the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... - https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... - https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... - https://www.shellcheck.net/wiki/SC2139 -- This expands when defined, not wh... - https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ... The help for invalid arg now works when the faulty argument isn't the first argument Co-authored-by: Kris Gesling <kris.gesling@mycroft.ai>
2022-04-07 04:51:26 +00:00
cd -P "$( dirname "$SOURCE" )" || exit 1 # Enter scripts folder or fail!
DIR="$( pwd )"
2018-08-03 04:34:44 +00:00
VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${DIR}/.venv"}
help() {
2018-08-03 04:34:44 +00:00
echo "${script}: Mycroft command/service launcher"
echo "usage: ${script} [COMMAND] [restart] [params]"
2018-08-03 04:34:44 +00:00
echo
echo "Services COMMANDs:"
2018-08-03 04:34:44 +00:00
echo " all runs core services: bus, audio, skills, voice"
echo " debug runs core services, then starts the CLI"
echo " audio the audio playback service"
echo " bus the messagebus service"
echo " skills the skill service"
echo " voice voice capture service"
# echo " wifi wifi setup service"
echo " enclosure mark_1 enclosure service"
echo
echo "Tool COMMANDs:"
2018-08-03 04:34:44 +00:00
echo " cli the Command Line Interface"
echo " unittest run mycroft-core unit tests (requires pytest)"
echo " skillstest run the skill autotests for all skills (requires pytest)"
echo " vktest run the Voight Kampff integration test suite"
2018-08-03 04:34:44 +00:00
echo
echo "Util COMMANDs:"
2018-08-03 04:34:44 +00:00
echo " audiotest attempt simple audio validation"
echo " wakewordtest test selected wakeword engine"
2018-08-03 04:34:44 +00:00
echo " sdkdoc generate sdk documentation"
echo
echo "Options:"
echo " restart (optional) Force the service to restart if running"
echo
2018-08-03 04:34:44 +00:00
echo "Examples:"
echo " ${script} all"
echo " ${script} all restart"
2018-08-03 04:34:44 +00:00
echo " ${script} cli"
echo " ${script} unittest"
exit 1
}
_module=""
name_to_script_path() {
2018-08-03 04:34:44 +00:00
case ${1} in
"bus") _module="mycroft.messagebus.service" ;;
"skills") _module="mycroft.skills" ;;
"audio") _module="mycroft.audio" ;;
"voice") _module="mycroft.client.speech" ;;
"cli") _module="mycroft.client.text" ;;
"audiotest") _module="mycroft.util.audio_test" ;;
"wakewordtest") _module="test.wake_word" ;;
"enclosure") _module="mycroft.client.enclosure" ;;
2018-08-03 04:34:44 +00:00
*)
echo "Error: Unknown name '${1}'"
exit 1
esac
}
source_venv() {
2018-08-03 04:34:44 +00:00
# Enter Python virtual environment, unless under Docker
if [ ! -f "/.dockerenv" ] ; then
. "${VIRTUALENV_ROOT}/bin/activate"
2018-08-03 04:34:44 +00:00
fi
}
first_time=true
init_once() {
2018-08-03 04:34:44 +00:00
if ($first_time) ; then
echo "Initializing..."
Unify the command line experience across platforms (#1784) * Unify the command line experience across platforms Interacting with Mycroft was slightly different on different platforms (Mark 1, Github, Picroft), which resulted in confusion and the beginnings of a documentation/support nightmare. This moves several of the common commands into a mycroft-core/bin folder instead of being build in packaging or part of the Picroft package only. This required a small changes to the common scripts, in addition to adding the new scripts. Here are details: * dev_setup.sh - Stubbed out a setup wizard (TODO) - Jumped to latest version of pip (18.0) - Set execution flags for new scripts * start-mycroft.sh - Allow auto-execution of dev_setup.sh - De-sourced the stop-mycroft.sh calls (not needed) - Add quotes to better handle paths with spaces * stop-mycroft.sh - Return exit code to show if a service was stopped or killed - Extend the time to wait for a gently shutdown from 2 secs to 5 - Changed to say "messagebus.service" instead of just "service" to be more clear (the name "service" means nothing to users, but "bus does") * venv-activate.sh - Added help - Added -q or --quiet mode - Added toggled availability of 'mycroft-venv-activate' and 'mycroft-venv-deactivate' aliases. Only one is available at any given time. New scripts: * mycroft-cli-client: start up the CLI * mycroft-help: shows hints on using mycroft * mycroft-mic-test: runs the basic record/playback, playing nicely with a running Mycroft by stopping and restarting services as appropriate * mycroft-pip: manage the venv via pip * mycroft-say-to: send utterances, like a user spoke them * mycroft-speak: speaks the given phrase using Mycroft * mycroft-skill-testrunner: invoke the single-skill test runner All of these scripts are easy to discover by typing "mycroft-" then hitting the TAB key. ==== INSTALLER NOTES ==== * We no longer need to create mycroft-cli-client and mycroft-pip in the Debian packages. * mycroft-core/bin should be added to the path * Corrections after review Several minor corrections, plus added wrappers for the 'msm' and 'msk' utilities. * Set executable flag on script files in bin/ The scripts in the bin/ folder needed to be changed to executable within git to prevent looking dirty after dev_setup.sh has been run. * Add executable flag to one more script
2018-09-09 21:55:01 +00:00
"${DIR}/scripts/prepare-msm.sh"
source_venv
2018-08-03 04:34:44 +00:00
first_time=false
fi
}
launch_process() {
init_once
2018-08-03 04:34:44 +00:00
name_to_script_path "${1}"
2018-08-03 04:34:44 +00:00
# Launch process in foreground
echo "Starting $1"
Shellcheck scripts in root folder (#3090) * Fix Shellcheck: Add -r flag to read read will mangle backslashes without it. These are not expected characters so not explicitly necessary, but also won't hurt. * Fix Shellcheck SC2086: Double quote variables * Fix Shellcheck SC2004: dollar sign unnecessary on arithmetic vars * Fix Shellcheck SC2129: use curly braces to >> file * Disable shellcheck on sourced venv/bin/activate * Fix Shellcheck SC1004 Simplify sed-expression to be a single line only removing the need for the offending / and linefeed * Fix Shellcheck SC2046 when finding repo root Splits the check into to files to be able to quote the expressions in a good way. * Fix Shellcheck SC2086 Unquoted apt packagaes This converts the variable APT_PACKAGE_LIST from a string to an array. This is a safer way to handle arguments according to BashFAQ (http://mywiki.wooledge.org/BashFAQ/050) * Fix Shellcheck SC2230 by changing which to command -v * CICD: Activate shellcheck job for dev_setup.sh * Shellcheck start-mycroft.sh This fixes the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... - https://www.shellcheck.net/wiki/SC2124 -- Assigning an array to a string! A... The command is added to the CICD run of shellcheck * Shellcheck stop-mycroft.sh Fixes the following issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... The file is now automatically checked by the CICD job * Shellcheck venv-activate.sh Fix the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... - https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... - https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... - https://www.shellcheck.net/wiki/SC2139 -- This expands when defined, not wh... - https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ... The help for invalid arg now works when the faulty argument isn't the first argument Co-authored-by: Kris Gesling <kris.gesling@mycroft.ai>
2022-04-07 04:51:26 +00:00
python3 -m ${_module} "$@"
2018-08-03 04:34:44 +00:00
}
require_process() {
# Launch process if not found
name_to_script_path "${1}"
2020-01-09 21:23:08 +00:00
if ! pgrep -f "python3 (.*)-m ${_module}" > /dev/null ; then
# Start required process
launch_background "${1}"
2018-08-03 04:34:44 +00:00
fi
}
launch_background() {
init_once
2018-08-03 04:34:44 +00:00
Unify the command line experience across platforms (#1784) * Unify the command line experience across platforms Interacting with Mycroft was slightly different on different platforms (Mark 1, Github, Picroft), which resulted in confusion and the beginnings of a documentation/support nightmare. This moves several of the common commands into a mycroft-core/bin folder instead of being build in packaging or part of the Picroft package only. This required a small changes to the common scripts, in addition to adding the new scripts. Here are details: * dev_setup.sh - Stubbed out a setup wizard (TODO) - Jumped to latest version of pip (18.0) - Set execution flags for new scripts * start-mycroft.sh - Allow auto-execution of dev_setup.sh - De-sourced the stop-mycroft.sh calls (not needed) - Add quotes to better handle paths with spaces * stop-mycroft.sh - Return exit code to show if a service was stopped or killed - Extend the time to wait for a gently shutdown from 2 secs to 5 - Changed to say "messagebus.service" instead of just "service" to be more clear (the name "service" means nothing to users, but "bus does") * venv-activate.sh - Added help - Added -q or --quiet mode - Added toggled availability of 'mycroft-venv-activate' and 'mycroft-venv-deactivate' aliases. Only one is available at any given time. New scripts: * mycroft-cli-client: start up the CLI * mycroft-help: shows hints on using mycroft * mycroft-mic-test: runs the basic record/playback, playing nicely with a running Mycroft by stopping and restarting services as appropriate * mycroft-pip: manage the venv via pip * mycroft-say-to: send utterances, like a user spoke them * mycroft-speak: speaks the given phrase using Mycroft * mycroft-skill-testrunner: invoke the single-skill test runner All of these scripts are easy to discover by typing "mycroft-" then hitting the TAB key. ==== INSTALLER NOTES ==== * We no longer need to create mycroft-cli-client and mycroft-pip in the Debian packages. * mycroft-core/bin should be added to the path * Corrections after review Several minor corrections, plus added wrappers for the 'msm' and 'msk' utilities. * Set executable flag on script files in bin/ The scripts in the bin/ folder needed to be changed to executable within git to prevent looking dirty after dev_setup.sh has been run. * Add executable flag to one more script
2018-09-09 21:55:01 +00:00
# Check if given module is running and start (or restart if running)
name_to_script_path "${1}"
2020-01-09 21:23:08 +00:00
if pgrep -f "python3 (.*)-m ${_module}" > /dev/null ; then
if ($_force_restart) ; then
echo "Restarting: ${1}"
Shellcheck scripts in root folder (#3090) * Fix Shellcheck: Add -r flag to read read will mangle backslashes without it. These are not expected characters so not explicitly necessary, but also won't hurt. * Fix Shellcheck SC2086: Double quote variables * Fix Shellcheck SC2004: dollar sign unnecessary on arithmetic vars * Fix Shellcheck SC2129: use curly braces to >> file * Disable shellcheck on sourced venv/bin/activate * Fix Shellcheck SC1004 Simplify sed-expression to be a single line only removing the need for the offending / and linefeed * Fix Shellcheck SC2046 when finding repo root Splits the check into to files to be able to quote the expressions in a good way. * Fix Shellcheck SC2086 Unquoted apt packagaes This converts the variable APT_PACKAGE_LIST from a string to an array. This is a safer way to handle arguments according to BashFAQ (http://mywiki.wooledge.org/BashFAQ/050) * Fix Shellcheck SC2230 by changing which to command -v * CICD: Activate shellcheck job for dev_setup.sh * Shellcheck start-mycroft.sh This fixes the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... - https://www.shellcheck.net/wiki/SC2124 -- Assigning an array to a string! A... The command is added to the CICD run of shellcheck * Shellcheck stop-mycroft.sh Fixes the following issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... The file is now automatically checked by the CICD job * Shellcheck venv-activate.sh Fix the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... - https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... - https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... - https://www.shellcheck.net/wiki/SC2139 -- This expands when defined, not wh... - https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ... The help for invalid arg now works when the faulty argument isn't the first argument Co-authored-by: Kris Gesling <kris.gesling@mycroft.ai>
2022-04-07 04:51:26 +00:00
"${DIR}/stop-mycroft.sh" "${1}"
else
# Already running, no need to restart
return
fi
2018-08-03 04:34:44 +00:00
else
echo "Starting background service $1"
fi
# Security warning/reminder for the user
if [ "${1}" = "bus" ] ; then
2018-08-03 04:34:44 +00:00
echo "CAUTION: The Mycroft bus is an open websocket with no built-in security"
echo " measures. You are responsible for protecting the local port"
echo " 8181 with a firewall as appropriate."
fi
# Launch process in background, sending logs to standard location
Shellcheck scripts in root folder (#3090) * Fix Shellcheck: Add -r flag to read read will mangle backslashes without it. These are not expected characters so not explicitly necessary, but also won't hurt. * Fix Shellcheck SC2086: Double quote variables * Fix Shellcheck SC2004: dollar sign unnecessary on arithmetic vars * Fix Shellcheck SC2129: use curly braces to >> file * Disable shellcheck on sourced venv/bin/activate * Fix Shellcheck SC1004 Simplify sed-expression to be a single line only removing the need for the offending / and linefeed * Fix Shellcheck SC2046 when finding repo root Splits the check into to files to be able to quote the expressions in a good way. * Fix Shellcheck SC2086 Unquoted apt packagaes This converts the variable APT_PACKAGE_LIST from a string to an array. This is a safer way to handle arguments according to BashFAQ (http://mywiki.wooledge.org/BashFAQ/050) * Fix Shellcheck SC2230 by changing which to command -v * CICD: Activate shellcheck job for dev_setup.sh * Shellcheck start-mycroft.sh This fixes the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... - https://www.shellcheck.net/wiki/SC2124 -- Assigning an array to a string! A... The command is added to the CICD run of shellcheck * Shellcheck stop-mycroft.sh Fixes the following issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... The file is now automatically checked by the CICD job * Shellcheck venv-activate.sh Fix the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... - https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... - https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... - https://www.shellcheck.net/wiki/SC2139 -- This expands when defined, not wh... - https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ... The help for invalid arg now works when the faulty argument isn't the first argument Co-authored-by: Kris Gesling <kris.gesling@mycroft.ai>
2022-04-07 04:51:26 +00:00
python3 -m ${_module} "$@" >> "/var/log/mycroft/${1}.log" 2>&1 &
2018-08-03 04:34:44 +00:00
}
launch_all() {
2018-08-03 04:34:44 +00:00
echo "Starting all mycroft-core services"
launch_background bus
launch_background skills
launch_background audio
launch_background voice
launch_background enclosure
2018-08-03 04:34:44 +00:00
}
check_dependencies() {
if [ -f .dev_opts.json ] ; then
auto_update=$( jq -r ".auto_update" < .dev_opts.json 2> /dev/null)
else
auto_update="false"
fi
if [ "$auto_update" = "true" ] ; then
# Check github repo for updates (e.g. a new release)
git pull
fi
if [ ! -f .installed ] || ! md5sum -c > /dev/null 2>&1 < .installed ; then
Unify the command line experience across platforms (#1784) * Unify the command line experience across platforms Interacting with Mycroft was slightly different on different platforms (Mark 1, Github, Picroft), which resulted in confusion and the beginnings of a documentation/support nightmare. This moves several of the common commands into a mycroft-core/bin folder instead of being build in packaging or part of the Picroft package only. This required a small changes to the common scripts, in addition to adding the new scripts. Here are details: * dev_setup.sh - Stubbed out a setup wizard (TODO) - Jumped to latest version of pip (18.0) - Set execution flags for new scripts * start-mycroft.sh - Allow auto-execution of dev_setup.sh - De-sourced the stop-mycroft.sh calls (not needed) - Add quotes to better handle paths with spaces * stop-mycroft.sh - Return exit code to show if a service was stopped or killed - Extend the time to wait for a gently shutdown from 2 secs to 5 - Changed to say "messagebus.service" instead of just "service" to be more clear (the name "service" means nothing to users, but "bus does") * venv-activate.sh - Added help - Added -q or --quiet mode - Added toggled availability of 'mycroft-venv-activate' and 'mycroft-venv-deactivate' aliases. Only one is available at any given time. New scripts: * mycroft-cli-client: start up the CLI * mycroft-help: shows hints on using mycroft * mycroft-mic-test: runs the basic record/playback, playing nicely with a running Mycroft by stopping and restarting services as appropriate * mycroft-pip: manage the venv via pip * mycroft-say-to: send utterances, like a user spoke them * mycroft-speak: speaks the given phrase using Mycroft * mycroft-skill-testrunner: invoke the single-skill test runner All of these scripts are easy to discover by typing "mycroft-" then hitting the TAB key. ==== INSTALLER NOTES ==== * We no longer need to create mycroft-cli-client and mycroft-pip in the Debian packages. * mycroft-core/bin should be added to the path * Corrections after review Several minor corrections, plus added wrappers for the 'msm' and 'msk' utilities. * Set executable flag on script files in bin/ The scripts in the bin/ folder needed to be changed to executable within git to prevent looking dirty after dev_setup.sh has been run. * Add executable flag to one more script
2018-09-09 21:55:01 +00:00
# Critical files have changed, dev_setup.sh should be run again
if [ "$auto_update" = "true" ] ; then
echo "Updating dependencies..."
Unify the command line experience across platforms (#1784) * Unify the command line experience across platforms Interacting with Mycroft was slightly different on different platforms (Mark 1, Github, Picroft), which resulted in confusion and the beginnings of a documentation/support nightmare. This moves several of the common commands into a mycroft-core/bin folder instead of being build in packaging or part of the Picroft package only. This required a small changes to the common scripts, in addition to adding the new scripts. Here are details: * dev_setup.sh - Stubbed out a setup wizard (TODO) - Jumped to latest version of pip (18.0) - Set execution flags for new scripts * start-mycroft.sh - Allow auto-execution of dev_setup.sh - De-sourced the stop-mycroft.sh calls (not needed) - Add quotes to better handle paths with spaces * stop-mycroft.sh - Return exit code to show if a service was stopped or killed - Extend the time to wait for a gently shutdown from 2 secs to 5 - Changed to say "messagebus.service" instead of just "service" to be more clear (the name "service" means nothing to users, but "bus does") * venv-activate.sh - Added help - Added -q or --quiet mode - Added toggled availability of 'mycroft-venv-activate' and 'mycroft-venv-deactivate' aliases. Only one is available at any given time. New scripts: * mycroft-cli-client: start up the CLI * mycroft-help: shows hints on using mycroft * mycroft-mic-test: runs the basic record/playback, playing nicely with a running Mycroft by stopping and restarting services as appropriate * mycroft-pip: manage the venv via pip * mycroft-say-to: send utterances, like a user spoke them * mycroft-speak: speaks the given phrase using Mycroft * mycroft-skill-testrunner: invoke the single-skill test runner All of these scripts are easy to discover by typing "mycroft-" then hitting the TAB key. ==== INSTALLER NOTES ==== * We no longer need to create mycroft-cli-client and mycroft-pip in the Debian packages. * mycroft-core/bin should be added to the path * Corrections after review Several minor corrections, plus added wrappers for the 'msm' and 'msk' utilities. * Set executable flag on script files in bin/ The scripts in the bin/ folder needed to be changed to executable within git to prevent looking dirty after dev_setup.sh has been run. * Add executable flag to one more script
2018-09-09 21:55:01 +00:00
bash dev_setup.sh
else
echo "Please update dependencies by running ./dev_setup.sh again."
if command -v notify-send >/dev/null ; then
# Generate a desktop notification (ArchLinux)
notify-send "Mycroft Dependencies Outdated" "Run ./dev_setup.sh again"
fi
exit 1
fi
2018-08-03 04:34:44 +00:00
fi
}
_opt=$1
_force_restart=false
if [ $# -eq 0 ]; then
help
return
fi
2018-08-03 04:34:44 +00:00
shift
if [ "${1}" = "restart" ] || [ "${_opt}" = "restart" ] ; then
_force_restart=true
if [ "${_opt}" = "restart" ] ; then
# Support "start-mycroft.sh restart all" as well as "start-mycroft.sh all restart"
_opt=$1
fi
if [ $# -gt 0 ]; then
shift
fi
fi
Shellcheck scripts in root folder (#3090) * Fix Shellcheck: Add -r flag to read read will mangle backslashes without it. These are not expected characters so not explicitly necessary, but also won't hurt. * Fix Shellcheck SC2086: Double quote variables * Fix Shellcheck SC2004: dollar sign unnecessary on arithmetic vars * Fix Shellcheck SC2129: use curly braces to >> file * Disable shellcheck on sourced venv/bin/activate * Fix Shellcheck SC1004 Simplify sed-expression to be a single line only removing the need for the offending / and linefeed * Fix Shellcheck SC2046 when finding repo root Splits the check into to files to be able to quote the expressions in a good way. * Fix Shellcheck SC2086 Unquoted apt packagaes This converts the variable APT_PACKAGE_LIST from a string to an array. This is a safer way to handle arguments according to BashFAQ (http://mywiki.wooledge.org/BashFAQ/050) * Fix Shellcheck SC2230 by changing which to command -v * CICD: Activate shellcheck job for dev_setup.sh * Shellcheck start-mycroft.sh This fixes the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... - https://www.shellcheck.net/wiki/SC2124 -- Assigning an array to a string! A... The command is added to the CICD run of shellcheck * Shellcheck stop-mycroft.sh Fixes the following issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... The file is now automatically checked by the CICD job * Shellcheck venv-activate.sh Fix the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... - https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... - https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... - https://www.shellcheck.net/wiki/SC2139 -- This expands when defined, not wh... - https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ... The help for invalid arg now works when the faulty argument isn't the first argument Co-authored-by: Kris Gesling <kris.gesling@mycroft.ai>
2022-04-07 04:51:26 +00:00
if [ ! "${_opt}" = "cli" ] ; then
check_dependencies
2020-10-06 22:13:21 +00:00
fi
2018-08-03 04:34:44 +00:00
case ${_opt} in
"all")
launch_all
2018-08-03 04:34:44 +00:00
;;
"bus")
launch_background "${_opt}"
2018-08-03 04:34:44 +00:00
;;
"audio")
launch_background "${_opt}"
2018-08-03 04:34:44 +00:00
;;
"skills")
launch_background "${_opt}"
2018-08-03 04:34:44 +00:00
;;
"voice")
launch_background "${_opt}"
2018-08-03 04:34:44 +00:00
;;
"debug")
launch_all
launch_process cli
2018-08-03 04:34:44 +00:00
;;
"cli")
require_process bus
require_process skills
launch_process "${_opt}"
2018-08-03 04:34:44 +00:00
;;
# TODO: Restore support for Wifi Setup on a Picroft, etc.
# "wifi")
# launch_background ${_opt}
2018-08-03 04:34:44 +00:00
# ;;
"unittest")
source_venv
2018-08-03 04:34:44 +00:00
pytest test/unittests/ --cov=mycroft "$@"
;;
"singleunittest")
source_venv
pytest "$@"
;;
2018-08-03 04:34:44 +00:00
"skillstest")
source_venv
2018-08-03 04:34:44 +00:00
pytest test/integrationtests/skills/discover_tests.py "$@"
;;
"vktest")
"$DIR/bin/mycroft-skill-testrunner" vktest "$@"
;;
2018-08-03 04:34:44 +00:00
"audiotest")
launch_process "${_opt}"
2018-08-03 04:34:44 +00:00
;;
"wakewordtest")
launch_process "${_opt}"
2018-08-03 04:34:44 +00:00
;;
"sdkdoc")
source_venv
Shellcheck scripts in root folder (#3090) * Fix Shellcheck: Add -r flag to read read will mangle backslashes without it. These are not expected characters so not explicitly necessary, but also won't hurt. * Fix Shellcheck SC2086: Double quote variables * Fix Shellcheck SC2004: dollar sign unnecessary on arithmetic vars * Fix Shellcheck SC2129: use curly braces to >> file * Disable shellcheck on sourced venv/bin/activate * Fix Shellcheck SC1004 Simplify sed-expression to be a single line only removing the need for the offending / and linefeed * Fix Shellcheck SC2046 when finding repo root Splits the check into to files to be able to quote the expressions in a good way. * Fix Shellcheck SC2086 Unquoted apt packagaes This converts the variable APT_PACKAGE_LIST from a string to an array. This is a safer way to handle arguments according to BashFAQ (http://mywiki.wooledge.org/BashFAQ/050) * Fix Shellcheck SC2230 by changing which to command -v * CICD: Activate shellcheck job for dev_setup.sh * Shellcheck start-mycroft.sh This fixes the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... - https://www.shellcheck.net/wiki/SC2124 -- Assigning an array to a string! A... The command is added to the CICD run of shellcheck * Shellcheck stop-mycroft.sh Fixes the following issues: - https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |... - https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... The file is now automatically checked by the CICD job * Shellcheck venv-activate.sh Fix the following shellcheck issues: - https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... - https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... - https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind... - https://www.shellcheck.net/wiki/SC2139 -- This expands when defined, not wh... - https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ... The help for invalid arg now works when the faulty argument isn't the first argument Co-authored-by: Kris Gesling <kris.gesling@mycroft.ai>
2022-04-07 04:51:26 +00:00
cd doc || exit 1 # Exit if doc directory doesn't exist
make "$@"
cd ..
2018-08-03 04:34:44 +00:00
;;
"enclosure")
launch_background "${_opt}"
2018-08-03 04:34:44 +00:00
;;
*)
help
;;
esac