diff --git a/arch_requirements.txt b/arch_requirements.txt new file mode 100644 index 00000000..d5769077 --- /dev/null +++ b/arch_requirements.txt @@ -0,0 +1,49 @@ + +# Core requirements +python3-pip +atlas +openssl +ncurses +gnupg +# dirmngr does not exist +gettext +gcc-fortran +util-linux +jq + +# Plugins +## AudioEngine +### PyAudio +#portaudio19-dev +# libasound2-dev +pulseaudio +#pulseaudio-utils +pipewire + +## STT +### PocketSphinx is default for wakeword spotting +swig +bison +libpulse + +#### Phonetisaurus is used to build dictionaries +gcc +# g++ Does not exist +make +autoconf +libtool +git +#gfortran +autoconf-archive +subversion +swig +bison + +# TTS +## flite +flite + +# SpeechHandler +## MPDControl +mpd + diff --git a/installers/naomi-setup.sh b/installers/naomi-setup.sh index a4ef1ff4..132764f6 100755 --- a/installers/naomi-setup.sh +++ b/installers/naomi-setup.sh @@ -1,229 +1,20 @@ #!/bin/bash +source "scripts/misc.sh" +source "scripts/pre_checks.sh" +source "scripts/naomi_cmds.sh" + ######################################### # Determines the OS & Version to direct # Naomi build process correctly. ######################################### -BLACK='\033[1;30m' -RED='\033[1;31m' -GREEN='\033[1;32m' -YELLOW='\033[1;33m' -BLUE='\033[1;34m' -MAGENTA='\033[1;35m' -CYAN='\033[1;36m' -WHITE='\033[1;37m' -B_C='\033[1;96m' #Bright Cyan For logo -B_R='\033[1;91m' #Bright Red For alerts/errors -B_G='\033[1;92m' #Bright Green For initiating a process i.e. "Installing blah blah..." or calling attention to thing in outputs -B_Y='\033[1;93m' #Bright Yellow For urls & emails -B_Black='\033[1;90m' #Bright Black For lower text -B_Blue='\033[1;94m' #Bright Blue For prompt question -B_M='\033[1;95m' #Bright Magenta For prompt choices -B_W='\033[1;97m' #Bright White For standard text output -NL=" -" -OPTION="0" -SUDO_APPROVE="" -version="3.0" -theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S) -gitVersionNumber=$(git rev-parse --short HEAD) -gitURL="https://github.com/naomiproject/naomi" - -CONTINUE() { - read -n1 -p "Press 'q' to quit, any other key to continue: " CONTINUE - echo - if [ "$CONTINUE" = "q" ] || [ "$CONTINUE" = "Q" ]; then - echo "EXITING" - exit 1 - fi -} -quit() { - read -n1 -p "Press 'q' to quit, any other key to continue: " CONTINUE - echo - if [ "$CONTINUE" = "q" ] || [ "$CONTINUE" = "Q" ]; then - echo "EXITING" - exit 1 - else - exec bash $0 - fi -} -SUDO_COMMAND() { - echo - printf "${B_R}Notice:${B_W} this program is about to use sudo to run the following command:${NL}" - printf "[$(pwd)]\$ ${B_G}${1}${B_W}${NL}" - if [ "$SUDO_APPROVE" != "-y" ]; then - CONTINUE - fi - $1 -} -CHECK_HEADER() { - echo "#include <$1>" | cpp $(pkg-config alsa --cflags) -H -o /dev/null > /dev/null 2>&1 - echo $? -} -CHECK_PROGRAM() { - type -p "$1" > /dev/null 2>&1 - echo $? -} -unknown_os () { - printf "${B_R}Notice:${B_W} Unfortunately, your operating system distribution and version are not supported by this script at this time.${NL}" - echo - printf "${B_R}Notice:${B_W} You can find a list of supported OSes and distributions on our website: ${B_Y}https://projectnaomi.com/dev/docs/installation/${NL}" - echo - printf "${B_R}Notice:${B_W} Please join our Discord or email us at ${B_Y}contact@projectnaomi.com${B_W} and let us know if you run into any issues.${NL}" - exit 1 -} -os_detect () { - if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then - # some systems dont have lsb-release yet have the lsb_release binary and - # vice-versa - if [ -e /etc/lsb-release ]; then - . /etc/lsb-release - - if [ "${ID}" = "raspbian" ]; then - os=${ID} - dist=`cut --delimiter='.' -f1 /etc/debian_version` - else - os=${DISTRIB_ID} - dist=${DISTRIB_CODENAME} - - if [ -z "$dist" ]; then - dist=${DISTRIB_RELEASE} - fi - fi - - elif [ `which lsb_release 2>/dev/null` ]; then - dist=`lsb_release -c | cut -f2` - os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` - - elif [ -e /etc/debian_version ]; then - # some Debians have jessie/sid in their /etc/debian_version - # while others have '6.0.7' - os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'` - if grep -q '/' /etc/debian_version; then - dist=`cut --delimiter='/' -f1 /etc/debian_version` - else - dist=`cut --delimiter='.' -f1 /etc/debian_version` - fi - - elif [ -e /etc/os-release ]; then - . /etc/os-release - os=${ID} - if [ "${os}" = "poky" ]; then - dist=`echo ${VERSION_ID}` - elif [ "${os}" = "sles" ]; then - dist=`echo ${VERSION_ID}` - elif [ "${os}" = "opensuse" ]; then - dist=`echo ${VERSION_ID}` - elif [ "${os}" = "opensuse-leap" ]; then - os=opensuse - dist=`echo ${VERSION_ID}` - else - dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'` - fi - - elif [ `which lsb_release 2>/dev/null` ]; then - # get major version (e.g. '5' or '6') - dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'` - - # get os (e.g. 'centos', 'redhatenterpriseserver', etc) - os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` - - elif [ -e /etc/oracle-release ]; then - dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'` - os='ol' - - elif [ -e /etc/fedora-release ]; then - dist=`cut -f3 --delimiter=' ' /etc/fedora-release` - os='fedora' - - elif [ -e /etc/redhat-release ]; then - os_hint=`cat /etc/redhat-release | awk '{ print tolower($1) }'` - if [ "${os_hint}" = "centos" ]; then - dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'` - os='centos' - elif [ "${os_hint}" = "scientific" ]; then - dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'` - os='scientific' - else - dist=`cat /etc/redhat-release | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'` - os='redhatenterpriseserver' - fi - else - unknown_os - fi - fi - - if [[ ( -z "${os}" ) || ( -z "${dist}" ) ]]; then - unknown_os - fi - - # remove whitespace from OS and dist name - os="${os// /}" - dist="${dist// /}" +curl_check +jq_check +python_check +git_check +zip_check - printf "${B_W}Detected operating system as $os/$dist.${NL}" -} -curl_check () { - printf "${B_W}Checking for curl...${NL}" - if command -v curl > /dev/null; then - printf "${B_W}Detected curl...${NL}" - else - printf "${B_G}Installing curl...${NL}" - if [ -n "$(command -v yum)" ]; then - printf "${B_W}yum found${NL}" - SUDO_COMMAND "yum install -d0 -e0 -y curl" - if [ "$?" -ne "0" ]; then - printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" - printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" - exit 1 - fi - elif [ -n "$(command -v apt-get)" ]; then - printf "${B_W}apt found${NL}" - SUDO_COMMAND "sudo apt-get install -q -y curl" - if [ "$?" -ne "0" ]; then - printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" - printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" - exit 1 - fi - else - printf "${B_R}Notice:${B_W} Neither yum nor apt-get found${NL}" - printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" - printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" - exit 1 - fi - fi -} -jq_check () { - printf "${B_W}Checking for jq...${NL}" - if command -v jq > /dev/null; then - printf "${B_W}Detected jq...${NL}" - else - printf "${B_G}Installing jq...${NL}" - if [ -n "$(command -v yum)" ]; then - printf "${B_W}yum found${NL}" - SUDO_COMMAND "yum install -d0 -e0 -y jq" - if [ "$?" -ne "0" ]; then - printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" - printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" - exit 1 - fi - elif [ -n "$(command -v apt-get)" ]; then - printf "${B_W}apt found${NL}" - SUDO_COMMAND "sudo apt-get install -q -y jq" - if [ "$?" -ne "0" ]; then - printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" - printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" - exit 1 - fi - else - printf "${B_R}Notice:${B_W} Neither yum nor apt-get found${NL}" - printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" - printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" - exit 1 - fi - fi -} apt_setup_wizard() { if [ ! -f ~/Naomi/README.md ]; then echo @@ -231,24 +22,7 @@ apt_setup_wizard() { . <( wget -O - "https://installers.projectnaomi.com/script.deb.sh" ); wget_exit_code=$? if [ "$wget_exit_code" = "0" ]; then - echo - echo - echo - echo - printf "${B_W}=========================================================================${NL}" - echo - printf "${B_W}That's all, installation is complete! All that is left is the profile${NL}" - printf "${B_W}population process and after that Naomi will start.${NL}" - echo - printf "${B_W}In the future, to start Naomi type '${B_G}Naomi${B_W}' in a terminal${NL}" - echo - printf "${B_W}Please type '${B_G}Naomi --repopulate${B_W}' on the prompt below to populate your profile...${NL}" - sudo rm -Rf ~/Naomi-Temp - # Launch Naomi Population - cd ~/.config/naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Apt Setup Wizard Failed.${NL}" @@ -260,24 +34,7 @@ apt_setup_wizard() { bash ~/Naomi/installers/script.deb.sh script_exit_code=$? if [ "$script_exit_code" = "0" ]; then - echo - echo - echo - echo - printf "${B_W}=========================================================================${NL}" - echo - printf "${B_W}That's all, installation is complete! All that is left is the profile${NL}" - printf "${B_W}population process and after that Naomi will start.${NL}" - echo - printf "${B_W}In the future, to start Naomi type '${B_G}Naomi${B_W}' in a terminal${NL}" - echo - printf "${B_W}Please type '${B_G}Naomi --repopulate${B_W}' on the prompt below to populate your profile...${NL}" - sudo rm -Rf ~/Naomi-Temp - # Launch Naomi Population - cd ~/.config/naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Apt Setup Wizard Failed.${NL}" @@ -285,13 +42,7 @@ apt_setup_wizard() { exit 1 fi else - printf "${B_W}=========================================================================${NL}" - printf "${B_W}It looks like you have Naomi source in the ${B_G}~/Naomi${B_W} directory,${NL}" - printf "${B_W}however it looks to be out of date. Please update or remove the Naomi${NL}" - printf "${B_W}source and try running the installer again.${NL}" - echo - printf "${B_W}Please join our Discord or email us at ${B_Y}contact@projectnaomi.com${B_W} and let us know if you run into any issues.${NL}" - exit 1 + existingInstall fi } yum_setup_wizard() { @@ -304,24 +55,7 @@ yum_setup_wizard() { . <( wget -O - "https://installers.projectnaomi.com/script.rpm.sh" ); wget_exit_code=$? if [ "$wget_exit_code" = "0" ]; then - echo - echo - echo - echo - printf "${B_W}=========================================================================${NL}" - echo - printf "${B_W}That's all, installation is complete! All that is left is the profile${NL}" - printf "${B_W}population process and after that Naomi will start.${NL}" - echo - printf "${B_W}In the future, to start Naomi type '${B_G}Naomi${B_W}' in a terminal${NL}" - echo - printf "${B_W}Please type '${B_G}Naomi --repopulate${B_W}' on the prompt below to populate your profile...${NL}" - sudo rm -Rf ~/Naomi-Temp - # Launch Naomi Population - cd ~/.config/naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Yum Setup Wizard Failed.${NL}" @@ -333,24 +67,7 @@ yum_setup_wizard() { bash ~/Naomi/installers/script.rpm.sh script_exit_code=$? if [ "$script_exit_code" = "0" ]; then - echo - echo - echo - echo - printf "${B_W}=========================================================================${NL}" - echo - printf "${B_W}That's all, installation is complete! All that is left is the profile${NL}" - printf "${B_W}population process and after that Naomi will start.${NL}" - echo - printf "${B_W}In the future, to start Naomi type '${B_G}Naomi${B_W}' in a terminal${NL}" - echo - printf "${B_W}Please type '${B_G}Naomi --repopulate${B_W}' on the prompt below to populate your profile...${NL}" - sudo rm -Rf ~/Naomi-Temp - # Launch Naomi Population - cd ~/.config/naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Yum Setup Wizard Failed.${NL}" @@ -358,421 +75,18 @@ yum_setup_wizard() { exit 1 fi else - printf "${B_W}=========================================================================${NL}" - printf "${B_W}It looks like you have Naomi source in the ${B_G}~/Naomi${B_W} directory,${NL}" - printf "${B_W}however it looks to be out of date. Please update or remove the Naomi${NL}" - printf "${B_W}source and try running the installer again.${NL}" - echo - printf "${B_W}Please join our Discord or email us at ${B_Y}contact@projectnaomi.com${B_W} and let us know if you run into any issues.${NL}" - exit 1 + existingInstall fi } -naomi_install() { - printf "${B_W}=========================================================================${NL}" - printf "${B_M}Install ${B_W}...${NL}" - printf "${B_W}=========================================================================${NL}" - echo - if [ -d ~/.config/naomi ]; then - printf "${B_W}It looks like you already have Naomi installed.${NL}" - printf "${B_W}To start Naomi just type '${B_G}Naomi${B_W}' in any terminal.${NL}" - echo - printf "${B_W}Running the install process again will create a backup of Naomi${NL}" - printf "${B_W}in the '${B_G}~/.config/naomi-backup${B_W}' directory and then create a fresh install.${NL}" - printf "${B_W}Is this what you want?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - read installChoice - if [ "$installChoice" = "y" ] || [ "$installChoice" = "Y" ]; then - printf "${B_M}Y ${B_W}- Creating Backup${NL}" - theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S) - mkdir -p ~/.config/naomi_backup/ - mv ~/Naomi ~/.config/naomi_backup/Naomi-Source - mv ~/.config/naomi ~/.config/naomi_backup/Naomi-SubDir - cd ~/.config/naomi_backup/ - zip -r Naomi-Backup.$theDateRightNow.zip ~/.config/naomi_backup/ - sudo rm -Rf ~/.config/naomi_backup/Naomi-Source/ - sudo rm -Rf ~/.config/naomi_backup/Naomi-SubDir/ - printf "${B_M}Y ${B_W}- Installing Naomi${NL}" - if [ -n "$(command -v apt-get)" ]; then - apt_setup_wizard - elif [ -n "$(command -v yum)" ]; then - unknown_os - else - unknown_os - fi - break - elif [ "$installChoice" = "n" ] || [ "$installChoice" = "N" ]; then - printf "${B_M}N ${B_W}- Cancelling Install${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - elif [ ! -d ~/.config/naomi ]; then - printf "${B_W}This process can take up to 3 hours to complete.${NL}" - printf "${B_W}Would you like to continue with the process now or wait for another time?${NL}" - echo - printf "${B_M} Y${B_W})es, I'd like the proceed with the setup.${NL}" - printf "${B_M} N${B_W})ope, I will come back at another time.${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - read installChoice - if [ "$installChoice" = "y" ] || [ "$installChoice" = "Y" ]; then - printf "${B_M}Y ${B_W}- Installing Naomi${NL}" - if [ -n "$(command -v apt-get)" ]; then - apt_setup_wizard - elif [ -n "$(command -v yum)" ]; then - unknown_os - else - unknown_os - fi - break - elif [ "$installChoice" = "n" ] || [ "$installChoice" = "N" ]; then - printf "${B_M}N ${B_W}- Cancelling Install${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - fi -} -naomi_uninstall() { - printf "${B_W}=========================================================================${NL}" - printf "${B_M}Uninstall ${B_W}...${NL}" - printf "${B_W}=========================================================================${NL}" - printf "${B_R}Notice:${B_W} You are about to uninstall Naomi, is that what you want?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - read uninstallChoice - if [ "$uninstallChoice" = "y" ] || [ "$uninstallChoice" = "Y" ]; then - printf "${B_M}$key ${B_W}- Uninstalling Naomi${NL}" - SUDO_COMMAND "sudo rm -Rf ~/Naomi" - SUDO_COMMAND "sudo rm -Rf ~/.config/naomi" - break - elif [ "$uninstallChoice" = "n" ] || [ "$uninstallChoice" = "N" ]; then - printf "${B_M}N ${B_W}- Cancelling Install${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done -} -naomi_update() { - printf "${B_W}=========================================================================${NL}" - printf "${B_M}Update ${B_W}...${NL}" - printf "${B_W}=========================================================================${NL}" - printf "${B_R}Notice: ${B_W}You are about to manually update Naomi, is that what you want?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - read updateChoice - if [ "$updateChoice" = "y" ] || [ "$updateChoice" = "Y" ]; then - if [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"nightly"' ]; then - printf "${B_M}$key ${B_W}- Forcing Update${NL}" - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cd ~ - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"milestone"' ]; then - printf "${B_M}$key ${B_W}- Forcing Update${NL}" - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cd ~ - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"stable"' ]; then - printf "${B_M}$key ${B_W}- Forcing Update${NL}" - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b master Naomi - cd Naomi - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cd ~ - sudo rm -Rf ~/Naomi-Temp - break - else - printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" - echo - fi - elif [ "$updateChoice" = "n" ] || [ "$updateChoice" = "N" ]; then - printf "${B_M}N ${B_W}- Cancelling Update${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" - fi - done - sleep 5 - exec bash $0 -} -naomi_version() { - printf "${B_W}=========================================================================${NL}" - printf "${B_M}Version ${B_W}...${NL}" - printf "${B_W}=========================================================================${NL}" - echo - if [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"stable"' ]; then - printf "${B_W}It looks like you are using '${B_G}Stable${B_W}',${NL}" - printf "${B_W}would you like to change versions?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Milestone${B_Blue} or ${B_M}Nightly${B_Blue} or ${B_M}Quit${B_Blue}]: ${B_W}" - read versionChoice - if [ "$versionChoice" = "Milestone" ] || [ "$versionChoice" = "MILESTONE" ] || [ "$versionChoice" = "milestone" ]; then - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - cat <<< $(jq '.use_release = "milestone"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Milestone ${B_W}- Version Changed${NL}" - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$versionChoice" = "Nightly" ] || [ "$versionChoice" = "NIGHTLY" ] || [ "$versionChoice" = "nightly" ]; then - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - cat <<< $(jq '.use_release = "nightly"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.auto_update = "true"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Nightly ${B_W}- Version Changed${NL}" - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$versionChoice" = "Quit" ] || [ "$versionChoice" = "QUIT" ] || [ "$versionChoice" = "quit" ]; then - printf "${B_M}Quit ${B_W}- Cancelling Version Change${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"milestone"' ]; then - printf "${B_W}It looks like you are using '${B_G}Milestone${B_W}',${NL}" - printf "${B_W}would you like to change versions?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Stable${B_Blue} or ${B_M}Nightly${B_Blue} or ${B_M}Quit${B_Blue}]: ${B_W}" - read versionChoice - if [ "$versionChoice" = "Stable" ] || [ "$versionChoice" = "STABLE" ] || [ "$versionChoice" = "stable" ]; then - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b master Naomi - cd Naomi - cat <<< $(jq '.use_release = "stable"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Stable ${B_W}- Version Changed${NL}" - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$versionChoice" = "Nightly" ] || [ "$versionChoice" = "NIGHTLY" ] || [ "$versionChoice" = "nightly" ]; then - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - cat <<< $(jq '.use_release = "nightly"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.auto_update = "true"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Nightly ${B_W}- Version Changed${NL}" - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$versionChoice" = "Quit" ] || [ "$versionChoice" = "QUIT" ] || [ "$versionChoice" = "quit" ]; then - printf "${B_M}Quit ${B_W}- Cancelling Version Change${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"nightly"' ]; then - printf "${B_W}It looks like you are using '${B_G}Nightly${B_W}',${NL}" - printf "${B_W}would you like to change versions?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Stable${B_Blue} or ${B_M}Milestone${B_Blue} or ${B_M}Quit${B_Blue}]: ${B_W}" - read versionChoice - if [ "$versionChoice" = "Stable" ] || [ "$versionChoice" = "STABLE" ] || [ "$versionChoice" = "stable" ]; then - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b master Naomi - cd Naomi - cat <<< $(jq '.use_release = "stable"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Stable ${B_W}- Version Changed${NL}" - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$versionChoice" = "Milestone" ] || [ "$versionChoice" = "MILESTONE" ] || [ "$versionChoice" = "milestone" ]; then - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - cat <<< $(jq '.use_release = "milestone"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Milestone ${B_W}- Version Changed${NL}" - sudo rm -Rf ~/Naomi-Temp - break - elif [ "$versionChoice" = "Quit" ] || [ "$versionChoice" = "QUIT" ] || [ "$versionChoice" = "quit" ]; then - printf "${B_M}Quit ${B_W}- Cancelling Version Change${NL}" - sleep 5 - exec bash $0 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - else - printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" - fi - sleep 5 - exec bash $0 -} -naomi_autoupdate() { - printf "${B_W}=========================================================================${NL}" - printf "${B_M}AutoUpdate ${B_W}...${NL}" - printf "${B_W}=========================================================================${NL}" - echo - if [ "$(jq '.auto_update' ~/.config/naomi/configs/.naomi_options.json)" = '"true"' ]; then - printf "${B_W}It looks like you have AutoUpdates '${B_G}Enabled${B_W}',${NL}" - printf "${B_W}would you like to disabled AutoUpdates?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - read autoupdateChoice - if [ "$autoupdateChoice" = "y" ] || [ "$autoupdateChoice" = "Y" ]; then - cat <<< $(jq '.auto_update = "false"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Y ${B_W}- AutoUpdate Disabled${NL}" - break - elif [ "$autoupdateChoice" = "n" ] || [ "$autoupdateChoice" = "N" ]; then - printf "${B_M}N ${B_W}- No Change${NL}" - break - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - elif [ "$(jq '.auto_update' ~/.config/naomi/configs/.naomi_options.json)" = '"false"' ]; then - printf "${B_W}It looks like you have AutoUpdates '${B_G}Disabled${B_W}',${NL}" - printf "${B_W}would you like to enable AutoUpdates?${NL}" - echo - while true; do - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - read autoupdateChoice - if [ "$autoupdateChoice" = "y" ] || [ "$autoupdateChoice" = "Y" ]; then - cat <<< $(jq '.auto_update = "true"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json - printf "${B_M}Y ${B_W}- AutoUpdate Enabled${NL}" - break - elif [ "$autoupdateChoice" = "n" ] || [ "$autoupdateChoice" = "N" ]; then - printf "${B_M}N ${B_W}- No Change${NL}" - break - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - fi - done - else - printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" - fi - sleep 5 - exec bash $0 -} - -tput reset -os_detect -curl_check -jq_check -sleep 5 -tput reset -echo -printf "${B_C} ___ ___ ___ ___ ${NL}" -printf "${B_C} /\__\ /\ \ /\ \ /\__\ ___ ${NL}" -printf "${B_C} /::| | /::\ \ /::\ \ /::| | /\ \ ${NL}" -printf "${B_C} /:|:| | /:/\:\ \ /:/\:\ \ /:|:| | \:\ \ ${NL}" -printf "${B_C} /:/|:| |__ /::\~\:\ \ /:/ \:\ \ /:/|:|__|__ /::\__\ ${NL}" -printf "${B_C} /:/ |:| /\__\ /:/\:\ \:\__\ /:/__/ \:\__\ /:/ |::::\__\ __/:/\/__/ ${NL}" -printf "${B_C} \/__|:|/:/ / \/__\:\/:/ / \:\ \ /:/ / \/__/~~/:/ / /\/:/ / ${NL}" -printf "${B_C} |:/:/ / \::/ / \:\ /:/ / /:/ / \::/__/ ${NL}" -printf "${B_C} |::/ / /:/ / \:\/:/ / /:/ / \:\__\ ${NL}" -printf "${B_C} /:/ / /:/ / \::/ / /:/ / \/__/ ${NL}" -printf "${B_C} \/__/ \/__/ \/__/ \/__/ ${NL}" +tput reset sleep 5 -echo +printNaomi if [ "$1" == "--uninstall" ]; then - naomi_uninstall + naomi_uninstall fi -printf "${B_W}=========================================================================${NL}" -printf "${B_W}Welcome to the Naomi Installer. Pick one of the options below to get started:${NL}" -echo -printf "${B_W}'${B_M}Install${B_W}':${NL}" -printf "${B_W}This will fresh install & setup Naomi on your system.${NL}" -echo -printf "${B_W}'${B_M}Uninstall${B_W}':${NL}" -printf "${B_W}This will remove Naomi from your system.${NL}" -echo -printf "${B_W}'${B_M}Update${B_W}':${NL}" -printf "${B_W}This will update Naomi if there is a newer release for your installed version.${NL}" -echo -printf "${B_W}'${B_M}Version${B_W}':${NL}" -printf "${B_W}This will allow you to switch what version of Naomi you have installed.${NL}" -echo -printf "${B_W}'${B_M}AutoUpdate${B_W}':${NL}" -printf "${B_W}This will allow you to enable/disable Naomi auto updates.${NL}" -echo -printf "${B_W}'${B_M}Quit${B_W}'${NL}" -echo -printf "${B_Blue}Input: ${B_W}" -while true; do - read installerChoice - if [ "$installerChoice" = "install" ] || [ "$installerChoice" = "INSTALL" ] || [ "$installerChoice" = "Install" ]; then - naomi_install - break - elif [ "$installerChoice" = "uninstall" ] || [ "$installerChoice" = "UNINSTALL" ] || [ "$installerChoice" = "Uninstall" ]; then - naomi_uninstall - break - elif [ "$installerChoice" = "update" ] || [ "$installerChoice" = "UPDATE" ] || [ "$installerChoice" = "Update" ]; then - naomi_update - break - elif [ "$installerChoice" = "version" ] || [ "$installerChoice" = "VERSION" ] || [ "$installerChoice" = "Version" ]; then - naomi_version - break - elif [ "$installerChoice" = "autoupdate" ] || [ "$installerChoice" = "AUTOUPDATE" ] || [ "$installerChoice" = "AutoUpdate" ] || [ "$installerChoice" = "Autoupdate" ] || [ "$installerChoice" = "autoUpdate" ]; then - naomi_autoupdate - break - elif [ "$installerChoice" = "quit" ] || [ "$installerChoice" = "QUIT" ] || [ "$installerChoice" = "Quit" ]; then - echo "EXITING" - exit 1 - else - printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" - echo - printf "${B_Blue}Input: ${B_W}" - fi -done \ No newline at end of file +installOptions diff --git a/installers/script.deb.sh b/installers/script.deb.sh index 89af5b97..0f2dc8ee 100755 --- a/installers/script.deb.sh +++ b/installers/script.deb.sh @@ -1,5 +1,9 @@ #!/bin/bash +source "scripts/misc.sh" +source "scripts/pre_checks.sh" +source "scripts/naomi_cmds.sh" + ######################################### # Installs python and necessary packages # for deb based Naomi. This script will install python @@ -7,84 +11,9 @@ # install naomi & requirements in their # respective directories. ######################################### -BLACK='\033[1;30m' -RED='\033[1;31m' -GREEN='\033[1;32m' -YELLOW='\033[1;33m' -BLUE='\033[1;34m' -MAGENTA='\033[1;35m' -CYAN='\033[1;36m' -WHITE='\033[1;37m' -B_C='\033[1;96m' #Bright Cyan For logo -B_R='\033[1;91m' #Bright Red For alerts/errors -B_G='\033[1;92m' #Bright Green For initiating a process i.e. "Installing blah blah..." or calling attention to thing in outputs -B_Y='\033[1;93m' #Bright Yellow For urls & emails -B_Black='\033[1;90m' #Bright Black For lower text -B_Blue='\033[1;94m' #Bright Blue For prompt question -B_M='\033[1;95m' #Bright Magenta For prompt choices -B_W='\033[1;97m' #Bright White For standard text output -NL=" -" -OPTION="0" -SUDO_APPROVE="" -REQUIRE_AUTH="" -version="3.0" -theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S) -gitVersionNumber=$(git rev-parse --short HEAD) -gitURL="https://github.com/naomiproject/naomi" - -CONTINUE() { - printf "${B_W}If you want to allow the process to run uninterrupted type '${B_G}S${B_W}'${NL}" - printf "${B_W}or press '${B_G}Q${B_W}' to quit, any other key to continue:${NL}" - read -n1 -p "" CONTINUE - echo - if [ "$CONTINUE" = "q" ] || [ "$CONTINUE" = "Q" ]; then - echo - printf "${B_R}EXITING${B_W}${NL}" - exit 1 - elif [ "$CONTINUE" = "S" ] || [ "$CONTINUE" = "s" ]; then - REQUIRE_AUTH="0" - SUDO_APPROVE="-y" - fi -} -SUDO_COMMAND() { - echo - printf "${B_R}Notice:${B_W} this program is about to use sudo to run the following command:${NL}" - printf "[$(pwd)]\$ ${B_G}${1}${B_W}${NL}" - echo - if [ "$SUDO_APPROVE" != "-y" ]; then - CONTINUE - fi - $1 -} -CHECK_HEADER() { - echo "#include <$1>" | cpp $(pkg-config alsa --cflags) -H -o /dev/null > /dev/null 2>&1 - echo $? -} -CHECK_PROGRAM() { - type -p "$1" > /dev/null 2>&1 - echo $? -} setup_wizard() { - echo - printf "${B_W}=========================================================================${NL}" - printf "${B_W}DEB SETUP WIZARD${NL}" - printf "${B_W}This process will first walk you through setting up your device,${NL}" - printf "${B_W}installing Naomi, and default plugins.${NL}" - echo - sleep 3 - echo - echo - - echo - printf "${B_W}=========================================================================${NL}" - printf "${B_W}LOCALIZATION SETUP:${NL}" - printf "${B_W}Let's examine your localization settings.${NL}" - echo - sleep 3 - echo - + WizardSetup() echo printf "${B_W}=========================================================================${NL}" printf "${B_W}SECURITY SETUP:${NL}" @@ -123,144 +52,45 @@ setup_wizard() { echo echo - echo - printf "${B_W}=========================================================================${NL}" - printf "${B_W}ENVIRONMENT SETUP:${NL}" - printf "${B_W}Now setting up the file stuctures & requirements${NL}" - echo - sleep 3 - echo - - # Create basic folder structures - echo - printf "${B_G}Creating File Structure...${B_W}${NL}" - mkdir -p ~/.config/naomi/ - mkdir -p ~/.config/naomi/configs/ - mkdir -p ~/.config/naomi/scripts/ - mkdir -p ~/.config/naomi/sources/ + env + createDirs - # Download and setup Naomi Dev repo as default - echo - printf "${B_G}Installing 'git'...${B_W}${NL}" - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo apt-get install git $SUDO_APPROVE" - else - printf "${B_W}${NL}" - sudo apt-get install git $SUDO_APPROVE - fi - echo + naomiChannel - echo - printf "${B_W}=========================================================================${NL}" - printf "${B_W}NAOMI SETUP:${NL}" - printf "${B_W}Naomi is continuously updated. There are three options to choose from:${NL}" - echo - printf "${B_W}'${B_G}Stable${B_W}' versions are thoroughly tested official releases of Naomi. Use${NL}" - printf "${B_W}the stable version for your production environment if you don't need the${NL}" - printf "${B_W}latest enhancements and prefer a robust system${NL}" - echo - printf "${B_W}'${B_G}Milestone${B_W}' versions are intermediary releases of the next Naomi version,${NL}" - printf "${B_W}released about once a month, and they include the new recently added${NL}" - printf "${B_W}features and bugfixes. They are a good compromise between the current${NL}" - printf "${B_W}stable version and the bleeding-edge and potentially unstable nightly version.${NL}" - echo - printf "${B_W}'${B_G}Nightly${B_W}' versions are at most 1 or 2 days old and include the latest code.${NL}" - printf "${B_W}Use nightly for testing out very recent changes, but be aware some nightly${NL}" - printf "${B_W}versions might be unstable. Use in production at your own risk!${NL}" - echo - printf "${B_W}Note: '${B_G}Nightly${B_W}' comes with automatic updates by default!${NL}" - echo - printf "${B_M} 1${B_W}) Use the recommended ('${B_G}Stable${B_W}')${NL}" - printf "${B_M} 2${B_W}) Monthly releases sound good to me ('${B_G}Milestone${B_W}')${NL}" - printf "${B_M} 3${B_W}) I'm a developer or want the cutting edge, put me on '${B_G}Nightly${B_W}'${NL}" - printf "${B_Blue}Choice [${B_M}1${B_Blue}-${B_M}3${B_Blue}]: ${B_W}" while true; do read -N1 -s key case $key in 1) - printf "${B_M}$key ${B_W}- Easy Peasy!${NL}" - cd ~ - if [ ! -f ~/Naomi/README.md ]; then - printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" - cd ~ - git clone $gitURL.git -b master Naomi - cd Naomi - echo '{"use_release":"stable", "branch":"master", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - else - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b master Naomi - cd Naomi - echo '{"use_release":"stable", "branch":"master", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - fi + defaultFlavor break ;; 2) - printf "${B_M}$key ${B_W}- Good Choice!${NL}" - echo '{"use_release":"milestone", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - if [ ! -f ~/Naomi/README.md ]; then - printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - echo '{"use_release":"milestone", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - else - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - echo '{"use_release":"milestone", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - fi - break - ;; + stableVersion + break + ;; 3) - printf "${B_M}$key ${B_W}- You know what you are doing!${NL}" - cd ~ - if [ ! -f ~/Naomi/README.md ]; then - printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - echo '{"use_release":"nightly", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"true"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - else - mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi - echo '{"use_release":"nightly", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"true"}' > ~/.config/naomi/configs/.naomi_options.json - cd ~ - fi - break - ;; + nightlyVersion + break + ;; S) - printf "${B_M}$key ${B_W}- Skipping Section${NL}" - echo '{"use_release":"testing", "version":"Naomi-Development", "version":"Development", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json - break - ;; + skipFlavor + break + ;; esac done echo echo - find ~/Naomi -maxdepth 1 -iname '*.py' -type f -exec chmod a+x {} \; - find ~/Naomi -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; - find ~/Naomi/installers -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; + findScripts NAOMI_DIR="$(cd ~/Naomi && pwd)" - cd ~/Naomi APT=1 if [ $APT -eq 1 ]; then if [ $REQUIRE_AUTH -eq 1 ]; then SUDO_COMMAND "sudo apt-get update" SUDO_COMMAND "sudo apt upgrade $SUDO_APPROVE" - SUDO_COMMAND "sudo ./naomi_apt_requirements.sh $SUDO_APPROVE" + SUDO_COMMAND "sudo ./naomi_requirements.sh $SUDO_APPROVE" if [ $? -ne 0 ]; then printf "${B_R}Notice:${B_W} Error installing apt packages${NL}" >&2 exit 1 @@ -269,7 +99,7 @@ setup_wizard() { printf "${B_W}${NL}" sudo apt-get update sudo apt upgrade $SUDO_APPROVE - sudo ./naomi_apt_requirements.sh $SUDO_APPROVE + sudo ./naomi_requirements.sh $SUDO_APPROVE if [ $? -ne 0 ]; then printf "${B_R}Notice:${B_W} Error installing apt packages${NL}" >&2 exit 1 @@ -304,398 +134,39 @@ setup_wizard() { pulseaudio -D fi - pip3 install --user virtualenv virtualenvwrapper=='4.8.4' - printf "${B_G}sourcing virtualenvwrapper.sh${B_W}${NL}" - export WORKON_HOME=$HOME/.virtualenvs - export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 - export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv - source ~/.local/bin/virtualenvwrapper.sh - export VIRTUALENVWRAPPER_ENV_BIN_DIR=bin - printf "${B_G}checking if Naomi virtualenv exists${B_W}${NL}" - workon Naomi > /dev/null 2>&1 - if [ $? -ne 0 ]; then - printf "${B_G}Naomi virtualenv does not exist. Creating.${B_W}${NL}" - PATH=$PATH:~/.local/bin mkvirtualenv -p python3 Naomi - fi - workon Naomi - if [ "$(which pip)" = "$HOME/.virtualenvs/Naomi/bin/pip" ]; then - echo - echo - echo - echo - printf "${B_W}If you want, we can add the call to start virtualenvwrapper directly${NL}" - printf "${B_W}to the end of your ${B_G}~/.bashrc${B_W} file, so if you want to use the same${NL}" - printf "${B_W}python that Naomi does for debugging or installing additional${NL}" - printf "${B_W}dependencies, all you have to type is '${B_G}workon Naomi${B_W}'${NL}" - echo - printf "${B_W}Otherwise, you will need to enter:${NL}" - printf "${B_W}'${B_G}VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv${B_W}'${NL}" - printf "${B_W}'${B_G}source ~/.local/bin/virtualenvwrapper.sh${B_W}'${NL}" - printf "${B_W}before you will be able activate the Naomi environment with '${B_G}workon Naomi${B_W}'${NL}" - echo - printf "${B_W}All of this will be incorporated into the Naomi script, so to simply${NL}" - printf "${B_W}launch Naomi, all you have to type is '${B_G}Naomi${B_W}' in a terminal regardless of your choice here.${NL}" - echo - printf "${B_W}Would you like to start VirtualEnvWrapper automatically?${NL}" - echo - printf "${B_M} Y${B_W})es, start virtualenvwrapper whenever I start a shell${NL}" - printf "${B_M} N${B_W})o, don't start virtualenvwrapper for me${NL}" - printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" - export AUTO_START="" - if [ "$SUDO_APPROVE" = "-y" ]; then - AUTO_START="Y" - else - while [ "$AUTO_START" != "Y" ] && [ "$AUTO_START" != "y" ] && [ "$AUTO_START" != "N" ] && [ "$AUTO_START" != "n" ]; do - read -e -p 'Please select: ' AUTO_START - if [ "$AUTO_START" = "" ]; then - AUTO_START="Y" - fi - if [ "$AUTO_START" != "Y" ] && [ "$AUTO_START" != "y" ] && [ "$AUTO_START" != "N" ] && [ "$AUTO_START" != "n" ]; then - printf "${B_R}Notice:${B_W} Please choose 'Y' or 'N'" - fi - done - fi - if [ "$AUTO_START" = "Y" ] || [ "$AUTO_START" = "y" ]; then - printf "${B_W}${NL}" - echo '' >> ~/.bashrc - echo '' >> ~/.bashrc - echo '' >> ~/.bashrc - echo '######################################################################' >> ~/.bashrc - echo '# Initialize Naomi VirtualEnvWrapper' >> ~/.bashrc - echo '######################################################################' >> ~/.bashrc - echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc - echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc - echo "export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv" >> ~/.bashrc - echo "source ~/.local/bin/virtualenvwrapper.sh" >> ~/.bashrc - fi - pip install -r python_requirements.txt - if [ $? -ne 0 ]; then - printf "${B_R}Notice:${B_W} Error installing python requirements: ${NL}${NL}$!" >&2 - exit 1 - fi - else - printf "${B_R}Notice:${B_W} Something went wrong, not in virtual environment...${NL}" >&2 - exit 1 - fi - # start the naomi setup process - printf "${B_W}${NL}" - echo - echo - echo '' >> ~/.bashrc - echo '' >> ~/.bashrc - echo '' >> ~/.bashrc - echo '######################################################################' >> ~/.bashrc - echo '# Initialize Naomi to start on command' >> ~/.bashrc - echo '######################################################################' >> ~/.bashrc - echo 'source ~/.config/naomi/Naomi.sh' >> ~/.bashrc - echo - echo - echo '[Desktop Entry]' > ~/Desktop/Naomi.desktop - echo 'Name=Naomi' >> ~/Desktop/Naomi.desktop - echo 'Comment=Your privacy respecting digital assistant' >> ~/Desktop/Naomi.desktop - echo 'Icon=/home/pi/Naomi/Naomi.png' >> ~/Desktop/Naomi.desktop - echo 'Exec=Naomi' >> ~/Desktop/Naomi.desktop - echo 'Type=Application' >> ~/Desktop/Naomi.desktop - echo 'Encoding=UTF-8' >> ~/Desktop/Naomi.desktop - echo 'Terminal=True' >> ~/Desktop/Naomi.desktop - echo 'Categories=None;' >> ~/Desktop/Naomi.desktop - echo - echo - echo "#!/bin/bash" > ~/.config/naomi/Naomi.sh - echo "" >> ~/.config/naomi/Naomi.sh - echo "B_W='\033[1;97m' #Bright White For standard text output" >> ~/.config/naomi/Naomi.sh - echo "B_R='\033[1;91m' #Bright Red For alerts/errors" >> ~/.config/naomi/Naomi.sh - echo "B_Blue='\033[1;94m' #Bright Blue For prompt question" >> ~/.config/naomi/Naomi.sh - echo "B_M='\033[1;95m' #Bright Magenta For prompt choices" >> ~/.config/naomi/Naomi.sh - echo 'NL="' >> ~/.config/naomi/Naomi.sh - echo '"' >> ~/.config/naomi/Naomi.sh - echo 'version="3.0"' >> ~/.config/naomi/Naomi.sh - echo 'theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S)' >> ~/.config/naomi/Naomi.sh - echo 'gitURL="https://github.com/naomiproject/naomi"' >> ~/.config/naomi/Naomi.sh - echo "" >> ~/.config/naomi/Naomi.sh - echo "function Naomi() {" >> ~/.config/naomi/Naomi.sh - echo " if [ \"\$(jq '.auto_update' ~/.config/naomi/configs/.naomi_options.json)\" = '\"true\"' ]; then" >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_W}=========================================================================${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_W}Checking for Naomi Updates...${NL}"' >> ~/.config/naomi/Naomi.sh - echo " cd ~/Naomi" >> ~/.config/naomi/Naomi.sh - echo " git fetch -q " >> ~/.config/naomi/Naomi.sh - echo ' if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ] ; then' >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_W}Downloading & Installing Updates...${NL}"' >> ~/.config/naomi/Naomi.sh - echo " git pull" >> ~/.config/naomi/Naomi.sh - echo " sudo apt-get -o Acquire::ForceIPv4=true update -y" >> ~/.config/naomi/Naomi.sh - echo " sudo apt -o upgrade -y" >> ~/.config/naomi/Naomi.sh - echo " sudo ./naomi_apt_requirements.sh -y" >> ~/.config/naomi/Naomi.sh - echo " else" >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_W}No Updates Found.${NL}"' >> ~/.config/naomi/Naomi.sh - echo " fi" >> ~/.config/naomi/Naomi.sh - echo " else" >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_R}Notice: ${B_W}Naomi Auto Update Failed!${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_R}Notice: ${B_W}Would you like to force update Naomi?${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}"' >> ~/.config/naomi/Naomi.sh - echo ' while true; do' >> ~/.config/naomi/Naomi.sh - echo ' read -N1 -s key' >> ~/.config/naomi/Naomi.sh - echo ' case $key in' >> ~/.config/naomi/Naomi.sh - echo ' Y)' >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo " if [ \"\$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)\" = '\"nightly\"' ]; then" >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo " git clone \$gitURL.git -b naomi-dev Naomi" >> ~/.config/naomi/Naomi.sh - echo ' cd Naomi' >> ~/.config/naomi/Naomi.sh - echo " echo '{\"use_release\":\"nightly\", \"branch\":\"naomi-dev\", \"version\":\"Naomi-\$version.\$(git rev-parse --short HEAD)\", \"date\":\"\$theDateRightNow\", \"auto_update\":\"true\"}' > ~/.config/naomi/configs/.naomi_options.json" >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo ' break' >> ~/.config/naomi/Naomi.sh - echo " elif [ \"\$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)\" = '\"milestone\"' ]; then" >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo " git clone \$gitURL.git -b naomi-dev Naomi" >> ~/.config/naomi/Naomi.sh - echo ' cd Naomi' >> ~/.config/naomi/Naomi.sh - echo " echo '{\"use_release\":\"milestone\", \"branch\":\"naomi-dev\", \"version\":\"Naomi-\$version.\$(git rev-parse --short HEAD)\", \"date\":\"\$theDateRightNow\", \"auto_update\":\"true\"}' > ~/.config/naomi/configs/.naomi_options.json" >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo ' break' >> ~/.config/naomi/Naomi.sh - echo " elif [ \"\$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)\" = '\"stable\"' ]; then" >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo " git clone \$gitURL.git -b master Naomi" >> ~/.config/naomi/Naomi.sh - echo ' cd Naomi' >> ~/.config/naomi/Naomi.sh - echo " echo '{\"use_release\":\"stable\", \"branch\":\"master\", \"version\":\"Naomi-\$version.\$(git rev-parse --short HEAD)\", \"date\":\"\$theDateRightNow\", \"auto_update\":\"false\"}' > ~/.config/naomi/configs/.naomi_options.json" >> ~/.config/naomi/Naomi.sh - echo ' cd ~' >> ~/.config/naomi/Naomi.sh - echo ' fi' >> ~/.config/naomi/Naomi.sh - echo ' break' >> ~/.config/naomi/Naomi.sh - echo ' ;;' >> ~/.config/naomi/Naomi.sh - echo ' N)' >> ~/.config/naomi/Naomi.sh - echo ' printf "${B_M}$key ${B_W}- Launching Naomi!${NL}"' >> ~/.config/naomi/Naomi.sh - echo ' break' >> ~/.config/naomi/Naomi.sh - echo ' ;;' >> ~/.config/naomi/Naomi.sh - echo ' esac' >> ~/.config/naomi/Naomi.sh - echo ' done' >> ~/.config/naomi/Naomi.sh - echo " fi" >> ~/.config/naomi/Naomi.sh - echo " export WORKON_HOME=$HOME/.virtualenvs" >> ~/.config/naomi/Naomi.sh - echo " export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.config/naomi/Naomi.sh - echo " export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv" >> ~/.config/naomi/Naomi.sh - echo " source ~/.local/bin/virtualenvwrapper.sh" >> ~/.config/naomi/Naomi.sh - echo " workon Naomi" >> ~/.config/naomi/Naomi.sh - echo " python $NAOMI_DIR/Naomi.py \"\$@\"" >> ~/.config/naomi/Naomi.sh - echo "}" >> ~/.config/naomi/Naomi.sh - echo - echo - echo - echo + setupVenv + + findScripts - find ~/Naomi -maxdepth 1 -iname '*.py' -type f -exec chmod a+x {} \; - find ~/Naomi -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; - find ~/.config/naomi -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; - find ~/Naomi/installers -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; + # start the naomi setup process + processNaomi - echo - printf "${B_W}=========================================================================${NL}" - printf "${B_W}PLUGIN SETUP${NL}" - printf "${B_W}Now we'll tackle the default plugin options available for Text-to-Speech, Speech-to-Text, and more.${NL}" - echo - sleep 3 - echo + pluginMsg - # Build Phonetisaurus + # Get packages & build Phonetisaurus # Building and installing openfst - echo - printf "${B_G}Building and installing openfst...${B_W}${NL}" - cd ~/.config/naomi/sources - - if [ ! -f "openfst-1.6.9.tar.gz" ]; then - wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.6.9.tar.gz - fi - tar -zxvf openfst-1.6.9.tar.gz - cd openfst-1.6.9 - autoreconf -i - ./configure --enable-static --enable-shared --enable-far --enable-lookahead-fsts --enable-const-fsts --enable-pdt --enable-ngram-fsts --enable-linear-fsts --prefix=/usr - make - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo make install" - if [ $? -ne 0 ]; then - echo $! >&2 - exit 1 - fi - else - printf "${B_W}${NL}" - sudo make install - if [ $? -ne 0 ]; then - echo $! >&2 - exit 1 - fi - fi - - if [ -z "$(which fstinfo)" ]; then - printf "${ERROR} ${B_R}Notice:${B_W} openfst not installed${NL}" >&2 - exit 1 - fi + openfst # Building and installing mitlm-0.4.2 - echo - printf "${B_G}Installing & Building mitlm-0.4.2...${B_W}${NL}" - cd ~/.config/naomi/sources - if [ ! -d "mitlm" ]; then - git clone https://github.com/mitlm/mitlm.git - if [ $? -ne 0 ]; then - printf "${ERROR} ${B_R}Notice:${B_W} Error cloning mitlm${NL}" - exit 1 - fi - fi - cd mitlm - ./autogen.sh - make - printf "${B_G}Installing mitlm${B_W}${NL}" - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo make install" - if [ $? -ne 0 ]; then - echo $! >&2 - exit 1 - fi - else - printf "${B_W}${NL}" - sudo make install - if [ $? -ne 0 ]; then - echo $! >&2 - exit 1 - fi - fi + mitlm # Building and installing CMUCLMTK - echo - printf "${B_G}Installing & Building cmuclmtk...${B_W}${NL}" - cd ~/.config/naomi/sources - svn co https://svn.code.sf.net/p/cmusphinx/code/trunk/cmuclmtk/ - if [ $? -ne 0 ]; then - printf "${ERROR} ${B_R}Notice:${B_W} Error cloning cmuclmtk${NL}" >&2 - exit 1 - fi - cd cmuclmtk - ./autogen.sh - make - printf "${B_G}Installing CMUCLMTK${B_W}${NL}" - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo make install" - else - printf "${B_W}${NL}" - sudo make install - fi - - printf "${B_G}Linking shared libraries${B_W}${NL}" - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo ldconfig" - else - printf "${B_W}${NL}" - sudo ldconfig - fi - + cmuclmtk + # Building and installing phonetisaurus - echo - printf "${B_G}Installing & Building phonetisaurus...${B_W}${NL}" - cd ~/.config/naomi/sources - if [ ! -d "Phonetisaurus" ]; then - git clone https://github.com/AdolfVonKleist/Phonetisaurus.git - if [ $? -ne 0 ]; then - printf "${ERROR} ${B_R}Notice:${B_W} Error cloning Phonetisaurus${NL}" >&2 - exit 1 - fi - fi - cd Phonetisaurus - ./configure --enable-python - make - printf "${B_G}Installing Phonetisaurus${B_W}${NL}" - printf "${B_G}Linking shared libraries${B_W}${NL}" - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo make install" - else - printf "${B_W}${NL}" - sudo make install - fi - - printf "[$(pwd)]\$ ${B_G}cd python${B_W}${NL}" - cd python - echo $(pwd) - cp -v ../.libs/Phonetisaurus.so ./ - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo python setup.py install" - else - printf "${B_W}${NL}" - sudo python setup.py install - fi - - if [ -z "$(which phonetisaurus-g2pfst)" ]; then - printf "${ERROR} ${B_R}Notice:${B_W} phonetisaurus-g2pfst does not exist${NL}" >&2 - exit 1 - fi + #phonetisaurus # Installing & Building sphinxbase - echo - printf "${B_G}Building and installing sphinxbase...${B_W}${NL}" - cd ~/.config/naomi/sources - if [ ! -d "pocketsphinx-python" ]; then - git clone --recursive https://github.com/bambocher/pocketsphinx-python.git - if [ $? -ne 0 ]; then - printf "${ERROR} ${B_R}Notice:${B_W} Error cloning pocketsphinx${NL}" >&2 - exit 1 - fi - fi - cd pocketsphinx-python/deps/sphinxbase - ./autogen.sh - make - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo make install" - else - printf "${B_W}${NL}" - sudo make install - fi - + sphinxbase + # Installing & Building pocketsphinx - echo - printf "${B_G}Building and installing pocketsphinx...${B_W}${NL}" - cd ~/.config/naomi/sources/pocketsphinx-python/deps/pocketsphinx - ./autogen.sh - make - if [ $REQUIRE_AUTH -eq 1 ]; then - SUDO_COMMAND "sudo make install" - else - printf "${B_W}${NL}" - sudo make install - fi + pocketsphinx # Installing PocketSphinx Python module - echo - printf "${B_G}Installing PocketSphinx module...${B_W}${NL}" - cd ~/.config/naomi/sources/pocketsphinx-python - python setup.py install - - cd $NAOMI_DIR - if [ -z "$(which text2wfreq)" ]; then - printf "${ERROR} ${B_R}Notice:${B_W} text2wfreq does not exist${NL}" >&2 - exit 1 - fi - if [ -z "$(which text2idngram)" ]; then - printf "${ERROR} ${B_R}Notice:${B_W} text2idngram does not exist${NL}" >&2 - exit 1 - fi - if [ -z "$(which idngram2lm)" ]; then - printf "${ERROR} ${B_R}Notice:${B_W} idngram2lm does not exist${NL}" >&2 - exit 1 - fi + pocketSphinx_python # Compiling Translations - echo - printf "${B_G}Compiling Translations...${B_W}${NL}" - cd ~/Naomi - chmod a+x compile_translations.sh - ./compile_translations.sh - cd ~ - echo - echo - echo - echo + compileTranslations } setup_wizard diff --git a/naomi_apt_requirements.sh b/naomi_apt_requirements.sh deleted file mode 100755 index 009107d8..00000000 --- a/naomi_apt_requirements.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -SUDO_APPROVE="" -for var in "$@"; do - if [ "$var" = "-y" ] || [ "$var" = "--yes" ]; then - SUDO_APPROVE="-y" - fi -done -xargs -a <(awk '! /^ *(#|$)/' apt_requirements.txt) -r -- apt install $SUDO_APPROVE - diff --git a/naomi_requirements.sh b/naomi_requirements.sh new file mode 100755 index 00000000..ac9e4ce5 --- /dev/null +++ b/naomi_requirements.sh @@ -0,0 +1,38 @@ +#!/bin/bash +SUDO_APPROVE="" +#TODO: Fix the arch scripts later +DebianSetup() { + for var in "$@"; do + if [ "$var" = "-y" ] || [ "$var" = "--yes" ]; then + SUDO_APPROVE="-y" + fi + done + xargs -a <(awk '! /^ *(#|$)/' apt_requirements.txt) -r -- apt install $SUDO_APPROVE +} + +ArchSetup() { + for var in "$@"; do + if [ "$var" = "-y" ] || [ "$var" = "--yes" ]; then + SUDO_APPROVE="--noconfirm" + fi + done + xargs -a <(awk '! /^ *(#|$)/' arch_requirements.txt) -r -- pacman -Syu $SUDO_APPROVE +} + +if [ -e /etc/os-release ]; then + . /etc/os-release + os=${ID} + os_like=${ID_LIKE} + if [ "${os_like}" = "arch" ]; then + ArchSetup + elif [ "${os}" = "debian" ]; then + DebianSetup + elif [ "${os}" = "ubuntu" ]; then + DebianSetup + elif [ "${os}" = "arch" ]; then + ArchSetup + fi +else + echo "Can't detect OS script will exit now..." + exit 1 +fi diff --git a/python_requirements.txt b/python_requirements.txt index 7e97ba50..7876ec35 100644 --- a/python_requirements.txt +++ b/python_requirements.txt @@ -48,7 +48,7 @@ webrtcvad # NaomiSTTTrain cython pandas -sklearn +scikit-learn jiwer # Development diff --git a/scripts/misc.sh b/scripts/misc.sh new file mode 100644 index 00000000..5850c762 --- /dev/null +++ b/scripts/misc.sh @@ -0,0 +1,235 @@ +#!/bin/bash + +######################################### +# Miscellaneous Script That has variables +# For Naomi Build Scripts +######################################### + +TEXT='\033[0m' +BLACK='\033[1;30m' +RED='\033[1;31m' +GREEN='\033[1;32m' +YELLOW='\033[1;33m' +BLUE='\033[1;34m' +MAGENTA='\033[1;35m' +CYAN='\033[1;36m' +WHITE='\033[1;37m' +B_C='\033[1;96m' #Bright Cyan For logo +B_R='\033[1;91m' #Bright Red For alerts/errors +B_G='\033[1;92m' #Bright Green For initiating a process i.e. "Installing blah blah..." or calling attention to thing in outputs +B_Y='\033[1;93m' #Bright Yellow For urls & emails +B_Black='\033[1;90m' #Bright Black For lower text +B_Blue='\033[1;94m' #Bright Blue For prompt question +B_M='\033[1;95m' #Bright Magenta For prompt choices +B_W='\033[1;97m' #Bright White For standard text output +NL=" +" +OPTION="0" +SUDO_APPROVE="" +version="3.0" +theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S) +gitVersionNumber=$(git rev-parse --short HEAD) +gitURL="https://github.com/naomiproject/naomi" + +GIT="git" +JQ="jq" +CURL="curl" +PYTHON="python" +ZIP="zip" + +## Set ARCH (Deb, Ubuntu) +ARCH="" + +printNaomi() { + + echo + printf "${B_C} ___ ___ ___ ___ ${NL}" + printf "${B_C} /\__\ /\ \ /\ \ /\__\ ___ ${NL}" + printf "${B_C} /::| | /::\ \ /::\ \ /::| | /\ \ ${NL}" + printf "${B_C} /:|:| | /:/\:\ \ /:/\:\ \ /:|:| | \:\ \ ${NL}" + printf "${B_C} /:/|:| |__ /::\~\:\ \ /:/ \:\ \ /:/|:|__|__ /::\__\ ${NL}" + printf "${B_C} /:/ |:| /\__\ /:/\:\ \:\__\ /:/__/ \:\__\ /:/ |::::\__\ __/:/\/__/ ${NL}" + printf "${B_C} \/__|:|/:/ / \/__\:\/:/ / \:\ \ /:/ / \/__/~~/:/ / /\/:/ / ${NL}" + printf "${B_C} |:/:/ / \::/ / \:\ /:/ / /:/ / \::/__/ ${NL}" + printf "${B_C} |::/ / /:/ / \:\/:/ / /:/ / \:\__\ ${NL}" + printf "${B_C} /:/ / /:/ / \::/ / /:/ / \/__/ ${NL}" + printf "${B_C} \/__/ \/__/ \/__/ \/__/ ${NL}" + + sleep 5 + + echo + +} + +createDirs(){ + # Create basic folder structures + echo + printf "${B_G}Creating File Structure...${B_W}${NL}" + mkdir -p ~/.config/naomi/ + mkdir -p ~/.config/naomi/configs/ + mkdir -p ~/.config/naomi/scripts/ + mkdir -p ~/.config/naomi/sources/ + +} + +installDone() { + echo + echo + echo + echo + printf "${B_W}=========================================================================${NL}" + echo + printf "${B_W}That's all, installation is complete! All that is left is the profile${NL}" + printf "${B_W}population process and after that Naomi will start.${NL}" + echo + printf "${B_W}In the future, to start Naomi type '${B_G}Naomi${B_W}' in a terminal${NL}" + echo + printf "${B_W}Please type '${B_G}Naomi --repopulate${B_W}' on the prompt below to populate your profile...${NL}" + sudo rm -Rf ~/Naomi-Temp + # Launch Naomi Population + cd ~/Naomi + chmod a+x Naomi.sh + cd ~ + exec bash +} + +existingInstall() { + printf "${B_W}=========================================================================${NL}" + printf "${B_W}It looks like you have Naomi source in the ${B_G}~/Naomi${B_W} directory,${NL}" + printf "${B_W}however it looks to be out of date. Please update or remove the Naomi${NL}" + printf "${B_W}source and try running the installer again.${NL}" + echo + printf "${B_W}Please join our Discord or email us at ${B_Y}contact@projectnaomi.com${B_W} and let us know if you run into any issues.${NL}" + exit 1 +} + +wizardSetup(){ + + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}DEB SETUP WIZARD${NL}" + printf "${B_W}This process will first walk you through setting up your device,${NL}" + printf "${B_W}installing Naomi, and default plugins.${NL}" + echo + sleep 3 + echo + echo + + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}LOCALIZATION SETUP:${NL}" + printf "${B_W}Let's examine your localization settings.${NL}" + echo + sleep 3 + echo +} + +env(){ + echo + echo + echo + + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}ENVIRONMENT SETUP:${NL}" + printf "${B_W}Now setting up the file stuctures & requirements${NL}" + echo + sleep 3 + echo + + +} + +naomiChannel(){ + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}NAOMI SETUP:${NL}" + printf "${B_W}Naomi is continuously updated. There are three options to choose from:${NL}" + echo + printf "${B_W}'${B_G}Stable${B_W}' versions are thoroughly tested official releases of Naomi. Use${NL}" + printf "${B_W}the stable version for your production environment if you don't need the${NL}" + printf "${B_W}latest enhancements and prefer a robust system${NL}" + echo + printf "${B_W}'${B_G}Milestone${B_W}' versions are intermediary releases of the next Naomi version,${NL}" + printf "${B_W}released about once a month, and they include the new recently added${NL}" + printf "${B_W}features and bugfixes. They are a good compromise between the current${NL}" + printf "${B_W}stable version and the bleeding-edge and potentially unstable nightly version.${NL}" + echo + printf "${B_W}'${B_G}Nightly${B_W}' versions are at most 1 or 2 days old and include the latest code.${NL}" + printf "${B_W}Use nightly for testing out very recent changes, but be aware some nightly${NL}" + printf "${B_W}versions might be unstable. Use in production at your own risk!${NL}" + echo + printf "${B_W}Note: '${B_G}Nightly${B_W}' comes with automatic updates by default!${NL}" + echo + printf "${B_M} 1${B_W}) Use the recommended ('${B_G}Stable${B_W}')${NL}" + printf "${B_M} 2${B_W}) Monthly releases sound good to me ('${B_G}Milestone${B_W}')${NL}" + printf "${B_M} 3${B_W}) I'm a developer or want the cutting edge, put me on '${B_G}Nightly${B_W}'${NL}" + printf "${B_Blue}Choice [${B_M}1${B_Blue}-${B_M}3${B_Blue}]: ${B_W}" +} + +installOptions() { +printf "${B_W}=========================================================================${NL}" +printf "${B_W}Welcome to the Naomi Installer. Pick one of the options below to get started:${NL}" +echo +printf "${B_W}'${B_M}Install${B_W}':${NL}" +printf "${B_W}This will fresh install & setup Naomi on your system.${NL}" +echo +printf "${B_W}'${B_M}Uninstall${B_W}':${NL}" +printf "${B_W}This will remove Naomi from your system.${NL}" +echo +printf "${B_W}'${B_M}Update${B_W}':${NL}" +printf "${B_W}This will update Naomi if there is a newer release for your installed version.${NL}" +echo +printf "${B_W}'${B_M}Version${B_W}':${NL}" +printf "${B_W}This will allow you to switch what version of Naomi you have installed.${NL}" +echo +printf "${B_W}'${B_M}AutoUpdate${B_W}':${NL}" +printf "${B_W}This will allow you to enable/disable Naomi auto updates.${NL}" +echo +printf "${B_W}'${B_M}Quit${B_W}'${NL}" +echo +printf "${B_Blue}Input: ${B_W}" +while true; do + read installerChoice + if [ "$installerChoice" = "install" ] || [ "$installerChoice" = "INSTALL" ] || [ "$installerChoice" = "Install" ]; then + naomi_install + break + elif [ "$installerChoice" = "uninstall" ] || [ "$installerChoice" = "UNINSTALL" ] || [ "$installerChoice" = "Uninstall" ]; then + naomi_uninstall + break + elif [ "$installerChoice" = "update" ] || [ "$installerChoice" = "UPDATE" ] || [ "$installerChoice" = "Update" ]; then + naomi_update + break + elif [ "$installerChoice" = "version" ] || [ "$installerChoice" = "VERSION" ] || [ "$installerChoice" = "Version" ]; then + naomi_version + break + elif [ "$installerChoice" = "autoupdate" ] || [ "$installerChoice" = "AUTOUPDATE" ] || [ "$installerChoice" = "AutoUpdate" ] || [ "$installerChoice" = "Autoupdate" ] || [ "$installerChoice" = "autoUpdate" ]; then + naomi_autoupdate + break + elif [ "$installerChoice" = "quit" ] || [ "$installerChoice" = "QUIT" ] || [ "$installerChoice" = "Quit" ]; then + echo "EXITING" + exit 1 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + printf "${B_Blue}Input: ${B_W}" + fi +done +} + +pluginMsg() { + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}PLUGIN SETUP${NL}" + printf "${B_W}Now we'll tackle the default plugin options available for Text-to-Speech, Speech-to-Text, and more.${NL}" + echo + sleep 3 + echo +} + +findScripts() { + find ~/Naomi -maxdepth 1 -iname '*.py' -type f -exec chmod a+x {} \; + find ~/Naomi -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; + find ~/.config/naomi -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; + find ~/Naomi/installers -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; +} diff --git a/scripts/naomi_cmds.sh b/scripts/naomi_cmds.sh new file mode 100644 index 00000000..55334216 --- /dev/null +++ b/scripts/naomi_cmds.sh @@ -0,0 +1,809 @@ +#!/bin/bash + +######################################### +# Runs Commands For Naomi +######################################### + +naomi_install() { + printf "${B_W}=========================================================================${NL}" + printf "${B_M}Install ${B_W}...${NL}" + printf "${B_W}=========================================================================${NL}" + echo + if [ -d ~/.config/naomi ]; then + printf "${B_W}It looks like you already have Naomi installed.${NL}" + printf "${B_W}To start Naomi just type '${B_G}Naomi${B_W}' in any terminal.${NL}" + echo + printf "${B_W}Running the install process again will create a backup of Naomi${NL}" + printf "${B_W}in the '${B_G}~/.config/naomi-backup${B_W}' directory and then create a fresh install.${NL}" + printf "${B_W}Is this what you want?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + read installChoice + if [ "$installChoice" = "y" ] || [ "$installChoice" = "Y" ]; then + printf "${B_M}Y ${B_W}- Creating Backup${NL}" + theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S) + mkdir -p ~/.config/naomi_backup/ + mv ~/Naomi ~/.config/naomi_backup/Naomi-Source + mv ~/.config/naomi ~/.config/naomi_backup/Naomi-SubDir + cd ~/.config/naomi_backup/ + gzip -r Naomi-Backup.$theDateRightNow.zip ~/.config/naomi_backup/ + sudo rm -Rf ~/.config/naomi_backup/Naomi-Source/ + sudo rm -Rf ~/.config/naomi_backup/Naomi-SubDir/ + printf "${B_M}Y ${B_W}- Installing Naomi${NL}" + if [ -n "$(command -v apt-get)" ]; then + apt_setup_wizard + elif [ -n "$(command -v pacman -Syu)" ]; then + arch_setup_wizard + elif [ -n "$(command -v yum)" ]; then + unknown_os + else + unknown_os + fi + return; + elif [ "$installChoice" = "n" ] || [ "$installChoice" = "N" ]; then + printf "${B_M}N ${B_W}- Cancelling Install${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + elif [ ! -d ~/.config/naomi ]; then + printf "${B_W}This process can take up to 3 hours to complete.${NL}" + printf "${B_W}Would you like to continue with the process now or wait for another time?${NL}" + echo + printf "${B_M} Y${B_W})es, I'd like the proceed with the setup.${NL}" + printf "${B_M} N${B_W})ope, I will come back at another time.${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + read installChoice + if [ "$installChoice" = "y" ] || [ "$installChoice" = "Y" ]; then + printf "${B_M}Y ${B_W}- Installing Naomi${NL}" + if [ -n "$(command -v apt-get)" ]; then + apt_setup_wizard + elif [ -n "$(command -v pacman -Syu)" ]; then + arch_setup_wizard + elif [ -n "$(command -v yum)" ]; then + unknown_os + else + unknown_os + fi + return; + elif [ "$installChoice" = "n" ] || [ "$installChoice" = "N" ]; then + printf "${B_M}N ${B_W}- Cancelling Install${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + fi +} +naomi_uninstall() { + printf "${B_W}=========================================================================${NL}" + printf "${B_M}Uninstall ${B_W}...${NL}" + printf "${B_W}=========================================================================${NL}" + printf "${B_R}Notice:${B_W} You are about to uninstall Naomi, is that what you want?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + read uninstallChoice + if [ "$uninstallChoice" = "y" ] || [ "$uninstallChoice" = "Y" ]; then + printf "${B_M}$key ${B_W}- Uninstalling Naomi${NL}" + SUDO_COMMAND "sudo rm -Rf ~/Naomi" + SUDO_COMMAND "sudo rm -Rf ~/.config/naomi" + return; + elif [ "$uninstallChoice" = "n" ] || [ "$uninstallChoice" = "N" ]; then + printf "${B_M}N ${B_W}- Cancelling Install${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done +} +naomi_update() { + printf "${B_W}=========================================================================${NL}" + printf "${B_M}Update ${B_W}...${NL}" + printf "${B_W}=========================================================================${NL}" + printf "${B_R}Notice: ${B_W}You are about to manually update Naomi, is that what you want?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + read updateChoice + if [ "$updateChoice" = "y" ] || [ "$updateChoice" = "Y" ]; then + if [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"nightly"' ]; then + printf "${B_M}$key ${B_W}- Forcing Update${NL}" + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cd ~ + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"milestone"' ]; then + printf "${B_M}$key ${B_W}- Forcing Update${NL}" + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cd ~ + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"stable"' ]; then + printf "${B_M}$key ${B_W}- Forcing Update${NL}" + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b master Naomi + cd Naomi + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cd ~ + sudo rm -Rf ~/Naomi-Temp + return; + else + printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" + echo + fi + elif [ "$updateChoice" = "n" ] || [ "$updateChoice" = "N" ]; then + printf "${B_M}N ${B_W}- Cancelling Update${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" + fi + done + sleep 5 + exec bash $0 +} +naomi_version() { + printf "${B_W}=========================================================================${NL}" + printf "${B_M}Version ${B_W}...${NL}" + printf "${B_W}=========================================================================${NL}" + echo + if [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"stable"' ]; then + printf "${B_W}It looks like you are using '${B_G}Stable${B_W}',${NL}" + printf "${B_W}would you like to change versions?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Milestone${B_Blue} or ${B_M}Nightly${B_Blue} or ${B_M}Quit${B_Blue}]: ${B_W}" + read versionChoice + if [ "$versionChoice" = "Milestone" ] || [ "$versionChoice" = "MILESTONE" ] || [ "$versionChoice" = "milestone" ]; then + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + cat <<< $(jq '.use_release = "milestone"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Milestone ${B_W}- Version Changed${NL}" + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$versionChoice" = "Nightly" ] || [ "$versionChoice" = "NIGHTLY" ] || [ "$versionChoice" = "nightly" ]; then + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + cat <<< $(jq '.use_release = "nightly"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.auto_update = "true"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Nightly ${B_W}- Version Changed${NL}" + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$versionChoice" = "Quit" ] || [ "$versionChoice" = "QUIT" ] || [ "$versionChoice" = "quit" ]; then + printf "${B_M}Quit ${B_W}- Cancelling Version Change${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"milestone"' ]; then + printf "${B_W}It looks like you are using '${B_G}Milestone${B_W}',${NL}" + printf "${B_W}would you like to change versions?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Stable${B_Blue} or ${B_M}Nightly${B_Blue} or ${B_M}Quit${B_Blue}]: ${B_W}" + read versionChoice + if [ "$versionChoice" = "Stable" ] || [ "$versionChoice" = "STABLE" ] || [ "$versionChoice" = "stable" ]; then + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b master Naomi + cd Naomi + cat <<< $(jq '.use_release = "stable"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Stable ${B_W}- Version Changed${NL}" + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$versionChoice" = "Nightly" ] || [ "$versionChoice" = "NIGHTLY" ] || [ "$versionChoice" = "nightly" ]; then + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + cat <<< $(jq '.use_release = "nightly"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.auto_update = "true"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Nightly ${B_W}- Version Changed${NL}" + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$versionChoice" = "Quit" ] || [ "$versionChoice" = "QUIT" ] || [ "$versionChoice" = "quit" ]; then + printf "${B_M}Quit ${B_W}- Cancelling Version Change${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + elif [ "$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)" = '"nightly"' ]; then + printf "${B_W}It looks like you are using '${B_G}Nightly${B_W}',${NL}" + printf "${B_W}would you like to change versions?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Stable${B_Blue} or ${B_M}Milestone${B_Blue} or ${B_M}Quit${B_Blue}]: ${B_W}" + read versionChoice + if [ "$versionChoice" = "Stable" ] || [ "$versionChoice" = "STABLE" ] || [ "$versionChoice" = "stable" ]; then + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b master Naomi + cd Naomi + cat <<< $(jq '.use_release = "stable"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Stable ${B_W}- Version Changed${NL}" + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$versionChoice" = "Milestone" ] || [ "$versionChoice" = "MILESTONE" ] || [ "$versionChoice" = "milestone" ]; then + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + cat <<< $(jq '.use_release = "milestone"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.version = "Naomi-'$version'.'$gitVersionNumber'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + cat <<< $(jq '.date = "'$theDateRightNow'"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Milestone ${B_W}- Version Changed${NL}" + sudo rm -Rf ~/Naomi-Temp + return; + elif [ "$versionChoice" = "Quit" ] || [ "$versionChoice" = "QUIT" ] || [ "$versionChoice" = "quit" ]; then + printf "${B_M}Quit ${B_W}- Cancelling Version Change${NL}" + sleep 5 + exec bash $0 + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + else + printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" + fi + sleep 5 + exec bash $0 +} +naomi_autoupdate() { + printf "${B_W}=========================================================================${NL}" + printf "${B_M}AutoUpdate ${B_W}...${NL}" + printf "${B_W}=========================================================================${NL}" + echo + if [ "$(jq '.auto_update' ~/.config/naomi/configs/.naomi_options.json)" = '"true"' ]; then + printf "${B_W}It looks like you have AutoUpdates '${B_G}Enabled${B_W}',${NL}" + printf "${B_W}would you like to disabled AutoUpdates?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + read autoupdateChoice + if [ "$autoupdateChoice" = "y" ] || [ "$autoupdateChoice" = "Y" ]; then + cat <<< $(jq '.auto_update = "false"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Y ${B_W}- AutoUpdate Disabled${NL}" + return; + elif [ "$autoupdateChoice" = "n" ] || [ "$autoupdateChoice" = "N" ]; then + printf "${B_M}N ${B_W}- No Change${NL}" + return; + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + elif [ "$(jq '.auto_update' ~/.config/naomi/configs/.naomi_options.json)" = '"false"' ]; then + printf "${B_W}It looks like you have AutoUpdates '${B_G}Disabled${B_W}',${NL}" + printf "${B_W}would you like to enable AutoUpdates?${NL}" + echo + while true; do + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + read autoupdateChoice + if [ "$autoupdateChoice" = "y" ] || [ "$autoupdateChoice" = "Y" ]; then + cat <<< $(jq '.auto_update = "true"' ~/.config/naomi/configs/.naomi_options.json) > ~/.config/naomi/configs/.naomi_options.json + printf "${B_M}Y ${B_W}- AutoUpdate Enabled${NL}" + return; + elif [ "$autoupdateChoice" = "n" ] || [ "$autoupdateChoice" = "N" ]; then + printf "${B_M}N ${B_W}- No Change${NL}" + return; + else + printf "${B_R}Notice:${B_W} Did not recognize input, try again...${NL}" + echo + fi + done + else + printf "${B_R}Notice:${B_W} Error finding your Naomi Options file...${NL}" + fi + sleep 5 + exec bash $0 +} +#TODO: Implement functoin before setup wizard +#installProcess + +defaultFlavor() { + printf "${B_M}$key ${B_W}- Easy Peasy!${NL}" + cd ~ + if [ ! -f ~/Naomi/README.md ]; then + printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" + cd ~ + git clone $gitURL.git -b master Naomi + cd Naomi + echo '{"use_release":"stable", "branch":"master", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + else + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b master Naomi + cd Naomi + echo '{"use_release":"stable", "branch":"master", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + fi + return; + +} + +stableVersion() { + printf "${B_M}$key ${B_W}- Good Choice!${NL}" + echo '{"use_release":"milestone", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + if [ ! -f ~/Naomi/README.md ]; then + printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + echo '{"use_release":"milestone", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + else + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + echo '{"use_release":"milestone", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + fi + return; +} + +nightlyVersion(){ + printf "${B_M}$key ${B_W}- You know what you are doing!${NL}" + cd ~ + if [ ! -f ~/Naomi/README.md ]; then + printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + echo '{"use_release":"nightly", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"true"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + else + mv ~/Naomi ~/Naomi-Temp + cd ~ + git clone $gitURL.git -b naomi-dev Naomi + cd Naomi + echo '{"use_release":"nightly", "branch":"naomi-dev", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"true"}' > ~/.config/naomi/configs/.naomi_options.json + cd ~ + fi + return; +} + +skipFlavor(){ + printf "${B_M}$key ${B_W}- Skipping Section${NL}" + echo '{"use_release":"testing", "version":"Naomi-Development", "version":"Development", "date":"'$theDateRightNow'", "auto_update":"false"}' > ~/.config/naomi/configs/.naomi_options.json + return; + +} + + +setupVenv() { + pip3 install --user virtualenv virtualenvwrapper=='4.8.4' + printf "${B_G}sourcing virtualenvwrapper.sh${B_W}${NL}" + export WORKON_HOME=$HOME/.virtualenvs + export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 + export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv + source ~/.local/bin/virtualenvwrapper.sh + export VIRTUALENVWRAPPER_ENV_BIN_DIR=bin + printf "${B_G}checking if Naomi virtualenv exists${B_W}${NL}" + workon Naomi > /dev/null 2>&1 + if [ $? -ne 0 ]; then + printf "${B_G}Naomi virtualenv does not exist. Creating.${B_W}${NL}" + PATH=$PATH:~/.local/bin mkvirtualenv -p python3 Naomi + fi + workon Naomi + if [ "$(which pip)" = "$HOME/.virtualenvs/Naomi/bin/pip" ]; then + echo + echo + echo + echo + printf "${B_W}If you want, we can add the call to start virtualenvwrapper directly${NL}" + printf "${B_W}to the end of your ${B_G}~/.bashrc${B_W} file, so if you want to use the same${NL}" + printf "${B_W}python that Naomi does for debugging or installing additional${NL}" + printf "${B_W}dependencies, all you have to type is '${B_G}workon Naomi${B_W}'${NL}" + echo + printf "${B_W}Otherwise, you will need to enter:${NL}" + printf "${B_W}'${B_G}VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv${B_W}'${NL}" + printf "${B_W}'${B_G}source ~/.local/bin/virtualenvwrapper.sh${B_W}'${NL}" + printf "${B_W}before you will be able activate the Naomi environment with '${B_G}workon Naomi${B_W}'${NL}" + echo + printf "${B_W}All of this will be incorporated into the Naomi script, so to simply${NL}" + printf "${B_W}launch Naomi, all you have to type is '${B_G}Naomi${B_W}' in a terminal regardless of your choice here.${NL}" + echo + printf "${B_W}Would you like to start VirtualEnvWrapper automatically?${NL}" + echo + printf "${B_M} Y${B_W})es, start virtualenvwrapper whenever I start a shell${NL}" + printf "${B_M} N${B_W})o, don't start virtualenvwrapper for me${NL}" + printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}" + export AUTO_START="" + if [ "$SUDO_APPROVE" = "-y" ]; then + AUTO_START="Y" + else + while [ "$AUTO_START" != "Y" ] && [ "$AUTO_START" != "y" ] && [ "$AUTO_START" != "N" ] && [ "$AUTO_START" != "n" ]; do + read -e -p 'Please select: ' AUTO_START + if [ "$AUTO_START" = "" ]; then + AUTO_START="Y" + fi + if [ "$AUTO_START" != "Y" ] && [ "$AUTO_START" != "y" ] && [ "$AUTO_START" != "N" ] && [ "$AUTO_START" != "n" ]; then + printf "${B_R}Notice:${B_W} Please choose 'Y' or 'N'" + fi + done + fi + if [ "$AUTO_START" = "Y" ] || [ "$AUTO_START" = "y" ]; then + printf "${B_W}${NL}" + echo '' >> ~/.bashrc + echo '' >> ~/.bashrc + echo '' >> ~/.bashrc + echo '######################################################################' >> ~/.bashrc + echo '# Initialize Naomi VirtualEnvWrapper' >> ~/.bashrc + echo '######################################################################' >> ~/.bashrc + echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc + echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc + echo "export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv" >> ~/.bashrc + echo "source ~/.local/bin/virtualenvwrapper.sh" >> ~/.bashrc + fi + pip install -r python_requirements.txt + if [ $? -ne 0 ]; then + printf "${B_R}Notice:${B_W} Error installing python requirements: ${NL}${NL}$!" >&2 + exit 1 + fi + else + printf "${B_R}Notice:${B_W} Something went wrong, not in virtual environment...${NL}" >&2 + exit 1 + fi +} + +processNaomi() { + printf "${B_W}${NL}" + echo + echo + echo '' >> ~/.bashrc + echo '' >> ~/.bashrc + echo '' >> ~/.bashrc + echo '######################################################################' >> ~/.bashrc + echo '# Initialize Naomi to start on command' >> ~/.bashrc + echo '######################################################################' >> ~/.bashrc + echo 'source ~/.config/naomi/Naomi.sh' >> ~/.bashrc + echo + echo + echo '[Desktop Entry]' > ~/Desktop/Naomi.desktop + echo 'Name=Naomi' >> ~/Desktop/Naomi.desktop + echo 'Comment=Your privacy respecting digital assistant' >> ~/Desktop/Naomi.desktop + echo 'Icon=/home/pi/Naomi/Naomi.png' >> ~/Desktop/Naomi.desktop + echo 'Exec=Naomi' >> ~/Desktop/Naomi.desktop + echo 'Type=Application' >> ~/Desktop/Naomi.desktop + echo 'Encoding=UTF-8' >> ~/Desktop/Naomi.desktop + echo 'Terminal=True' >> ~/Desktop/Naomi.desktop + echo 'Categories=None;' >> ~/Desktop/Naomi.desktop + echo + echo + echo "#!/bin/bash" > ~/.config/naomi/Naomi.sh + echo "" >> ~/.config/naomi/Naomi.sh + echo "B_W='\033[1;97m' #Bright White For standard text output" >> ~/.config/naomi/Naomi.sh + echo "B_R='\033[1;91m' #Bright Red For alerts/errors" >> ~/.config/naomi/Naomi.sh + echo "B_Blue='\033[1;94m' #Bright Blue For prompt question" >> ~/.config/naomi/Naomi.sh + echo "B_M='\033[1;95m' #Bright Magenta For prompt choices" >> ~/.config/naomi/Naomi.sh + echo 'NL="' >> ~/.config/naomi/Naomi.sh + echo '"' >> ~/.config/naomi/Naomi.sh + echo 'version="3.0"' >> ~/.config/naomi/Naomi.sh + echo 'theDateRightNow=$(date +%m-%d-%Y-%H:%M:%S)' >> ~/.config/naomi/Naomi.sh + echo 'gitURL="https://github.com/naomiproject/naomi"' >> ~/.config/naomi/Naomi.sh + echo "" >> ~/.config/naomi/Naomi.sh + echo "function Naomi() {" >> ~/.config/naomi/Naomi.sh + echo " if [ \"\$(jq '.auto_update' ~/.config/naomi/configs/.naomi_options.json)\" = '\"true\"' ]; then" >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_W}=========================================================================${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_W}Checking for Naomi Updates...${NL}"' >> ~/.config/naomi/Naomi.sh + echo " cd ~/Naomi" >> ~/.config/naomi/Naomi.sh + echo " git fetch -q " >> ~/.config/naomi/Naomi.sh + echo ' if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ] ; then' >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_W}Downloading & Installing Updates...${NL}"' >> ~/.config/naomi/Naomi.sh + echo " git pull" >> ~/.config/naomi/Naomi.sh + echo " sudo apt-get -o Acquire::ForceIPv4=true update -y" >> ~/.config/naomi/Naomi.sh + echo " sudo apt -o upgrade -y" >> ~/.config/naomi/Naomi.sh + echo " sudo ./naomi_apt_requirements.sh -y" >> ~/.config/naomi/Naomi.sh + echo " else" >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_W}No Updates Found.${NL}"' >> ~/.config/naomi/Naomi.sh + echo " fi" >> ~/.config/naomi/Naomi.sh + echo " else" >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_R}Notice: ${B_W}Naomi Auto Update Failed!${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_R}Notice: ${B_W}Would you like to force update Naomi?${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_Blue}Choice [${B_M}Y${B_Blue}/${B_M}N${B_Blue}]: ${B_W}"' >> ~/.config/naomi/Naomi.sh + echo ' while true; do' >> ~/.config/naomi/Naomi.sh + echo ' read -N1 -s key' >> ~/.config/naomi/Naomi.sh + echo ' case $key in' >> ~/.config/naomi/Naomi.sh + echo ' Y)' >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo " if [ \"\$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)\" = '\"nightly\"' ]; then" >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo " git clone \$gitURL.git -b naomi-dev Naomi" >> ~/.config/naomi/Naomi.sh + echo ' cd Naomi' >> ~/.config/naomi/Naomi.sh + echo " echo '{\"use_release\":\"nightly\", \"branch\":\"naomi-dev\", \"version\":\"Naomi-\$version.\$(git rev-parse --short HEAD)\", \"date\":\"\$theDateRightNow\", \"auto_update\":\"true\"}' > ~/.config/naomi/configs/.naomi_options.json" >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo ' break' >> ~/.config/naomi/Naomi.sh + echo " elif [ \"\$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)\" = '\"milestone\"' ]; then" >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo " git clone \$gitURL.git -b naomi-dev Naomi" >> ~/.config/naomi/Naomi.sh + echo ' cd Naomi' >> ~/.config/naomi/Naomi.sh + echo " echo '{\"use_release\":\"milestone\", \"branch\":\"naomi-dev\", \"version\":\"Naomi-\$version.\$(git rev-parse --short HEAD)\", \"date\":\"\$theDateRightNow\", \"auto_update\":\"true\"}' > ~/.config/naomi/configs/.naomi_options.json" >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo ' break' >> ~/.config/naomi/Naomi.sh + echo " elif [ \"\$(jq '.use_release' ~/.config/naomi/configs/.naomi_options.json)\" = '\"stable\"' ]; then" >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_M}$key ${B_W}- Forcing Update${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' mv ~/Naomi ~/Naomi-Temp' >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo " git clone \$gitURL.git -b master Naomi" >> ~/.config/naomi/Naomi.sh + echo ' cd Naomi' >> ~/.config/naomi/Naomi.sh + echo " echo '{\"use_release\":\"stable\", \"branch\":\"master\", \"version\":\"Naomi-\$version.\$(git rev-parse --short HEAD)\", \"date\":\"\$theDateRightNow\", \"auto_update\":\"false\"}' > ~/.config/naomi/configs/.naomi_options.json" >> ~/.config/naomi/Naomi.sh + echo ' cd ~' >> ~/.config/naomi/Naomi.sh + echo ' fi' >> ~/.config/naomi/Naomi.sh + echo ' break' >> ~/.config/naomi/Naomi.sh + echo ' ;;' >> ~/.config/naomi/Naomi.sh + echo ' N)' >> ~/.config/naomi/Naomi.sh + echo ' printf "${B_M}$key ${B_W}- Launching Naomi!${NL}"' >> ~/.config/naomi/Naomi.sh + echo ' break' >> ~/.config/naomi/Naomi.sh + echo ' ;;' >> ~/.config/naomi/Naomi.sh + echo ' esac' >> ~/.config/naomi/Naomi.sh + echo ' done' >> ~/.config/naomi/Naomi.sh + echo " fi" >> ~/.config/naomi/Naomi.sh + echo " export WORKON_HOME=$HOME/.virtualenvs" >> ~/.config/naomi/Naomi.sh + echo " export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.config/naomi/Naomi.sh + echo " export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv" >> ~/.config/naomi/Naomi.sh + echo " source ~/.local/bin/virtualenvwrapper.sh" >> ~/.config/naomi/Naomi.sh + echo " workon Naomi" >> ~/.config/naomi/Naomi.sh + echo " python $NAOMI_DIR/Naomi.py \"\$@\"" >> ~/.config/naomi/Naomi.sh + echo "}" >> ~/.config/naomi/Naomi.sh + echo + echo + echo + echo +} + +openfst() { + echo + printf "${B_G}Building and installing openfst...${B_W}${NL}" + cd ~/.config/naomi/sources + + if [ ! -f "openfst-1.6.9.tar.gz" ]; then + wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.6.9.tar.gz + fi + tar -zxvf openfst-1.6.9.tar.gz + cd openfst-1.6.9 + autoreconf -i + ./configure --enable-static --enable-shared --enable-far --enable-lookahead-fsts --enable-const-fsts --enable-pdt --enable-ngram-fsts --enable-linear-fsts --prefix=/usr + make + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo make install" + if [ $? -ne 0 ]; then + echo $! >&2 + exit 1 + fi + else + printf "${B_W}${NL}" + sudo make install + if [ $? -ne 0 ]; then + echo $! >&2 + exit 1 + fi + fi + + if [ -z "$(which fstinfo)" ]; then + printf "${ERROR} ${B_R}Notice:${B_W} openfst not installed${NL}" >&2 + exit 1 + fi +} + +mitlm() { + echo + printf "${B_G}Installing & Building mitlm-0.4.2...${B_W}${NL}" + cd ~/.config/naomi/sources + if [ ! -d "mitlm" ]; then + git clone https://github.com/mitlm/mitlm.git + if [ $? -ne 0 ]; then + printf "${ERROR} ${B_R}Notice:${B_W} Error cloning mitlm${NL}" + exit 1 + fi + fi + cd mitlm + ./autogen.sh + make + printf "${B_G}Installing mitlm${B_W}${NL}" + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo make install" + if [ $? -ne 0 ]; then + echo $! >&2 + exit 1 + fi + else + printf "${B_W}${NL}" + sudo make install + if [ $? -ne 0 ]; then + echo $! >&2 + exit 1 + fi + fi +} + +cmuclmtk() { + echo + printf "${B_G}Installing & Building cmuclmtk...${B_W}${NL}" + cd ~/.config/naomi/sources + svn co https://svn.code.sf.net/p/cmusphinx/code/trunk/cmuclmtk/ + if [ $? -ne 0 ]; then + printf "${ERROR} ${B_R}Notice:${B_W} Error cloning cmuclmtk${NL}" >&2 + exit 1 + fi + cd cmuclmtk + ./autogen.sh + make + printf "${B_G}Installing CMUCLMTK${B_W}${NL}" + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo make install" + else + printf "${B_W}${NL}" + sudo make install + fi + + printf "${B_G}Linking shared libraries${B_W}${NL}" + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo ldconfig" + else + printf "${B_W}${NL}" + sudo ldconfig + fi +} + +phonetisaurus() { + echo + printf "${B_G}Installing & Building phonetisaurus...${B_W}${NL}" + cd ~/.config/naomi/sources + if [ ! -d "Phonetisaurus" ]; then + git clone https://github.com/AdolfVonKleist/Phonetisaurus.git + if [ $? -ne 0 ]; then + printf "${ERROR} ${B_R}Notice:${B_W} Error cloning Phonetisaurus${NL}" >&2 + exit 1 + fi + fi + cd Phonetisaurus + ./configure --enable-python + make + printf "${B_G}Installing Phonetisaurus${B_W}${NL}" + printf "${B_G}Linking shared libraries${B_W}${NL}" + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo make install" + else + printf "${B_W}${NL}" + sudo make install + fi + + printf "[$(pwd)]\$ ${B_G}cd python${B_W}${NL}" + cd python + echo $(pwd) + cp -v ../.libs/Phonetisaurus.so ./ + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo python setup.py install" + else + printf "${B_W}${NL}" + sudo python setup.py install + fi + + if [ -z "$(which phonetisaurus-g2pfst)" ]; then + printf "${ERROR} ${B_R}Notice:${B_W} phonetisaurus-g2pfst does not exist${NL}" >&2 + exit 1 + fi +} + +sphinxbase() { + echo + printf "${B_G}Building and installing sphinxbase...${B_W}${NL}" + cd ~/.config/naomi/sources + if [ ! -d "pocketsphinx-python" ]; then + git clone --recursive https://github.com/bambocher/pocketsphinx-python.git + if [ $? -ne 0 ]; then + printf "${ERROR} ${B_R}Notice:${B_W} Error cloning pocketsphinx${NL}" >&2 + exit 1 + fi + fi + cd pocketsphinx-python/deps/sphinxbase + ./autogen.sh + make + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo make install" + else + printf "${B_W}${NL}" + sudo make install + fi +} + +pocketsphinx(){ + echo + printf "${B_G}Building and installing pocketsphinx...${B_W}${NL}" + cd ~/.config/naomi/sources/pocketsphinx-python/deps/pocketsphinx + ./autogen.sh + make + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo make install" + else + printf "${B_W}${NL}" + sudo make install + fi +} + +pocketsphinx_python(){ + echo + printf "${B_G}Installing PocketSphinx module...${B_W}${NL}" + cd ~/.config/naomi/sources/pocketsphinx-python + python setup.py install + + cd $NAOMI_DIR + if [ -z "$(which text2wfreq)" ]; then + printf "${ERROR} ${B_R}Notice:${B_W} text2wfreq does not exist${NL}" >&2 + exit 1 + fi + if [ -z "$(which text2idngram)" ]; then + printf "${ERROR} ${B_R}Notice:${B_W} text2idngram does not exist${NL}" >&2 + exit 1 + fi + if [ -z "$(which idngram2lm)" ]; then + printf "${ERROR} ${B_R}Notice:${B_W} idngram2lm does not exist${NL}" >&2 + exit 1 + fi +} + +compileTranslations(){ + echo + printf "${B_G}Compiling Translations...${B_W}${NL}" + cd ~/Naomi + chmod a+x compile_translations.sh + ./compile_translations.sh + cd ~ + echo + echo + echo + echo +} diff --git a/scripts/pre_checks.sh b/scripts/pre_checks.sh new file mode 100644 index 00000000..a540f870 --- /dev/null +++ b/scripts/pre_checks.sh @@ -0,0 +1,345 @@ +#!/bin/bash + +######################################### +# Does Pre-Checks to ensure requirements +# are met. +######################################### + +CONTINUE() { + read -n1 -p "Press 'q' to quit, any other key to continue: " CONTINUE + echo + if [ "$CONTINUE" = "q" ] || [ "$CONTINUE" = "Q" ]; then + echo "EXITING" + exit 1 + fi +} +quit() { + read -n1 -p "Press 'q' to quit, any other key to continue: " CONTINUE + echo + if [ "$CONTINUE" = "q" ] || [ "$CONTINUE" = "Q" ]; then + echo "EXITING" + exit 1 + else + exec bash $0 + fi +} +SUDO_COMMAND() { + echo + printf "${B_R}Notice:${B_W} this program is about to use sudo to run the following command:${NL}" + printf "[$(pwd)]\$ ${B_G}${1}${B_W}${NL}" + if [ "$SUDO_APPROVE" != "-y" ]; then + CONTINUE + fi + $1 +} +CHECK_HEADER() { + echo "#include <$1>" | cpp $(pkg-config alsa --cflags) -H -o /dev/null > /dev/null 2>&1 + echo $? +} +CHECK_PROGRAM() { + type -p "$1" > /dev/null 2>&1 + echo $? +} +unknown_os () { + printf "${B_R}Notice:${B_W} Unfortunately, your operating system distribution and version are not supported by this script at this time.${NL}" + echo + printf "${B_R}Notice:${B_W} You can find a list of supported OSes and distributions on our website: ${B_Y}https://projectnaomi.com/dev/docs/installation/${NL}" + echo + printf "${B_R}Notice:${B_W} Please join our Discord or email us at ${B_Y}contact@projectnaomi.com${B_W} and let us know if you run into any issues.${NL}" + exit 1 +} +os_detect () { + if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then + # some systems dont have lsb-release yet have the lsb_release binary and + # vice-versa + if [ -e /etc/lsb-release ]; then + . /etc/lsb-release + + if [ "${ID}" = "raspbian" ]; then + os=${ID} + dist=`cut --delimiter='.' -f1 /etc/debian_version` + else + os=${DISTRIB_ID} + dist=${DISTRIB_CODENAME} + + if [ -z "$dist" ]; then + dist=${DISTRIB_RELEASE} + fi + fi + + elif [ `which lsb_release 2>/dev/null` ]; then + dist=`lsb_release -c | cut -f2` + os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` + + elif [ -e /etc/debian_version ]; then + # some Debians have jessie/sid in their /etc/debian_version + # while others have '6.0.7' + os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'` + if grep -q '/' /etc/debian_version; then + dist=`cut --delimiter='/' -f1 /etc/debian_version` + else + dist=`cut --delimiter='.' -f1 /etc/debian_version` + fi + + elif [ -e /etc/os-release ]; then + . /etc/os-release + os=${ID} + os_like=${ID_LIKE} + if [ "${os}" = "poky" ]; then + dist=`echo ${VERSION_ID}` + elif [ "${os}" = "sles" ]; then + dist=`echo ${VERSION_ID}` + elif [ "${os}" = "opensuse" ]; then + dist=`echo ${VERSION_ID}` + elif [ "${os}" = "opensuse-leap" ]; then + os=opensuse + dist=`echo ${VERSION_ID}` + elif [ "${os_like}" = "arch" ]; then + os=arch + dist=`echo ${VERSION_ID}` + else + dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'` + fi + + elif [ `which lsb_release 2>/dev/null` ]; then + # get major version (e.g. '5' or '6') + dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'` + + # get os (e.g. 'centos', 'redhatenterpriseserver', etc) + os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` + + elif [ -e /etc/oracle-release ]; then + dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'` + os='ol' + + elif [ -e /etc/fedora-release ]; then + dist=`cut -f3 --delimiter=' ' /etc/fedora-release` + os='fedora' + + elif [ -e /etc/redhat-release ]; then + os_hint=`cat /etc/redhat-release | awk '{ print tolower($1) }'` + if [ "${os_hint}" = "centos" ]; then + dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'` + os='centos' + elif [ "${os_hint}" = "scientific" ]; then + dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'` + os='scientific' + else + dist=`cat /etc/redhat-release | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'` + os='redhatenterpriseserver' + fi + + else + unknown_os + fi + fi + + if [[ ( -z "${os}" ) || ( -z "${dist}" ) ]]; then + unknown_os + fi + + # remove whitespace from OS and dist name + os="${os// /}" + dist="${dist// /}" + + printf "${B_W}Detected operating system as $os/$dist.${NL}" +} + + + + +curl_check () { + printf "${B_W}Checking for curl...${NL}" + if command -v curl > /dev/null; then + printf "${B_W}Detected curl...${NL}" + else + printf "${B_G}Installing curl...${NL}" + if [ -n "$(command -v yum)" ]; then + printf "${B_W}yum found${NL}" + SUDO_COMMAND "yum install -d0 -e0 -y curl" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" + printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v apt-get)" ]; then + printf "${B_W}apt found${NL}" + SUDO_COMMAND "sudo apt-get install -q -y curl" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" + printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v pacman -Syu)" ]; then + printf "${B_W}apt found${NL}" + SUDO_COMMAND "sudo paru -S curl" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" + printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" + exit 1 + fi + else + printf "${B_R}Notice:${B_W} Neither yum | apt-get | pacman found${NL}" + printf "${B_R}Notice:${B_W} Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work.${NL}" + printf "${B_R}Notice:${B_W} Curl installation aborted.${NL}" + exit 1 + fi + fi +} + +jq_check () { + printf "${B_W}Checking for jq...${NL}" + if command -v jq > /dev/null; then + printf "${B_W}Detected jq...${NL}" + else + printf "${B_G}Installing jq...${NL}" + if [ -n "$(command -v yum)" ]; then + printf "${B_W}yum found${NL}" + SUDO_COMMAND "yum install -d0 -e0 -y jq" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v apt-get)" ]; then + printf "${B_W}apt found${NL}" + SUDO_COMMAND "sudo apt-get install -q -y jq" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v pacman -Syu)" ]; then + printf "${B_W}pacman found${NL}" + SUDO_COMMAND "sudo pacman -S jq" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" + exit 1 + fi + else + printf "${B_R}Notice:${B_W} Neither yum | apt-get | pacman found${NL}" + printf "${B_R}Notice:${B_W} Unable to install jq! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} jq installation aborted.${NL}" + exit 1 + fi + fi +} + +python_check () { + printf "${B_W}Checking for python3...${NL}" + if command -v python3 > /dev/null; then + printf "${B_W}Detected python3...${NL}" + else + printf "${B_G}Installing python3...${NL}" + if [ -n "$(command -v yum)" ]; then + printf "${B_W}yum found${NL}" + SUDO_COMMAND "yum install -d0 -e0 -y python3" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install python3! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} python3 installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v apt-get)" ]; then + printf "${B_W}apt found${NL}" + SUDO_COMMAND "sudo apt-get install -q -y python3" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install python3! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} python3 installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v pacman -Syu)" ]; then + printf "${B_W}pacman found${NL}" + SUDO_COMMAND "sudo pacman -S python3" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install python3! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} python3 installation aborted.${NL}" + exit 1 + fi + else + printf "${B_R}Notice:${B_W} Neither yum | apt-get | pacman found${NL}" + printf "${B_R}Notice:${B_W} Unable to install python3! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} python3 installation aborted.${NL}" + exit 1 + fi + fi +} + +git_check () { + printf "${B_W}Checking for git...${NL}" + if command -v python3 > /dev/null; then + printf "${B_W}Detected git...${NL}" + else + printf "${B_G}Installing git...${NL}" + if [ -n "$(command -v yum)" ]; then + printf "${B_W}yum found${NL}" + SUDO_COMMAND "yum install -d0 -e0 -y git" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install git! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v apt-get)" ]; then + printf "${B_W}apt found${NL}" + SUDO_COMMAND "sudo apt-get install -q -y git" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install git! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v pacman -Syu)" ]; then + printf "${B_W}pacman found${NL}" + SUDO_COMMAND "sudo pacman -S git" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install git! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + else + printf "${B_R}Notice:${B_W} Neither yum | apt-get | pacman found${NL}" + printf "${B_R}Notice:${B_W} Unable to install git! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + fi +} + +zip_check () { + printf "${B_W}Checking for zip...${NL}" + if command -v python3 > /dev/null; then + printf "${B_W}Detected zip...${NL}" + else + printf "${B_G}Installing zip...${NL}" + if [ -n "$(command -v yum)" ]; then + printf "${B_W}yum found${NL}" + SUDO_COMMAND "yum install -d0 -e0 -y zip" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install zip! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v apt-get)" ]; then + printf "${B_W}apt found${NL}" + SUDO_COMMAND "sudo apt-get install -y zip" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install zip! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + elif [ -n "$(command -v pacman -Syu)" ]; then + printf "${B_W}pacman found${NL}" + SUDO_COMMAND "sudo pacman -S zip" + if [ "$?" -ne "0" ]; then + printf "${B_R}Notice:${B_W} Unable to install zip! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + else + printf "${B_R}Notice:${B_W} Neither yum | apt-get | pacman found${NL}" + printf "${B_R}Notice:${B_W} Unable to install zip! Your base system has a problem; please check your default OS's package repositories because jq should work.${NL}" + printf "${B_R}Notice:${B_W} git installation aborted.${NL}" + exit 1 + fi + fi +} +