This makes the start and stop scripts compatible with POSIX shells.
Overview of the changes:
- "function" statements removed, not necessary and incompatible
- dashes in function and variable names for lower ones (- to _)
- source statements changed for .
- double square brackets replaced for single ones
- double equal statements replaced for single ones
- &> (piping stdout and stderr to the same file) replaced for 2>&1 >
- sourcing of mycroft-skill-testrunner replaced with direct execution
with Bash
- replaced BASH_SOURCE with $0, these scripts are never sourced anyway
- replaced "echo -n" statements with "printf"
- merged the "" and "all" cases to a single one
* 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>
"stop-mycroft.sh all" stopped the messagebus before the services were
shutdown, causing disconnected errors for the processes and making some
of the shutdown code take longer.
Several minor changes:
* Add mycroft-start and mycroft-stop, which can be used as commands anywhere
if the user has added this to the PATH. They are shortcuts to the
start-mycroft.sh and stop-mycroft.sh scripts.
* Add to the mycroft-help command reference
* Add "reset" parameter for start-mycroft.sh, which forces a service restart.
If a service is currently running, it will not restart by default anymore.
* Make the 'enclosure' service part of 'all' regardless of platform. This
makes sense not that it can handle a remote GUI connection.
* BUG: mycroft-stop would sometimes show odd messages if the skill process
had active child processes.
* 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
Explicitly setting the directory at the beginning of the start-mycroft.sh
and stop-mycroft.sh scripts. The behaves better if invoked from a
different directory.
Previously, the location of the log files changed depending
on whether you were running on a Mark1/Picroft or under a
"Github" install. Now they are always under the same directory
at /var/log/mycroft-*.log
This also updates the CLI to pull from that location always.
Additionally:
* Removed the nonfunctional 'wifi' option from start-mycroft.sh
* Made the validation for dev_setup.sh exit instead of just show
a warning message in start-mycroft.sh
* Added code to allow dev_setup.sh to be run from different
directories successfully
The start-mycroft.sh and stop-mycroft.sh scripts now automatically
run the enclosure client if the platform is defined as
"mycroft_mark_1".
Also corrected a copy/pasted comment and added a clarifying message during the stop when killing a process.
Add stop support for recent 'python3' change
Necessary after #1703
The -r option eliminates the quotes on output
Clean up the usage of jq, -r removes the quotes on output. Also eliminated the python2 support in the regex ```[p]ython[2|3]``` and dropped the unnecessary ```[p]```.
Verify platform file existence before read
It might not exist on a desktop install.
Verify platform file existence before read
This sends a ctrl+c signal to each process which will allow code to exit properly by handling KeyboardInterrupt
Other notable changes:
- create_daemon method used to clean up create daemon threads
- create_echo_function used to reduce code duplication with messagebus
echo functions
- wait_for_exit_signal used to wait for ctrl+c (SIGINT)
- reset_sigint_handler used to ensure SIGINT will raise KeyboardInterrupt
mycroft-core.sh has a relative-path call (that itself also likes to
be called from inside mycroft-core) that prevents making a clean start
of mycroft from outside the mycroft-core directory. This makes doing
things like adding it as a Ubuntu Unity startup application slightly
messy.
Reworking the mechanisms used to interact with Mycroft. The old
mycroft.sh utilized the 'screen' command, but now with the CLI it
it easier to use that for viewing log files. Plus there was
confusion between when to use start.sh and when to use mycroft.sh.
Now things are wrapped in the simple and easily discoverable scripts:
* start-mycroft.sh
* stop-mycroft.sh
The start-mycroft.sh allows you to start the background services and
to invoke the various tools (e.g. the CLI, unit tests, etc).
==== Fixed Issues ====
==== Documentation Notes ====
This will require revamp of the getting started guides, etc.