Merge pull request #2166 from MichaIng/patch-1
Update dev_setup.sh to use and benefit from bash double square bracket syntaxpull/2167/head^2
commit
a66dd0868f
225
dev_setup.sh
225
dev_setup.sh
|
@ -22,10 +22,10 @@ export LANG=C
|
|||
set -Ee
|
||||
|
||||
cd $(dirname $0)
|
||||
TOP=$( pwd -L )
|
||||
TOP=$(pwd -L)
|
||||
|
||||
function show_help() {
|
||||
echo "
|
||||
echo '
|
||||
Usage: dev_setup.sh [options]
|
||||
Prepare your environment for running the mycroft-core services.
|
||||
|
||||
|
@ -36,7 +36,7 @@ Options:
|
|||
-p arg, --python arg Sets the python version to use
|
||||
-r, --allow-root Allow to be run as root (e.g. sudo)
|
||||
-sm Skip mimic build
|
||||
"
|
||||
'
|
||||
}
|
||||
|
||||
# Parse the command line
|
||||
|
@ -44,44 +44,44 @@ opt_forcemimicbuild=false
|
|||
opt_allowroot=false
|
||||
opt_skipmimicbuild=false
|
||||
opt_python=python3
|
||||
param=""
|
||||
param=''
|
||||
|
||||
for var in "$@" ; do
|
||||
# Check if parameter should be read
|
||||
if [[ ${param} == "python" ]] ; then
|
||||
opt_python=${var}
|
||||
if [[ $param == 'python' ]] ; then
|
||||
opt_python=$var
|
||||
param=""
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check for options
|
||||
if [[ ${var} == "-h" ]] || [[ ${var} == "--help" ]] ; then
|
||||
if [[ $var == '-h' || $var == '--help' ]] ; then
|
||||
show_help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ${var} == "-r" ]] || [[ ${var} == "--allow-root" ]] ; then
|
||||
if [[ $var == '-r' || $var == '--allow-root' ]] ; then
|
||||
opt_allowroot=true
|
||||
fi
|
||||
|
||||
if [[ ${var} == "-fm" ]] ; then
|
||||
if [[ $var == '-fm' ]] ; then
|
||||
opt_forcemimicbuild=true
|
||||
fi
|
||||
if [[ ${var} == "-n" ]] || [[ ${var} == "--no-error" ]] ; then
|
||||
if [[ $var == '-n' || $var == '--no-error' ]] ; then
|
||||
# Do NOT exit on errors
|
||||
set +Ee
|
||||
fi
|
||||
if [[ ${var} == "-sm" ]] ; then
|
||||
if [[ $var == '-sm' ]] ; then
|
||||
opt_skipmimicbuild=true
|
||||
fi
|
||||
if [[ ${var} == "-p" ]] || [[ ${var} == "--python" ]] ; then
|
||||
param="python"
|
||||
if [[ $var == '-p' || $var == '--python' ]] ; then
|
||||
param='python'
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $(id -u) -eq 0 ] && [ "${opt_allowroot}" != true ] ; then
|
||||
echo "This script should not be run as root or with sudo."
|
||||
echo "If you really need to for this, rerun with --allow-root"
|
||||
if [[ $(id -u) -eq 0 && $opt_allowroot != true ]] ; then
|
||||
echo 'This script should not be run as root or with sudo.'
|
||||
echo 'If you really need to for this, rerun with --allow-root'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -93,8 +93,8 @@ function found_exe() {
|
|||
|
||||
if found_exe sudo ; then
|
||||
SUDO=sudo
|
||||
elif [ "${opt_allowroot}" != true ]; then
|
||||
echo "This script requires \"sudo\" to install system packages. Please install it, then re-run this script."
|
||||
elif [[ $opt_allowroot != true ]]; then
|
||||
echo 'This script requires "sudo" to install system packages. Please install it, then re-run this script.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -116,23 +116,23 @@ function get_YN() {
|
|||
}
|
||||
|
||||
if found_exe tput ; then
|
||||
GREEN="$(tput setaf 2)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
RESET="$(tput sgr0)"
|
||||
HIGHLIGHT=${YELLOW}
|
||||
GREEN=$(tput setaf 2)
|
||||
BLUE=$(tput setaf 4)
|
||||
CYAN=$(tput setaf 6)
|
||||
YELLOW=$(tput setaf 3)
|
||||
RESET=$(tput sgr0)
|
||||
HIGHLIGHT=$YELLOW
|
||||
fi
|
||||
|
||||
# Run a setup wizard the very first time that guides the user through some decisions
|
||||
if [[ ! -f .dev_opts.json ]] && [[ ${IS_TRAVIS} == "" ]] ; then
|
||||
if [[ ! -f .dev_opts.json && -z $IS_TRAVIS ]] ; then
|
||||
echo "
|
||||
${CYAN} Welcome to Mycroft! ${RESET}"
|
||||
$CYAN Welcome to Mycroft! $RESET"
|
||||
sleep 0.5
|
||||
echo "
|
||||
echo '
|
||||
This script is designed to make working with Mycroft easy. During this
|
||||
first run of dev_setup we will ask you a few questions to help setup
|
||||
your environment."
|
||||
your environment.'
|
||||
sleep 0.5
|
||||
echo "
|
||||
Do you want to run on 'master' or against a dev branch? Unless you are
|
||||
|
@ -141,11 +141,11 @@ a developer modifying mycroft-core itself, you should run on the
|
|||
Y)es, run on the stable 'master' branch
|
||||
N)o, I want to run unstable branches"
|
||||
if get_YN ; then
|
||||
echo -e "${HIGHLIGHT} Y - using 'master' branch ${RESET}"
|
||||
echo -e "$HIGHLIGHT Y - using 'master' branch $RESET"
|
||||
branch=master
|
||||
git checkout ${branch}
|
||||
else
|
||||
echo -e "${HIGHLIGHT} N - using an unstable branch ${RESET}"
|
||||
echo -e "$HIGHLIGHT N - using an unstable branch $RESET"
|
||||
branch=dev
|
||||
fi
|
||||
|
||||
|
@ -158,17 +158,17 @@ those running against the 'master' branch.
|
|||
Y)es, automatically check for updates
|
||||
N)o, I will be responsible for keeping Mycroft updated."
|
||||
if get_YN ; then
|
||||
echo -e "${HIGHLIGHT} Y - update automatically ${RESET}"
|
||||
echo -e "$HIGHLIGHT Y - update automatically $RESET"
|
||||
autoupdate=true
|
||||
else
|
||||
echo -e "${HIGHLIGHT} N - update manually using 'git pull' ${RESET}"
|
||||
echo -e "$HIGHLIGHT N - update manually using 'git pull' $RESET"
|
||||
autoupdate=false
|
||||
fi
|
||||
|
||||
# Pull down mimic source? Most will be happy with just the package
|
||||
if [[ ${opt_forcemimicbuild} == false && ${opt_skipmimicbuild} == false ]] ; then
|
||||
if [[ $opt_forcemimicbuild == false && $opt_skipmimicbuild == false ]] ; then
|
||||
sleep 0.5
|
||||
echo "
|
||||
echo '
|
||||
Mycroft uses its Mimic technology to speak to you. Mimic can run both
|
||||
locally and from a server. The local Mimic is more robotic, but always
|
||||
available regardless of network connectivity. It will act as a fallback
|
||||
|
@ -177,11 +177,11 @@ if unable to contact the Mimic server.
|
|||
However, building the local Mimic is time consuming -- it can take hours
|
||||
on slower machines. This can be skipped, but Mycroft will be unable to
|
||||
talk if you lose network connectivity. Would you like to build Mimic
|
||||
locally?"
|
||||
locally?'
|
||||
if get_YN ; then
|
||||
echo -e "${HIGHLIGHT} Y - Mimic will be built ${RESET}"
|
||||
echo -e "$HIGHLIGHT Y - Mimic will be built $RESET"
|
||||
else
|
||||
echo -e "${HIGHLIGHT} N - skip Mimic build ${RESET}"
|
||||
echo -e "$HIGHLIGHT N - skip Mimic build $RESET"
|
||||
opt_skipmimicbuild=true
|
||||
fi
|
||||
fi
|
||||
|
@ -189,14 +189,14 @@ locally?"
|
|||
echo
|
||||
# Add mycroft-core/bin to the .bashrc PATH?
|
||||
sleep 0.5
|
||||
echo "
|
||||
echo '
|
||||
There are several Mycroft helper commands in the bin folder. These
|
||||
can be added to your system PATH, making it simpler to use Mycroft.
|
||||
Would you like this to be added to your PATH in the .profile?"
|
||||
Would you like this to be added to your PATH in the .profile?'
|
||||
if get_YN ; then
|
||||
echo -e "${HIGHLIGHT} Y - Adding Mycroft commands to your PATH ${RESET}"
|
||||
echo -e "$HIGHLIGHT Y - Adding Mycroft commands to your PATH $RESET"
|
||||
|
||||
if [ ! -f ~/.profile_mycroft ] ; then
|
||||
if [[ ! -f ~/.profile_mycroft ]] ; then
|
||||
# Only add the following to the .profile if .profile_mycroft
|
||||
# doesn't exist, indicating this script has not been run before
|
||||
echo '' >> ~/.profile
|
||||
|
@ -210,47 +210,45 @@ Would you like this to be added to your PATH in the .profile?"
|
|||
if [ -d \"${TOP}/bin\" ] ; then
|
||||
PATH=\"\$PATH:${TOP}/bin\"
|
||||
fi" > ~/.profile_mycroft
|
||||
echo -e "Type ${CYAN}mycroft-help${RESET} to see available commands."
|
||||
echo -e "Type ${CYAN}mycroft-help$RESET to see available commands."
|
||||
else
|
||||
echo -e "${HIGHLIGHT} N - PATH left unchanged ${RESET}"
|
||||
echo -e "$HIGHLIGHT N - PATH left unchanged $RESET"
|
||||
fi
|
||||
|
||||
# Create a link to the 'skills' folder.
|
||||
sleep 0.5
|
||||
echo
|
||||
echo "The standard location for Mycroft skills is under /opt/mycroft/skills."
|
||||
echo 'The standard location for Mycroft skills is under /opt/mycroft/skills.'
|
||||
if [[ ! -d /opt/mycroft/skills ]] ; then
|
||||
echo "This script will create that folder for you. This requires sudo"
|
||||
echo "permission and might ask you for a password..."
|
||||
echo 'This script will create that folder for you. This requires sudo'
|
||||
echo 'permission and might ask you for a password...'
|
||||
setup_user=$USER
|
||||
setup_group=$( id -gn $USER )
|
||||
setup_group=$(id -gn $USER)
|
||||
$SUDO mkdir -p /opt/mycroft/skills
|
||||
$SUDO chown -R ${setup_user}:${setup_group} /opt/mycroft
|
||||
echo "Created!"
|
||||
echo 'Created!'
|
||||
fi
|
||||
if [[ ! -d skills ]] ; then
|
||||
ln -s /opt/mycroft/skills skills
|
||||
echo "For convenience, a soft link has been created called 'skills' which leads"
|
||||
echo "to /opt/mycroft/skills."
|
||||
echo 'to /opt/mycroft/skills.'
|
||||
fi
|
||||
|
||||
# Add PEP8 pre-commit hook
|
||||
sleep 0.5
|
||||
echo "
|
||||
echo '
|
||||
(Devloper) Do you want to automatically check code-style when submitting code.
|
||||
If unsure answer yes.
|
||||
"
|
||||
'
|
||||
if get_YN ; then
|
||||
echo -e "Will install PEP8 pre-commit hook..."
|
||||
echo 'Will install PEP8 pre-commit hook...'
|
||||
INSTALL_PRECOMMIT_HOOK=true
|
||||
fi
|
||||
|
||||
# Save options
|
||||
echo '{"use_branch": "'${branch}'", "auto_update": '${autoupdate}'}' > .dev_opts.json
|
||||
echo '{"use_branch": "'$branch'", "auto_update": '$autoupdate'}' > .dev_opts.json
|
||||
|
||||
echo
|
||||
echo "Interactive portion complete, now installing dependencies..."
|
||||
echo
|
||||
echo -e '\nInteractive portion complete, now installing dependencies...\n'
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
|
@ -270,26 +268,26 @@ function redhat_common_install() {
|
|||
git checkout b211dc3db3a6a2540a34fbe8995bf2df63fc9939
|
||||
cmake .
|
||||
$SUDO make install
|
||||
cd "${TOP}"
|
||||
cd "$TOP"
|
||||
rm -rf fann
|
||||
|
||||
}
|
||||
|
||||
function install_deps() {
|
||||
echo "Installing packages..."
|
||||
echo 'Installing packages...'
|
||||
if found_exe zypper ; then
|
||||
# OpenSUSE
|
||||
echo ${GREEN} Installing packages for OpenSUSE...${RESET}
|
||||
echo "$GREEN Installing packages for OpenSUSE...$RESET"
|
||||
$SUDO zypper install -y git python3 python3-devel libtool libffi-devel libopenssl-devel autoconf automake bison swig portaudio-devel mpg123 flac curl libicu-devel pkg-config libjpeg-devel libfann-devel python3-curses pulseaudio
|
||||
$SUDO zypper install -y -t pattern devel_C_C++
|
||||
elif found_exe yum && os_is centos ; then
|
||||
# CentOS
|
||||
echo ${GREEN} Installing packages for Centos...${RESET}
|
||||
echo "$GREEN Installing packages for Centos...$RESET"
|
||||
$SUDO yum install epel-release
|
||||
redhat_common_install
|
||||
elif found_exe yum && os_is rhel ; then
|
||||
# Redhat Enterprise Linux
|
||||
echo ${GREEN} Installing packages for Red Hat...${RESET}
|
||||
echo "$GREEN Installing packages for Red Hat...$RESET"
|
||||
$SUDO yum install -y wget
|
||||
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
|
||||
$SUDO yum install -y epel-release-latest-7.noarch.rpm
|
||||
|
@ -297,17 +295,17 @@ function install_deps() {
|
|||
redhat_common_install
|
||||
elif os_is_like debian ; then
|
||||
# Debian / Ubuntu
|
||||
echo ${GREEN} Installing packages for Debian/Ubuntu...${RESET}
|
||||
echo "$GREEN Installing packages for Debian/Ubuntu...$RESET"
|
||||
$SUDO apt-get install -y git python3 python3-dev python-setuptools python-gobject-2-dev libtool libffi-dev libssl-dev autoconf automake bison swig libglib2.0-dev portaudio19-dev mpg123 screen flac curl libicu-dev pkg-config automake libjpeg-dev libfann-dev build-essential jq
|
||||
elif os_is_like fedora ; then
|
||||
echo ${GREEN} Installing packages for Fedora...${RESET}
|
||||
echo "$GREEN Installing packages for Fedora...$RESET"
|
||||
# Fedora
|
||||
$SUDO dnf install -y git python3 python3-devel python3-pip python3-setuptools python3-virtualenv pygobject3-devel libtool libffi-devel openssl-devel autoconf bison swig glib2-devel portaudio-devel mpg123 mpg123-plugins-pulseaudio screen curl pkgconfig libicu-devel automake libjpeg-turbo-devel fann-devel gcc-c++ redhat-rpm-config jq
|
||||
elif found_exe pacman; then
|
||||
# Arch Linux
|
||||
echo ${GREEN} Installing packages for Arch...${RESET}
|
||||
echo "$GREEN Installing packages for Arch...$RESET"
|
||||
$SUDO pacman -S --needed --noconfirm git python python-pip python-setuptools python-virtualenv python-gobject python-virtualenvwrapper libffi swig portaudio mpg123 screen flac curl icu libjpeg-turbo base-devel jq pulseaudio pulseaudio-alsa
|
||||
pacman -Qs "^fann$" &> /dev/null || (
|
||||
pacman -Qs '^fann$' &> /dev/null || (
|
||||
git clone https://aur.archlinux.org/fann.git
|
||||
cd fann
|
||||
makepkg -srciA --noconfirm
|
||||
|
@ -316,22 +314,21 @@ function install_deps() {
|
|||
)
|
||||
else
|
||||
echo
|
||||
echo "${YELLOW}Could not find package manager"
|
||||
echo "${YELLOW}Make sure to manually install:${BLUE} git python3 python-setuptools python-venv pygobject libtool libffi libjpg openssl autoconf bison swig glib2.0 portaudio19 mpg123 flac curl fann g++ jq"
|
||||
echo ${RESET}
|
||||
echo -e "${YELLOW}Could not find package manager
|
||||
${YELLOW}Make sure to manually install:$BLUE git python3 python-setuptools python-venv pygobject libtool libffi libjpg openssl autoconf bison swig glib2.0 portaudio19 mpg123 flac curl fann g++ jq\n$RESET"
|
||||
fi
|
||||
}
|
||||
|
||||
VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${TOP}/.venv"}
|
||||
|
||||
function install_venv() {
|
||||
${opt_python} -m venv "${VIRTUALENV_ROOT}/" --without-pip
|
||||
$opt_python -m venv "${VIRTUALENV_ROOT}/" --without-pip
|
||||
# Force version of pip for reproducability, but there is nothing special
|
||||
# about this version. Update whenever a new version is released and
|
||||
# verified functional.
|
||||
curl https://bootstrap.pypa.io/3.3/get-pip.py | "${VIRTUALENV_ROOT}/bin/python" - 'pip==18.0.0'
|
||||
# Function status depending on if pip exists
|
||||
[ -x "${VIRTUALENV_ROOT}/bin/pip" ]
|
||||
[[ -x ${VIRTUALENV_ROOT}/bin/pip ]]
|
||||
}
|
||||
|
||||
install_deps
|
||||
|
@ -341,78 +338,78 @@ install_deps
|
|||
git config commit.template .gitmessage
|
||||
|
||||
# Check whether to build mimic (it takes a really long time!)
|
||||
build_mimic="n"
|
||||
if [[ ${opt_forcemimicbuild} == true ]] ; then
|
||||
build_mimic="y"
|
||||
build_mimic='n'
|
||||
if [[ $opt_forcemimicbuild == true ]] ; then
|
||||
build_mimic='y'
|
||||
else
|
||||
# first, look for a build of mimic in the folder
|
||||
has_mimic=""
|
||||
has_mimic=''
|
||||
if [[ -f ${TOP}/mimic/bin/mimic ]] ; then
|
||||
has_mimic=$( ${TOP}/mimic/bin/mimic -lv | grep Voice ) || true
|
||||
has_mimic=$(${TOP}/mimic/bin/mimic -lv | grep Voice) || true
|
||||
fi
|
||||
|
||||
# in not, check the system path
|
||||
if [ "$has_mimic" == "" ] ; then
|
||||
if [ -x "$(command -v mimic)" ] ; then
|
||||
has_mimic="$( mimic -lv | grep Voice )" || true
|
||||
if [[ -z $has_mimic ]] ; then
|
||||
if [[ -x $(command -v mimic) ]] ; then
|
||||
has_mimic=$(mimic -lv | grep Voice) || true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$has_mimic" == "" ]; then
|
||||
if [[ ${opt_skipmimicbuild} == true ]] ; then
|
||||
build_mimic="n"
|
||||
if [[ -z $has_mimic ]]; then
|
||||
if [[ $opt_skipmimicbuild == true ]] ; then
|
||||
build_mimic='n'
|
||||
else
|
||||
build_mimic="y"
|
||||
build_mimic='y'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "${VIRTUALENV_ROOT}/bin/activate" ] ; then
|
||||
if [[ ! -x ${VIRTUALENV_ROOT}/bin/activate ]] ; then
|
||||
if ! install_venv ; then
|
||||
echo "Failed to set up virtualenv for mycroft, exiting setup."
|
||||
echo 'Failed to set up virtualenv for mycroft, exiting setup.'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start the virtual environment
|
||||
source "${VIRTUALENV_ROOT}/bin/activate"
|
||||
cd "${TOP}"
|
||||
cd "$TOP"
|
||||
|
||||
# Install pep8 pre-commit hook
|
||||
HOOK_FILE="./.git/hooks/pre-commit"
|
||||
if [ ! -z ${INSTALL_PRECOMMIT_HOOK+x} ] || grep -q "MYCROFT DEV SETUP" ${HOOK_FILE}; then
|
||||
if [ ! -f ${HOOK_FILE} ] || grep -q "MYCROFT DEV SETUP" ${HOOK_FILE} ; then
|
||||
echo "Installing PEP8 check as precommit-hook"
|
||||
echo "#! $( which python )" > ${HOOK_FILE}
|
||||
echo "# MYCROFT DEV SETUP" >> ${HOOK_FILE}
|
||||
cat ./scripts/pre-commit >> ${HOOK_FILE}
|
||||
chmod +x ${HOOK_FILE}
|
||||
HOOK_FILE='./.git/hooks/pre-commit'
|
||||
if [[ -n $INSTALL_PRECOMMIT_HOOK ]] || grep -q 'MYCROFT DEV SETUP' $HOOK_FILE; then
|
||||
if [[ ! -f $HOOK_FILE ]] || grep -q 'MYCROFT DEV SETUP' $HOOK_FILE; then
|
||||
echo 'Installing PEP8 check as precommit-hook'
|
||||
echo "#! $(which python)" > $HOOK_FILE
|
||||
echo '# MYCROFT DEV SETUP' >> $HOOK_FILE
|
||||
cat ./scripts/pre-commit >> $HOOK_FILE
|
||||
chmod +x $HOOK_FILE
|
||||
fi
|
||||
fi
|
||||
|
||||
PYTHON=$( python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))" )
|
||||
PYTHON=$(python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))")
|
||||
|
||||
# Add mycroft-core to the virtualenv path
|
||||
# (This is equivalent to typing 'add2virtualenv $TOP', except
|
||||
# you can't invoke that shell function from inside a script)
|
||||
VENV_PATH_FILE="${VIRTUALENV_ROOT}/lib/$PYTHON/site-packages/_virtualenv_path_extensions.pth"
|
||||
if [ ! -f "$VENV_PATH_FILE" ] ; then
|
||||
echo "import sys; sys.__plen = len(sys.path)" > "$VENV_PATH_FILE" || return 1
|
||||
if [[ ! -f $VENV_PATH_FILE ]] ; then
|
||||
echo 'import sys; sys.__plen = len(sys.path)' > "$VENV_PATH_FILE" || return 1
|
||||
echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$VENV_PATH_FILE" || return 1
|
||||
fi
|
||||
|
||||
if ! grep -q "$TOP" $VENV_PATH_FILE ; then
|
||||
echo "Adding mycroft-core to virtualenv path"
|
||||
echo 'Adding mycroft-core to virtualenv path'
|
||||
sed -i.tmp '1 a\
|
||||
'"$TOP"'
|
||||
' "${VENV_PATH_FILE}"
|
||||
' "$VENV_PATH_FILE"
|
||||
fi
|
||||
|
||||
# install required python modules
|
||||
if ! pip install -r requirements.txt ; then
|
||||
echo "Warning: Failed to install all requirements. Continue? y/N"
|
||||
echo 'Warning: Failed to install all requirements. Continue? y/N'
|
||||
read -n1 continue
|
||||
if [[ "$continue" != "y" ]] ; then
|
||||
if [[ $continue != 'y' ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -421,36 +418,36 @@ if ! pip install -r test-requirements.txt ; then
|
|||
echo "Warning test requirements wasn't installed, Note: normal operation should still work fine..."
|
||||
fi
|
||||
|
||||
SYSMEM=$( free | awk '/^Mem:/ { print $2 }' )
|
||||
SYSMEM=$(free | awk '/^Mem:/ { print $2 }')
|
||||
MAXCORES=$(($SYSMEM / 512000))
|
||||
MINCORES=1
|
||||
CORES=$( nproc )
|
||||
CORES=$(nproc)
|
||||
|
||||
# ensure MAXCORES is > 0
|
||||
if [[ ${MAXCORES} -lt 1 ]] ; then
|
||||
if [[ $MAXCORES -lt 1 ]] ; then
|
||||
MAXCORES=${MINCORES}
|
||||
fi
|
||||
|
||||
# look for positive integer
|
||||
if ! [[ ${CORES} =~ ^[0-9]+$ ]] ; then
|
||||
CORES=${MINCORES}
|
||||
elif [[ ${MAXCORES} -lt ${CORES} ]] ; then
|
||||
CORES=${MAXCORES}
|
||||
if ! [[ $CORES =~ ^[0-9]+$ ]] ; then
|
||||
CORES=$MINCORES
|
||||
elif [[ $MAXCORES -lt $CORES ]] ; then
|
||||
CORES=$MAXCORES
|
||||
fi
|
||||
|
||||
echo "Building with $CORES cores."
|
||||
|
||||
#build and install pocketsphinx
|
||||
#cd ${TOP}
|
||||
#cd $TOP
|
||||
#${TOP}/scripts/install-pocketsphinx.sh -q
|
||||
#build and install mimic
|
||||
cd "${TOP}"
|
||||
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}"
|
||||
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"
|
||||
else
|
||||
echo "Skipping mimic build."
|
||||
echo 'Skipping mimic build.'
|
||||
fi
|
||||
|
||||
# set permissions for common scripts
|
||||
|
@ -469,7 +466,7 @@ chmod +x bin/mycroft-speak
|
|||
# create and set permissions for logging
|
||||
if [[ ! -w /var/log/mycroft/ ]] ; then
|
||||
# Creating and setting permissions
|
||||
echo "Creating /var/log/mycroft/ directory"
|
||||
echo 'Creating /var/log/mycroft/ directory'
|
||||
if [[ ! -d /var/log/mycroft/ ]] ; then
|
||||
$SUDO mkdir /var/log/mycroft/
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue