Shellcheck scripts folder (#3063)
* Remove unused scripts install-pocketsphinx and install-pygtk is no longer used by the dev-setup. * Fix shellcheck issues in scripts * Remove space in cores argument * Update my-info.sh script - Make it use the new method to activate venv if needed - Improve requirements.txt parsing - Update process detection from old "screen" setup - Update log-files paths - Fix finding mycroft-core folder * Fix shellcheck issues in mycroft-use.sh Mainly quoting but also unpacking of arguments and improving some if statements * Update shellcheck test to include scripts folderpull/3081/head
parent
df0b8fe212
commit
dd7f7abba6
|
|
@ -72,8 +72,9 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Shell check mycroft tools
|
||||
uses: ludeeus/action-shellcheck@ceeca77f6538b97991ca2c2a2ebe1ab64e573b5e
|
||||
uses: ludeeus/action-shellcheck@203a3fd018dfe73f8ae7e3aa8da2c149a5f41c33
|
||||
env:
|
||||
SHELLCHECK_OPTS: -x
|
||||
with:
|
||||
scandir: ./bin
|
||||
ignore_names: 'dev_setup.sh start-mycroft.sh stop-mycroft.sh venv-activate.sh run_test_suite.sh'
|
||||
# ignore_paths: doc mycroft test requirements
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ cd "$TOP"
|
|||
|
||||
if [[ $build_mimic == 'y' || $build_mimic == 'Y' ]] ; then
|
||||
echo 'WARNING: The following can take a long time to run!'
|
||||
"${TOP}/scripts/install-mimic.sh" " $CORES"
|
||||
"${TOP}/scripts/install-mimic.sh" "$CORES"
|
||||
else
|
||||
echo 'Skipping mimic build.'
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ if [ ! -d ${MIMIC_DIR} ] ; then
|
|||
cd ${MIMIC_DIR}
|
||||
./autogen.sh
|
||||
./configure --with-audio=alsa --enable-shared --prefix="$(pwd)"
|
||||
make -j${CORES}
|
||||
make -j"${CORES}"
|
||||
make install
|
||||
else
|
||||
# ensure mimic is up to date
|
||||
|
|
@ -43,6 +43,6 @@ else
|
|||
./autogen.sh
|
||||
./configure --with-audio=alsa --enable-shared --prefix="$(pwd)"
|
||||
make clean
|
||||
make -j${CORES}
|
||||
make -j"${CORES}"
|
||||
make install
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# 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.
|
||||
|
||||
# exit on any error
|
||||
set -Ee
|
||||
|
||||
#TOP="."
|
||||
|
||||
|
||||
function enable_local() {
|
||||
sed -i 's/from pocketsphinx.pocketsphinx import Decoder/from pocketsphinx import Decoder/g' mycroft/client/speech/local_recognizer.py
|
||||
}
|
||||
|
||||
function disable_local() {
|
||||
sed -i 's/from pocketsphinx import Decoder/from pocketsphinx.pocketsphinx import Decoder/g' mycroft/client/speech/local_recognizer.py
|
||||
}
|
||||
|
||||
function install_pocketsphinx() {
|
||||
# clone pocketsphinx-python at HEAD (fix to a constant version later)
|
||||
if [ ! -d ${TOP}/pocketsphinx-python ] ; then
|
||||
# build sphinxbase and pocketsphinx if we haven't already
|
||||
git clone --recursive https://github.com/cmusphinx/pocketsphinx-python
|
||||
pushd ./pocketsphinx-python/sphinxbase
|
||||
./autogen.sh
|
||||
./configure
|
||||
make -j$CORES
|
||||
popd
|
||||
pushd ./pocketsphinx-python/pocketsphinx
|
||||
./autogen.sh
|
||||
./configure
|
||||
make -j$CORES
|
||||
popd
|
||||
fi
|
||||
|
||||
# build and install pocketsphinx python bindings
|
||||
cd ${TOP}/pocketsphinx-python
|
||||
python setup.py install
|
||||
}
|
||||
|
||||
if [ "$1" = "-q" ] ; then
|
||||
enable_local
|
||||
install_pocketsphinx
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "This script will checkout, compile, and install pocketsphinx locally if the debian package python-pocketsphinx is not available"
|
||||
|
||||
PS3='Please enter your choice: '
|
||||
options=("Enable local checkout, compile and install" "Disable local checkout and exit" "Do nothing and quit")
|
||||
select opt in "${options[@]}" ; do
|
||||
case $opt in
|
||||
"Enable local checkout, compile and install")
|
||||
echo "you chose choice 1"
|
||||
enable_local
|
||||
install_pocketsphinx
|
||||
;;
|
||||
"Disable local checkout and exit")
|
||||
echo "you chose choice 2"
|
||||
disable_local
|
||||
exit 0
|
||||
;;
|
||||
"Do nothing and quit")
|
||||
echo "you chose choice 3"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo invalid option
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# 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.
|
||||
|
||||
# Ensure we're in a virtualenv.
|
||||
if [ "$VIRTUAL_ENV" == "" ] ; then
|
||||
echo "ERROR: not in a virtual environment."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Setup variables.
|
||||
CACHE="/tmp/install-pygtk-$$"
|
||||
CORES=$1
|
||||
|
||||
# Make temp directory.
|
||||
mkdir -p $CACHE
|
||||
|
||||
# Test for py2cairo.
|
||||
echo -e "\E[1m * Checking for cairo...\E[0m"
|
||||
python -c "
|
||||
try: import cairo; raise SystemExit(0)
|
||||
except ImportError: raise SystemExit(-1)"
|
||||
|
||||
if [ $? == 255 ] ; then
|
||||
echo -e "\E[1m * Installing cairo...\E[0m"
|
||||
# Fetch, build, and install py2cairo.
|
||||
( cd $CACHE
|
||||
curl 'https://www.cairographics.org/releases/py2cairo-1.10.0.tar.bz2' > "py2cairo.tar.bz2"
|
||||
tar -xvf py2cairo.tar.bz2
|
||||
( cd py2cairo-*
|
||||
autoreconf -ivf
|
||||
./configure --prefix=$VIRTUAL_ENV --disable-dependency-tracking
|
||||
make -j${CORES}
|
||||
make install
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
||||
# Test for gobject.
|
||||
echo -e "\E[1m * Checking for gobject...\E[0m"
|
||||
python -c "
|
||||
try: import gobject; raise SystemExit(0)
|
||||
except ImportError: raise SystemExit(-1)"
|
||||
|
||||
if [ $? == 255 ] ; then
|
||||
echo -e "\E[1m * Installing gobject...\E[0m"
|
||||
# Fetch, build, and install gobject.
|
||||
( cd $CACHE
|
||||
curl 'http://ftp.gnome.org/pub/GNOME/sources/pygobject/2.28/pygobject-2.28.6.tar.bz2' > 'pygobject.tar.bz2'
|
||||
tar -xvf pygobject.tar.bz2
|
||||
( cd pygobject-*
|
||||
./configure --prefix=$VIRTUAL_ENV --disable-introspection
|
||||
make -j${CORES}
|
||||
make install
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
||||
# Test for gtk.
|
||||
echo -e "\E[1m * Checking for gtk...\E[0m"
|
||||
python -c "
|
||||
try: import gtk; raise SystemExit(0)
|
||||
except ImportError: raise SystemExit(-1)" 2&> /dev/null
|
||||
|
||||
if [ $? == 255 ] ; then
|
||||
echo -e "\E[1m * Installing gtk...\E[0m"
|
||||
# Fetch, build, and install gtk.
|
||||
( cd $CACHE
|
||||
curl -L 'https://files.pythonhosted.org/packages/source/P/PyGTK/pygtk-2.24.0.tar.bz2' > 'pygtk.tar.bz2'
|
||||
tar -xvf pygtk.tar.bz2
|
||||
( cd pygtk-*
|
||||
./configure --prefix=$VIRTUAL_ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$VIRTUAL_ENV/lib/pkgconfig
|
||||
make -j${CORES}
|
||||
make install
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
|
@ -41,7 +41,6 @@ fi
|
|||
|
||||
MYCROFT_HOME=""
|
||||
RUN_AS_ROOT=1
|
||||
source $( locate virtualenvwrapper.sh )
|
||||
|
||||
# log stuff and things
|
||||
LOG_FILE=/tmp/my-info.$$.out
|
||||
|
|
@ -56,7 +55,8 @@ fi
|
|||
|
||||
# it's big, it's heavy, it's wood!
|
||||
function mlog() {
|
||||
local timestamp="[$( date +"%Y-%m-%d %H:%M:%S" )]"
|
||||
local timestamp
|
||||
timestamp="[$( date +"%Y-%m-%d %H:%M:%S" )]"
|
||||
message="$*"
|
||||
echo "${timestamp} ${message}" |tee -a ${LOG_FILE}
|
||||
}
|
||||
|
|
@ -87,18 +87,26 @@ fi
|
|||
echo "If you can read this, we may need glasses."
|
||||
}
|
||||
|
||||
|
||||
function list_log_files() {
|
||||
for logfile in "/var/log/mycroft/"*.log; do
|
||||
echo "$logfile"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Check before we wreck:
|
||||
function checkfiles() {
|
||||
mlog "Permission checks..."
|
||||
cat << EOF > /tmp/my-list.$$
|
||||
${MYCROFT_HOME}
|
||||
${MYCROFT_HOME}/scripts/logs
|
||||
$(list_log_files)
|
||||
/tmp/mycroft/
|
||||
/opt/mycroft/skills
|
||||
EOF
|
||||
|
||||
if [[ ${RUN_AS_ROOT} -eq 1 ]] ; then
|
||||
while read CHECKFN ; do
|
||||
while read -r CHECKFN ; do
|
||||
checkperms "${CHECKFN}"
|
||||
case $? in
|
||||
"0") mlog " - ${CHECKFN} has viable permissions." ;;
|
||||
|
|
@ -127,7 +135,7 @@ function checksysinfo() {
|
|||
|
||||
# -v
|
||||
function checkversion() {
|
||||
mlog "Mycroft version is $( grep -B3 'END_VERSION_BLOCK' ${MYCROFT_HOME}/mycroft/version/__init__.py | cut -d' ' -f3 | tr -s '\012' '\056' )"
|
||||
mlog "Mycroft version is $( grep -B3 'END_VERSION_BLOCK' "${MYCROFT_HOME}/mycroft/version/__init__.py" | cut -d' ' -f3 | tr -s '\012' '\056' )"
|
||||
}
|
||||
|
||||
# do you want to do repeat?
|
||||
|
|
@ -143,20 +151,38 @@ function checkmimic() {
|
|||
|
||||
# pythoning!
|
||||
function checkPIP() {
|
||||
REQUIREMENTS_FILE="${MYCROFT_HOME}/requirements/requirements.txt"
|
||||
VENV_ACTIVATE_SCRIPT="${MYCROFT_HOME}/venv-activate.sh"
|
||||
mlog "Python checks"
|
||||
mlog " - Verifying ${MYCROFT_HOME}/requirements/requirements.txt:"
|
||||
if workon mycroft ; then
|
||||
mlog " - Verifying $REQUIREMENTS_FILE:"
|
||||
if [[ -f "$VENV_ACTIVATE_SCRIPT" ]] ; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$VENV_ACTIVATE_SCRIPT"
|
||||
pip list > /tmp/mycroft-piplist.$$
|
||||
|
||||
while read reqline ; do
|
||||
IFS='==' read -r -a PIPREQ <<< "$reqline"
|
||||
PIPREQVER=$( grep -i ^"${PIPREQ[0]} " /tmp/mycroft-piplist.$$ | cut -d'(' -f2 | tr -d '\051' )
|
||||
if [[ "${PIPREQVER}" == "${PIPREQ[2]}" ]] ; then
|
||||
mlog " -- pip ${PIPREQ[0]} version ${PIPREQ[2]}"
|
||||
while read -r reqline ; do
|
||||
if (echo "$reqline" | grep -q '>='); then
|
||||
delim='>='
|
||||
elif echo "$reqline" | grep -q '~='; then
|
||||
delim='~='
|
||||
elif echo "$reqline" | grep -q '=='; then
|
||||
delim='=='
|
||||
else
|
||||
mlog " ~~ Warn: can't find ${PIPREQ[0]} ${PIPREQ[2]} in pip. (found ${PIPREQVER})"
|
||||
delim=''
|
||||
fi
|
||||
done < "${MYCROFT_HOME}/requirements.txt"
|
||||
if [[ $delim != '' ]]; then
|
||||
IFS=${delim} read -r -a PIPREQ <<< "$reqline"
|
||||
PIPREQVER=$( grep -i ^"${PIPREQ[0]} " /tmp/mycroft-piplist.$$ | cut -d'(' -f2 | tr -d '\051' | sed 's/ */ /g' | sed 's/ $//g')
|
||||
|
||||
PKG_NAME="${PIPREQ[0],,}"
|
||||
PKG_VERSION="${PIPREQ[2]}"
|
||||
if [[ "${PIPREQVER,,}" == "${PKG_NAME} ${PKG_VERSION}" ]] ; then
|
||||
mlog " -- pip ${PIPREQ[0]} version ${PIPREQ[2]}"
|
||||
else
|
||||
mlog " ~~ Warn: can't find ${PIPREQ[0]} ${PIPREQ[2]} in pip. (found ${PIPREQVER})"
|
||||
fi
|
||||
fi
|
||||
done < "${REQUIREMENTS_FILE}"
|
||||
deactivate
|
||||
mlog " - PIP list can be found at /tmp/mycroft-piplist.$$ to verify any issues."
|
||||
else
|
||||
|
|
@ -176,13 +202,11 @@ function checktubes() {
|
|||
|
||||
# I prefer biking myself.
|
||||
function checkrunning() {
|
||||
while read SCREEN_SESS ; do
|
||||
SESS_NAME=$( echo "${SCREEN_SESS}" | cut -d'(' -f1 | cut -d'.' -f2 )
|
||||
SESS_ID=$( echo "${SCREEN_SESS}" | cut -d'.' -f1 )
|
||||
if [[ $( ps flax| grep "$SESS_ID" | awk ' { print $4 } ' | grep -c "$SESS_ID" ) -eq 1 ]]; then
|
||||
mlog " - ${SESS_NAME} appears to be currently running."
|
||||
fi
|
||||
done < <(screen -list | grep mycroft)
|
||||
for pid in $(pgrep -ax "python." | grep '\-m mycroft' | awk -F ' ' '{print $1}')
|
||||
do
|
||||
cmdline=$(tr '\000' ' ' < "/proc/${pid}/cmdline")
|
||||
mlog " - ${cmdline}(${pid}) appears to be currently running."
|
||||
done
|
||||
}
|
||||
|
||||
# He's dead, Jim.
|
||||
|
|
@ -217,7 +241,7 @@ fi
|
|||
RUNDIR=$( readlink -f "${0}" | tr -s '\057' '\012' | sed \$d | tr -s '\012' '\057' )
|
||||
|
||||
# Where is mycroft installed?
|
||||
if [[ -f "${RUNDIR}/mycroft-service.screen" && -f "${RUNDIR}/../mycroft/__init__.py" ]] ; then
|
||||
if [[ -f "${RUNDIR}/../mycroft/__init__.py" ]] ; then
|
||||
MYCROFT_HOME=$(cd "${RUNDIR}" && cd .. && pwd )
|
||||
else
|
||||
if [[ -f "/opt/mycroft/mycroft/__init__.py" ]] ; then
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ current_pkg=$( cat /etc/apt/sources.list.d/repo.mycroft.ai.list )
|
|||
stable_pkg="deb http://repo.mycroft.ai/repos/apt/debian debian main"
|
||||
unstable_pkg="deb http://repo.mycroft.ai/repos/apt/debian debian-unstable main"
|
||||
|
||||
mark_1_package_list="mycroft-mark-1 mycroft-core mycroft-wifi-setup"
|
||||
picroft_package_list="mycroft-picroft mycroft-core mycroft-wifi-setup"
|
||||
mark_1_package_list=(mycroft-mark-1 mycroft-core mycroft-wifi-setup)
|
||||
picroft_package_list=(mycroft-picroft mycroft-core mycroft-wifi-setup)
|
||||
|
||||
# Determine the platform
|
||||
mycroft_platform="null"
|
||||
|
|
@ -44,7 +44,7 @@ fi
|
|||
function service_ctl() {
|
||||
service=${1}
|
||||
action=${2}
|
||||
sudo /etc/init.d/${service} ${action}
|
||||
sudo "/etc/init.d/${service}" "${action}"
|
||||
}
|
||||
|
||||
function stop_mycroft() {
|
||||
|
|
@ -115,39 +115,39 @@ function github_init_scripts() {
|
|||
|
||||
# switch to point a github install and run as the current user
|
||||
# TODO Verify all of these
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'${path}'/start-mycroft.sh audio"_g' /etc/init.d/mycroft-audio
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='${user}'_g' /etc/init.d/mycroft-audio
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'"${path}"'/start-mycroft.sh audio"_g' /etc/init.d/mycroft-audio
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='"${user}"'_g' /etc/init.d/mycroft-audio
|
||||
sudo sed -i 's_stop() {_stop() {\nPID=$(ps ax | grep mycroft/audio/ | awk '"'NR==1{print \$1; exit}'"')\necho "${PID}" > "$PIDFILE"_g' /etc/init.d/mycroft-audio
|
||||
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'${path}'/start-mycroft.sh enclosure"_g' /etc/init.d/mycroft-enclosure-client
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='${user}'_g' /etc/init.d/mycroft-enclosure-client
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'"${path}"'/start-mycroft.sh enclosure"_g' /etc/init.d/mycroft-enclosure-client
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='"${user}"'_g' /etc/init.d/mycroft-enclosure-client
|
||||
sudo sed -i 's_stop() {_stop() {\nPID=$(ps ax | grep mycroft/client/enclosure/ | awk '"'NR==1{print \$1; exit}'"')\necho "${PID}" > "$PIDFILE"_g' /etc/init.d/mycroft-enclosure-client
|
||||
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'${path}'/start-mycroft.sh bus"_g' /etc/init.d/mycroft-messagebus
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='${user}'_g' /etc/init.d/mycroft-messagebus
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'"${path}"'/start-mycroft.sh bus"_g' /etc/init.d/mycroft-messagebus
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='"${user}"'_g' /etc/init.d/mycroft-messagebus
|
||||
sudo sed -i 's_stop() {_stop() {\nPID=$(ps ax | grep mycroft/messagebus/ | awk '"'NR==1{print \$1; exit}'"')\necho "${PID}" > "$PIDFILE"_g' /etc/init.d/mycroft-messagebus
|
||||
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'${path}'/start-mycroft.sh skills"_g' /etc/init.d/mycroft-skills
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='${user}'_g' /etc/init.d/mycroft-skills
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'"${path}"'/start-mycroft.sh skills"_g' /etc/init.d/mycroft-skills
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='"${user}"'_g' /etc/init.d/mycroft-skills
|
||||
sudo sed -i 's_stop() {_stop() {\nPID=$(ps ax | grep mycroft/skills/ | awk '"'NR==1{print \$1; exit}'"')\necho "${PID}" > "$PIDFILE"_g' /etc/init.d/mycroft-skills
|
||||
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'${path}'/start-mycroft.sh voice"_g' /etc/init.d/mycroft-speech-client
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='${user}'_g' /etc/init.d/mycroft-speech-client
|
||||
sudo sed -i 's_.*SCRIPT=.*_SCRIPT="'"${path}"'/start-mycroft.sh voice"_g' /etc/init.d/mycroft-speech-client
|
||||
sudo sed -i 's_.*RUNAS=.*_RUNAS='"${user}"'_g' /etc/init.d/mycroft-speech-client
|
||||
sudo sed -i 's_stop() {_stop() {\nPID=$(ps ax | grep mycroft/client/speech | awk '"'NR==1{print \$1; exit}'"')\necho "${PID}" > "$PIDFILE"_g' /etc/init.d/mycroft-speech-client
|
||||
|
||||
# soft link the current user to the mycroft user's identity folder
|
||||
chown ${user}:${user} /home/mycroft/.mycroft/identity/identity2.json
|
||||
if [ ! -e ${HOME}/.mycroft ] ; then
|
||||
mkdir ${HOME}/.mycroft
|
||||
chown "${user}:${user}" /home/mycroft/.mycroft/identity/identity2.json
|
||||
if [ ! -e "${HOME}/.mycroft" ] ; then
|
||||
mkdir "${HOME}/.mycroft"
|
||||
fi
|
||||
if [ ! -e ${HOME}/.mycroft/identity ] ; then
|
||||
sudo ln -s /home/mycroft/.mycroft/identity ${HOME}/.mycroft/
|
||||
if [ ! -e "${HOME}/.mycroft/identity" ] ; then
|
||||
sudo ln -s /home/mycroft/.mycroft/identity "${HOME}/.mycroft/"
|
||||
fi
|
||||
|
||||
sudo chown -R ${user}:${user} /var/log/mycroft*
|
||||
sudo chown -R ${user}:${user} /var/run/mycroft*
|
||||
sudo chown -R ${user}:${user} /tmp/mycroft
|
||||
sudo chown -R ${user}:${user} /var/tmp/mycroft_web_cache.json
|
||||
sudo chown -R "${user}:${user}" /var/log/mycroft*
|
||||
sudo chown -R "${user}:${user}" /var/run/mycroft*
|
||||
sudo chown -R "${user}:${user}" /tmp/mycroft
|
||||
sudo chown -R "${user}:${user}" /var/tmp/mycroft_web_cache.json
|
||||
|
||||
# reload daemon scripts
|
||||
sudo systemctl daemon-reload
|
||||
|
|
@ -159,24 +159,24 @@ function github_init_scripts() {
|
|||
function invoke_apt() {
|
||||
if [ ${mycroft_platform} == "mycroft_mark_1" ] ; then
|
||||
echo "${1}ing the mycroft-mark-1 metapackage..."
|
||||
sudo apt-get ${1} mycroft-mark-1 -y
|
||||
sudo apt-get "${1}" mycroft-mark-1 -y
|
||||
elif [ ${mycroft_platform} == "picroft" ] ; then
|
||||
echo "${1}ing the mycroft-picroft metapackage..."
|
||||
sudo apt-get ${1} mycroft-picroft -y
|
||||
sudo apt-get "${1}" mycroft-picroft -y
|
||||
else
|
||||
# for unknown, just update the generic package
|
||||
echo "${1}ing the generic mycroft-core package..."
|
||||
sudo apt-get ${1} mycroft-core -y
|
||||
sudo apt-get "${1}" mycroft-core -y
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_all() {
|
||||
if [ ${mycroft_platform} == "mycroft_mark_1" ] ; then
|
||||
echo "Removing the mycroft mark-1 packages..."
|
||||
sudo apt-get remove ${mark_1_package_list} -y
|
||||
sudo apt-get remove "${mark_1_package_list[@]}" -y
|
||||
elif [ ${mycroft_platform} == "picroft" ] ; then
|
||||
echo "Removing the picroft packages..."
|
||||
sudo apt-get remove ${picroft_package_list} -y
|
||||
sudo apt-get remove "${picroft_package_list[@]}" -y
|
||||
else
|
||||
# for unknown, just update the generic package
|
||||
echo "Removing the generic mycroft-core package..."
|
||||
|
|
@ -197,8 +197,7 @@ function stable_to_unstable_server() {
|
|||
conf_path=/home/mycroft/.mycroft/
|
||||
|
||||
# check if on stable (home-test.mycroft.ai) already
|
||||
cmp --silent ${conf_path}/mycroft.conf ${conf_path}/mycroft.conf.unstable
|
||||
if [ $? -eq 0 ] ; then
|
||||
if ! cmp --silent "${conf_path}/mycroft.conf" "${conf_path}/mycroft.conf.unstable" ; then
|
||||
echo "Already set to use the home-test.mycroft.ai server"
|
||||
return
|
||||
fi
|
||||
|
|
@ -206,15 +205,16 @@ function stable_to_unstable_server() {
|
|||
# point to test server
|
||||
echo "Changing mycroft.conf to point to test server api-test.mycroft.ai"
|
||||
if [ -f ${conf_path}mycroft.conf ] ; then
|
||||
cp ${conf_path}mycroft.conf ${conf_path}mycroft.conf.stable
|
||||
cp "${conf_path}mycroft.conf" "${conf_path}mycroft.conf.stable"
|
||||
else
|
||||
echo "could not find mycroft.conf, was it deleted?"
|
||||
fi
|
||||
if [ -f ${conf_path}mycroft.conf.unstable ] ; then
|
||||
cp ${conf_path}mycroft.conf.unstable ${conf_path}mycroft.conf
|
||||
cp ${conf_path}mycroft.conf.unstable "${conf_path}mycroft.conf"
|
||||
else
|
||||
rm -r ${conf_path}mycroft.conf
|
||||
echo '{"server": {"url":"https://api-test.mycroft.ai", "version":"v1", "update":true, "metrics":false }}' $( cat ${conf_path}mycroft.conf.stable ) | jq -s add > ${conf_path}mycroft.conf
|
||||
conf_data=$( cat "${conf_path}mycroft.conf.stable")
|
||||
echo '{"server": {"url":"https://api-test.mycroft.ai", "version":"v1", "update":true, "metrics":false }}' "${conf_data}" | jq -s add > "${conf_path}mycroft.conf"
|
||||
fi
|
||||
|
||||
# saving identity2.json to stable state
|
||||
|
|
@ -238,8 +238,7 @@ function unstable_to_stable_server() {
|
|||
conf_path=/home/mycroft/.mycroft/
|
||||
|
||||
# check if on stable (home.mycroft.ai) already
|
||||
cmp --silent ${conf_path}/mycroft.conf ${conf_path}/mycroft.conf.stable
|
||||
if [ $? -eq 0 ] ; then
|
||||
if cmp --silent ${conf_path}/mycroft.conf ${conf_path}/mycroft.conf.stable; then
|
||||
echo "Already set to use the home.mycroft.ai server"
|
||||
return
|
||||
fi
|
||||
|
|
@ -247,7 +246,9 @@ function unstable_to_stable_server() {
|
|||
# point api to production server
|
||||
echo "Changing mycroft.conf to point to production server api.mycroft.ai"
|
||||
if [ -f ${conf_path}mycroft.conf ] ; then
|
||||
echo '{"server": {"url":"https://api-test.mycroft.ai", "version":"v1", "update":true, "metrics":false }}' $( cat ${conf_path}mycroft.conf ) | jq -s add > ${conf_path}mycroft.conf.unstable
|
||||
base_config='{"server": {"url":"https://api-test.mycroft.ai", "version":"v1", "update":true, "metrics":false }}'
|
||||
current_config=$( cat "${conf_path}mycroft.conf" )
|
||||
echo "$base_config" "$current_config" | jq -s add > "${conf_path}mycroft.conf.unstable"
|
||||
else
|
||||
echo "could not find mycroft.conf, was it deleted?"
|
||||
fi
|
||||
|
|
@ -319,16 +320,15 @@ elif [ "${change_to}" == "stable" ] ; then
|
|||
|
||||
elif [ "${change_to}" == "github" ] ; then
|
||||
echo "Switching to github..."
|
||||
if [ ! -d ${path} ] ; then
|
||||
if [ ! -d "${path}" ] ; then
|
||||
mkdir --parents "${path}"
|
||||
cd "${path}"
|
||||
cd ..
|
||||
cd "${path}/.." || exit
|
||||
git clone https://github.com/MycroftAI/mycroft-core.git "${path}"
|
||||
fi
|
||||
|
||||
sudo chmod -x /etc/cron.hourly/mycroft-core # Disable updates
|
||||
|
||||
if [ -d ${path} ] ; then
|
||||
if [ -d "${path}" ] ; then
|
||||
if [ -f /usr/local/bin/mimic ] ; then
|
||||
echo "Mimic file exists"
|
||||
mimic_flag="-sm"
|
||||
|
|
@ -336,9 +336,9 @@ elif [ "${change_to}" == "github" ] ; then
|
|||
echo "file doesn't exist"
|
||||
mimic_flag=""
|
||||
fi
|
||||
cd ${path}
|
||||
cd "${path}" || exit
|
||||
# Build the dev environment
|
||||
${path}/dev_setup.sh --allow-root ${mimic_flag}
|
||||
"${path}"/dev_setup.sh --allow-root "${mimic_flag}"
|
||||
|
||||
# Switch init scripts to start the github version
|
||||
github_init_scripts
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|||
|
||||
# Determine which user is running this script
|
||||
setup_user=$USER
|
||||
setup_group=$( id -gn $USER )
|
||||
setup_group=$( id -gn "$USER" )
|
||||
|
||||
function found_exe() {
|
||||
hash "$1" 2>/dev/null
|
||||
|
|
@ -42,8 +42,8 @@ fi
|
|||
|
||||
# change ownership of ${mycroft_root_dir} to ${setup_user } recursively
|
||||
function change_ownership {
|
||||
echo "Changing ownership of" ${mycroft_root_dir} "to user:" ${setup_user} "with group:" ${setup_group}
|
||||
$SUDO chown -Rf ${setup_user}:${setup_group} ${mycroft_root_dir}
|
||||
echo "Changing ownership of" ${mycroft_root_dir} "to user:" "${setup_user}" "with group:" "${setup_group}"
|
||||
$SUDO chown -Rf "${setup_user}:${setup_group}" ${mycroft_root_dir}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ if [[ ${CI} != true ]] ; then
|
|||
change_ownership
|
||||
fi
|
||||
|
||||
if [ ! -w ${SKILLS_DIR} ] ; then
|
||||
if [ ! -w "${skills_dir}" ] ; then
|
||||
change_ownership
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue