From fbd8f2a520a6fb5e4ae91ea7fd0a56ec9c7ffba1 Mon Sep 17 00:00:00 2001 From: Austin Casteel Date: Wed, 17 Feb 2021 16:37:27 -0600 Subject: [PATCH 1/4] Removing Nightly Builds due to new version system --- .github/workflows/nightly-publish.yml | 33 --------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/nightly-publish.yml diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml deleted file mode 100644 index f90c619..0000000 --- a/.github/workflows/nightly-publish.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: 'Nightly Publish' - -on: push - -jobs: - nightly-publish: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Nightly Publish - env: - BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} - run: | - git clone https://github.com/NaomiProject/Naomi.git - cd Naomi - git checkout naomi-dev - git pull - cd ../ - mv Naomi Naomi-Nightly - zip -r Naomi-Nightly.zip Naomi-Nightly - mv Naomi-Nightly.zip Naomi-Nightly/installers/ - - - name: Upload ftp - uses: sebastianpopp/ftp-action@releases/v2 - with: - host: ${{ secrets.FTP_SERVER }} - user: ${{ secrets.FTP_USERNAME }} - password: ${{ secrets.FTP_PASSWORD }} - localDir: "Naomi-Nightly/installers/" \ No newline at end of file From 1de1eccf089298c41bb396e4a92ee6438d8a8b28 Mon Sep 17 00:00:00 2001 From: Austin Casteel Date: Wed, 17 Feb 2021 16:37:48 -0600 Subject: [PATCH 2/4] Removing Monthly Builds due to new version system --- .github/workflows/monthly-publish.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/monthly-publish.yml diff --git a/.github/workflows/monthly-publish.yml b/.github/workflows/monthly-publish.yml deleted file mode 100644 index 788c99e..0000000 --- a/.github/workflows/monthly-publish.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: 'Monthly Publish' - -on: - schedule: - - cron: '0 4 1 * *' - -jobs: - monthly-publish: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Monthly Publish - env: - BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} - run: wget -q https://git.io/Je8ON -O monthly-publish.sh && bash monthly-publish.sh From 6c3d671d594b86278b5bd8376f06b40a9850e918 Mon Sep 17 00:00:00 2001 From: Sean Riley Hawkins Date: Mon, 17 Oct 2022 19:29:34 +0200 Subject: [PATCH 3/4] feat: add arch installer & files --- arch_requirements.txt | 48 +++ installers/arch.pacman.sh | 714 ++++++++++++++++++++++++++++++++++++++ installers/naomi-setup.sh | 212 ++++++++++- naomi_apt_requirements.sh | 9 - naomi_requirements.sh | 36 ++ requirements.txt | 55 +++ script.deb.sh | 701 +++++++++++++++++++++++++++++++++++++ 7 files changed, 1763 insertions(+), 12 deletions(-) create mode 100644 arch_requirements.txt create mode 100755 installers/arch.pacman.sh delete mode 100755 naomi_apt_requirements.sh create mode 100755 naomi_requirements.sh create mode 100644 requirements.txt create mode 100644 script.deb.sh diff --git a/arch_requirements.txt b/arch_requirements.txt new file mode 100644 index 0000000..72697e2 --- /dev/null +++ b/arch_requirements.txt @@ -0,0 +1,48 @@ +# Core requirements +python3-pip +atlas +openssl +ncurses +gnupg +dirmngr +gettext +gfortran +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++ +make +autoconf +libtool +git +gfortran +autoconf-archive +subversion +swig +bison + +# TTS +## flite +flite + +# SpeechHandler +## MPDControl +mpd + diff --git a/installers/arch.pacman.sh b/installers/arch.pacman.sh new file mode 100755 index 0000000..f624a01 --- /dev/null +++ b/installers/arch.pacman.sh @@ -0,0 +1,714 @@ +#!/bin/bash + +######################################### +# Installs python and necessary packages +# for arch based Naomi. This script will install python +# into the ~/.config/naomi/local/bin directory and +# 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}ARCH 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 + + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}SECURITY SETUP:${NL}" + printf "${B_W}Let's examine a few security settings.${NL}" + echo + printf "${B_W}By default, Naomi is configured to require a password to perform actions as${NL}" + printf "${B_W}root (e.g. 'sudo ...') as well as confirm commands before continuing.${NL}" + printf "${B_W}This means you will have to watch the setup process to confirm everytime a new${NL}" + printf "${B_W}command needs to run.${NL}" + echo + printf "${B_W}However you can enable Naomi to continue the process uninterrupted for a hands off experience${NL}" + echo + printf "${B_W}Would you like the setup to run uninterrupted or would you like to look over the setup process?${NL}" + echo + printf "${B_M} 1${B_W}) Allow the process to run uninterrupted${NL}" + printf "${B_M} 2${B_W}) Require authentication to continue and run commands${NL}" + printf "${B_Blue}Choice [${B_M}1${B_Blue}-${B_M}2${B_Blue}]: ${B_W}" + while true; do + read -N1 -s key + case $key in + [1]) + printf "${B_M}$key ${B_W}- Proceeding uninterrupted${NL}" + REQUIRE_AUTH="0" + SUDO_APPROVE="-y" + break + ;; + [2]) + printf "${B_M}$key ${B_W}- Requiring authentication${NL}" + REQUIRE_AUTH="1" + SUDO_APPROVE="" + break + ;; + esac + done + 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 + + # 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/ + + # 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 pacman -S git $SUDO_APPROVE" + else + printf "${B_W}${NL}" + sudo pacman -S git $SUDO_APPROVE + fi + echo + + 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 + 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 + ;; + 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 + ;; + 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 + ;; + 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 {} \; + + NAOMI_DIR="$(cd ~/Naomi && pwd)" + + cd ~/Naomi + APT=1 + if [ $APT -eq 1 ]; then + if [ $REQUIRE_AUTH -eq 1 ]; then + SUDO_COMMAND "sudo pacman -Syu" + SUDO_COMMAND "sudo pacman -Syu $SUDO_APPROVE" + SUDO_COMMAND "sudo bash ~/Documents/Github_Repos/Naomi/naomi_requirements.sh $SUDO_APPROVE" + if [ $? -ne 0 ]; then + printf "${B_R}Notice:${B_W} Error installing pacman packages${NL}" >&2 + exit 1 + fi + else + printf "${B_W}${NL}" + sudo pacman -Syu + sudo pacman -Syu $SUDO_APPROVE + sudo bash ~/Documents/Github_Repos/Naomi/naomi_requirements.sh $SUDO_APPROVE + if [ $? -ne 0 ]; then + printf "${B_R}Notice:${B_W} Error installing arch packages${NL}" >&2 + exit 1 + fi + fi + else + ERROR="" + if [[ $(CHECK_PROGRAM msgfmt) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} gettext program msgfmt not found${NL}" + fi + if [[ $(CHECK_HEADER portaudio.h) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} portaudio development file portaudio.h not found${NL}" + fi + if [[ $(CHECK_HEADER asoundlib.h) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} libasound development file asoundlib.h not found${NL}" + fi + if [[ $(CHECK_PROGRAM python3) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} python3 not found${NL}" + fi + if [[ $(CHECK_PROGRAM pip3) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} pip3 not found${NL}" + fi + if [ ! -z "$ERROR" ]; then + printf "${B_R}Notice:${B_W} Missing dependencies:${NL}${NL}$ERROR" + CONTINUE + fi + fi + + # make sure pulseaudio is running + # Check if pulseaudio or pipewire is installed + # pulseaudio --check + # if [ $? -ne 0 ]; then + # pulseaudio -D + # fi + + #TODO: Write the backup script to install the servers + if [ pulseaudio --version ]; then + echo "Pulseaudio detected running pulseaudio setup..." + elif [ pipewire --version ]; then + echo "Pipewire detected running pipewire setup..." + else + echo "Pipewire or Puleaudio are not installed" + echo "Installing Pipewire instead" + #FIXME: Add user choice for Pipewire + sudo pacman -S pipewire + 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 + + 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 {} \; + + 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 +} + +setup_wizard diff --git a/installers/naomi-setup.sh b/installers/naomi-setup.sh index ac42aa8..b3ae6e3 100755 --- a/installers/naomi-setup.sh +++ b/installers/naomi-setup.sh @@ -108,6 +108,7 @@ os_detect () { 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 @@ -117,6 +118,9 @@ os_detect () { 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 @@ -164,6 +168,7 @@ os_detect () { 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 @@ -186,14 +191,23 @@ curl_check () { 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 nor apt-get found${NL}" + 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 @@ -216,14 +230,102 @@ jq_check () { 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 nor apt-get found${NL}" + 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 +} + + apt_setup_wizard() { if [ ! -f ~/Naomi/README.md ]; then echo @@ -294,6 +396,104 @@ apt_setup_wizard() { exit 1 fi } + +arch_setup_wizard() { + if [ ! -f ~/Naomi/README.md ]; then + echo + printf "${B_G}Starting Naomi Arch Setup Wizard...${NL}${B_W}" + #. <( wget -O - "https://installers.projectnaomi.com/script.deb.sh" ); + # . <( wget -O - "./arch.pacman.sh" ); + #TODO: Check Why this is failing + bash installers/arch.pacman.sh; + + # ./installers/arch.pacman.sh + + if [ -n "$(command bash installers/arch.pacman.sh)" ]; 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 ~/Naomi + chmod a+x Naomi.sh + cd ~ + exec bash + + wget_exit_code=$? + elif [ "$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 ~/Naomi + chmod a+x Naomi.sh + cd ~ + exec bash + else + echo + printf "${B_R}Notice: ${B_W}Naomi Arch Setup Wizard Failed.${NL}" + echo + exit 1 + fi + elif [ -f ~/Naomi/README.md ] && [ -f ~/Naomi/installers/arch.pacman.sh ]; then + chmod a+x ~/Naomi/installers/arch.pacman.sh + bash ~/Naomi/installers/arch.pacman.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 ~/Naomi + chmod a+x Naomi.sh + cd ~ + exec bash + else + echo + printf "${B_R}Notice: ${B_W}Naomi Arch Setup Wizard Failed.${NL}" + echo + 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 + fi +} + yum_setup_wizard() { if [ ! -f ~/Naomi/README.md ]; then echo @@ -396,6 +596,8 @@ naomi_install() { 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 @@ -425,6 +627,8 @@ naomi_install() { 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 @@ -705,6 +909,8 @@ tput reset os_detect curl_check jq_check +python_check +git_check sleep 5 tput reset @@ -775,4 +981,4 @@ while true; do echo printf "${B_Blue}Input: ${B_W}" fi -done \ No newline at end of file +done diff --git a/naomi_apt_requirements.sh b/naomi_apt_requirements.sh deleted file mode 100755 index 009107d..0000000 --- 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 0000000..03cf764 --- /dev/null +++ b/naomi_requirements.sh @@ -0,0 +1,36 @@ +#!/bin/bash +SUDO_APPROVE="" + +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}"="arch" ]; then + ArchSetup + fi +else + echo "Can't detect OS script will exit now..." + exit 1 +fi diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d5d0a41 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,55 @@ +# Naomi Core Dependancies +APScheduler +argparse +mock==3.0.5 +pytz +PyYAML +requests +blessings +pyaudio +pyalsaaudio +cyrptography + +# Other Modules +python-slugify +mad + +# Pocketsphinx STT engine +cmuclmtk + +# HN Module +semantic + +# Birthday/Notifications Modules +facebook-sdk + +# Weather/News Modules +feedparser + +# Gmail module +python-dateutil + +# MPDControl module +python-mp2 + +# google tts +google-api-core +google-auth +google-cloud-speech +googleapis-common-protos +grpcio + +# google tts +google-cloud-texttospeech + +# webrtcvad +webrtcvad + +# NaomiSTTTrain +cython +pandas +sklearn +jiwer + +# Development +flake8 diff --git a/script.deb.sh b/script.deb.sh new file mode 100644 index 0000000..89af5b9 --- /dev/null +++ b/script.deb.sh @@ -0,0 +1,701 @@ +#!/bin/bash + +######################################### +# Installs python and necessary packages +# for deb based Naomi. This script will install python +# into the ~/.config/naomi/local/bin directory and +# 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 + + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}SECURITY SETUP:${NL}" + printf "${B_W}Let's examine a few security settings.${NL}" + echo + printf "${B_W}By default, Naomi is configured to require a password to perform actions as${NL}" + printf "${B_W}root (e.g. 'sudo ...') as well as confirm commands before continuing.${NL}" + printf "${B_W}This means you will have to watch the setup process to confirm everytime a new${NL}" + printf "${B_W}command needs to run.${NL}" + echo + printf "${B_W}However you can enable Naomi to continue the process uninterrupted for a hands off experience${NL}" + echo + printf "${B_W}Would you like the setup to run uninterrupted or would you like to look over the setup process?${NL}" + echo + printf "${B_M} 1${B_W}) Allow the process to run uninterrupted${NL}" + printf "${B_M} 2${B_W}) Require authentication to continue and run commands${NL}" + printf "${B_Blue}Choice [${B_M}1${B_Blue}-${B_M}2${B_Blue}]: ${B_W}" + while true; do + read -N1 -s key + case $key in + [1]) + printf "${B_M}$key ${B_W}- Proceeding uninterrupted${NL}" + REQUIRE_AUTH="0" + SUDO_APPROVE="-y" + break + ;; + [2]) + printf "${B_M}$key ${B_W}- Requiring authentication${NL}" + REQUIRE_AUTH="1" + SUDO_APPROVE="" + break + ;; + esac + done + 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 + + # 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/ + + # 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 + + 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 + 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 + ;; + 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 + ;; + 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 + ;; + 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 {} \; + + 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" + if [ $? -ne 0 ]; then + printf "${B_R}Notice:${B_W} Error installing apt packages${NL}" >&2 + exit 1 + fi + else + printf "${B_W}${NL}" + sudo apt-get update + sudo apt upgrade $SUDO_APPROVE + sudo ./naomi_apt_requirements.sh $SUDO_APPROVE + if [ $? -ne 0 ]; then + printf "${B_R}Notice:${B_W} Error installing apt packages${NL}" >&2 + exit 1 + fi + fi + else + ERROR="" + if [[ $(CHECK_PROGRAM msgfmt) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} gettext program msgfmt not found${NL}" + fi + if [[ $(CHECK_HEADER portaudio.h) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} portaudio development file portaudio.h not found${NL}" + fi + if [[ $(CHECK_HEADER asoundlib.h) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} libasound development file asoundlib.h not found${NL}" + fi + if [[ $(CHECK_PROGRAM python3) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} python3 not found${NL}" + fi + if [[ $(CHECK_PROGRAM pip3) -ne "0" ]]; then + ERROR="${ERROR} ${B_R}Notice:${B_W} pip3 not found${NL}" + fi + if [ ! -z "$ERROR" ]; then + printf "${B_R}Notice:${B_W} Missing dependencies:${NL}${NL}$ERROR" + CONTINUE + fi + fi + + # make sure pulseaudio is running + pulseaudio --check + if [ $? -ne 0 ]; then + 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 + + 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 {} \; + + 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 + + # 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 +} + +setup_wizard From c1d449a00990d633113ee920fed4e1c075244303 Mon Sep 17 00:00:00 2001 From: Sean Riley Hawkins Date: Sat, 11 Feb 2023 20:24:50 +0200 Subject: [PATCH 4/4] feat: Arch setup installer --- arch_requirements.txt | 12 +- installers/arch.pacman.sh | 287 +++++-------- installers/naomi-setup.sh | 875 +------------------------------------- installers/script.deb.sh | 65 +-- naomi_requirements.sh | 12 +- python_requirements.txt | 2 + scripts/misc.sh | 182 ++++++++ scripts/naomi_cmds.sh | 343 +++++++++++++++ scripts/pre_checks.sh | 344 +++++++++++++++ 9 files changed, 1023 insertions(+), 1099 deletions(-) create mode 100755 scripts/misc.sh create mode 100755 scripts/naomi_cmds.sh create mode 100755 scripts/pre_checks.sh diff --git a/arch_requirements.txt b/arch_requirements.txt index 72697e2..74eecdb 100644 --- a/arch_requirements.txt +++ b/arch_requirements.txt @@ -4,19 +4,19 @@ atlas openssl ncurses gnupg -dirmngr +# dirmngr does not exist gettext -gfortran +gcc-fortran util-linux jq # Plugins ## AudioEngine ### PyAudio -portaudio19-dev +#portaudio19-dev # libasound2-dev pulseaudio -pulseaudio-utils +#pulseaudio-utils pipewire ## STT @@ -27,12 +27,12 @@ libpulse #### Phonetisaurus is used to build dictionaries gcc -g++ +# g++ Does not exist make autoconf libtool git -gfortran +#gfortran autoconf-archive subversion swig diff --git a/installers/arch.pacman.sh b/installers/arch.pacman.sh index f624a01..f135b6b 100755 --- a/installers/arch.pacman.sh +++ b/installers/arch.pacman.sh @@ -1,5 +1,7 @@ #!/bin/bash +source "scripts/misc.sh" +source "scripts/pre_checks.sh" ######################################### # Installs python and necessary packages # for arch based Naomi. This script will install python @@ -7,101 +9,11 @@ # 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}ARCH 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 +setup_wizard() { + wizardSetup - echo - printf "${B_W}=========================================================================${NL}" - printf "${B_W}SECURITY SETUP:${NL}" - printf "${B_W}Let's examine a few security settings.${NL}" - echo - printf "${B_W}By default, Naomi is configured to require a password to perform actions as${NL}" - printf "${B_W}root (e.g. 'sudo ...') as well as confirm commands before continuing.${NL}" - printf "${B_W}This means you will have to watch the setup process to confirm everytime a new${NL}" - printf "${B_W}command needs to run.${NL}" - echo - printf "${B_W}However you can enable Naomi to continue the process uninterrupted for a hands off experience${NL}" - echo - printf "${B_W}Would you like the setup to run uninterrupted or would you like to look over the setup process?${NL}" - echo - printf "${B_M} 1${B_W}) Allow the process to run uninterrupted${NL}" - printf "${B_M} 2${B_W}) Require authentication to continue and run commands${NL}" - printf "${B_Blue}Choice [${B_M}1${B_Blue}-${B_M}2${B_Blue}]: ${B_W}" while true; do read -N1 -s key case $key in @@ -119,81 +31,65 @@ setup_wizard() { ;; esac done - 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 + env - # 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/ + 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 pacman -S git $SUDO_APPROVE" - else - printf "${B_W}${NL}" - sudo pacman -S git $SUDO_APPROVE - fi - echo + #TODO: Remove Git since pre_check already handles it + 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 ~ + #BUG: Does CWD to home + #cd ~ if [ ! -f ~/Naomi/README.md ]; then printf "${B_G}Downloading 'Naomi'...${B_W}${NL}" + mkdir -p ~/Naomi/naomiInstaller + #git clone ~/Naomi/naomiInstaller + #pwd + cp -r ../../Naomi ~/Naomi/naomiInstaller + cd ~/Naomi/naomiInstaller/Naomi + #TODO: Copy local repo instead | Write a script that will install directly to ~ + #TODO: Git pull upstream from particular branch | maybe just merge from Upstream +<~/.config/naomi/configs/.naomi_options.json + cd ~ +comment + #BUG: does not recognise folder as git + pwd + + git checkout master + git fetch origin + git merge origin master + #cp -r ../Naomi ~ + echo '{"use_release":"stable", "branch":"master", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' >~/.config/naomi/configs/.naomi_options.json else + mv ~/Naomi ~/Naomi-Temp +<~/.config/naomi/configs/.naomi_options.json cd ~ +comment + + + + git checkout master + git fetch origin + git merge origin master + cp -r ../Naomi ~ + echo '{"use_release":"stable", "branch":"master", "version":"Naomi-'$version'.'$gitVersionNumber'", "date":"'$theDateRightNow'", "auto_update":"false"}' >~/.config/naomi/configs/.naomi_options.json + fi break ;; @@ -203,36 +99,71 @@ setup_wizard() { 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 + #TODO: Replace & use git origin + # cd ~ + + + git checkout naomi-dev + git fetch origin + git merge origin naomi-dev + cp -r ../Naomi ~ + + #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 ~ + # cd ~ else mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi + #TODO: Replace & use git upstream + + + git checkout naomi-dev + git fetch origin + git merge origin naomi-dev + cp -r ../Naomi ~ + + cd ~/Naomi + #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 ~ + # cd ~ fi break ;; 3) printf "${B_M}$key ${B_W}- You know what you are doing!${NL}" - cd ~ + # 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 + #TODO: Replace with git upstream + + + git checkout naomi-dev + git fetch origin + git merge origin naomi-dev + cp -r ../Naomi ~ + + cd ~/Naomi + + #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 ~ + # cd ~ else mv ~/Naomi ~/Naomi-Temp - cd ~ - git clone $gitURL.git -b naomi-dev Naomi - cd Naomi + #TODO: Replace with git upstream + + + git checkout naomi-dev + git fetch origin + git merge origin naomi-dev + cp -r ../Naomi ~ + + cd ~/Naomi + + #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 @@ -253,14 +184,16 @@ setup_wizard() { find ~/Naomi/installers -maxdepth 1 -iname '*.sh' -type f -exec chmod a+x {} \; NAOMI_DIR="$(cd ~/Naomi && pwd)" - + #FIXME: Replace APT with ARCH cd ~/Naomi APT=1 if [ $APT -eq 1 ]; then if [ $REQUIRE_AUTH -eq 1 ]; then SUDO_COMMAND "sudo pacman -Syu" SUDO_COMMAND "sudo pacman -Syu $SUDO_APPROVE" - SUDO_COMMAND "sudo bash ~/Documents/Github_Repos/Naomi/naomi_requirements.sh $SUDO_APPROVE" + #FIXME: Broke here & couldnt find file + pwd + SUDO_COMMAND "sudo bash naomi_requirements.sh $SUDO_APPROVE" if [ $? -ne 0 ]; then printf "${B_R}Notice:${B_W} Error installing pacman packages${NL}" >&2 exit 1 @@ -269,7 +202,9 @@ setup_wizard() { printf "${B_W}${NL}" sudo pacman -Syu sudo pacman -Syu $SUDO_APPROVE - sudo bash ~/Documents/Github_Repos/Naomi/naomi_requirements.sh $SUDO_APPROVE + pwd + #FIXME: Still broke and couldnt find file + sudo bash naomi_requirements.sh $SUDO_APPROVE if [ $? -ne 0 ]; then printf "${B_R}Notice:${B_W} Error installing arch packages${NL}" >&2 exit 1 @@ -298,13 +233,6 @@ setup_wizard() { fi fi - # make sure pulseaudio is running - # Check if pulseaudio or pipewire is installed - # pulseaudio --check - # if [ $? -ne 0 ]; then - # pulseaudio -D - # fi - #TODO: Write the backup script to install the servers if [ pulseaudio --version ]; then echo "Pulseaudio detected running pulseaudio setup..." @@ -423,6 +351,7 @@ setup_wizard() { echo 'NL="' >>~/.config/naomi/Naomi.sh echo '"' >>~/.config/naomi/Naomi.sh echo 'version="3.0"' >>~/.config/naomi/Naomi.sh + #TODO: Migrate and use current cloned DIR 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 @@ -435,9 +364,9 @@ setup_wizard() { 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 " 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_requirements.sh" >>~/.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 @@ -606,6 +535,8 @@ setup_wizard() { fi # Building and installing phonetisaurus + # Remove Phonetisaurus then installed +<&2 exit 1 fi - +comment # Installing & Building sphinxbase + #TODO: Use pip3 package instead #pip3 install pocketsphinx + #TODO: Chuck out block for pocketsphinx replace with pip3 (aaron said it didnt end well) + #TODO: There is PocketSphinx in the Linux Repos. +<&2 diff --git a/installers/naomi-setup.sh b/installers/naomi-setup.sh index b3ae6e3..045cd03 100755 --- a/installers/naomi-setup.sh +++ b/installers/naomi-setup.sh @@ -1,330 +1,21 @@ #!/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} - 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 -} +#TODO: Call The following +curl_check +jq_check +python_check +git_check +zip_check apt_setup_wizard() { if [ ! -f ~/Naomi/README.md ]; then @@ -333,24 +24,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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Apt Setup Wizard Failed.${NL}" @@ -362,24 +36,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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Apt Setup Wizard Failed.${NL}" @@ -387,110 +44,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 - fi -} - -arch_setup_wizard() { - if [ ! -f ~/Naomi/README.md ]; then - echo - printf "${B_G}Starting Naomi Arch Setup Wizard...${NL}${B_W}" - #. <( wget -O - "https://installers.projectnaomi.com/script.deb.sh" ); - # . <( wget -O - "./arch.pacman.sh" ); - #TODO: Check Why this is failing - bash installers/arch.pacman.sh; - - # ./installers/arch.pacman.sh - - if [ -n "$(command bash installers/arch.pacman.sh)" ]; 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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash - - wget_exit_code=$? - elif [ "$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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash - else - echo - printf "${B_R}Notice: ${B_W}Naomi Arch Setup Wizard Failed.${NL}" - echo - exit 1 - fi - elif [ -f ~/Naomi/README.md ] && [ -f ~/Naomi/installers/arch.pacman.sh ]; then - chmod a+x ~/Naomi/installers/arch.pacman.sh - bash ~/Naomi/installers/arch.pacman.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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash - else - echo - printf "${B_R}Notice: ${B_W}Naomi Arch Setup Wizard Failed.${NL}" - echo - 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 } @@ -504,24 +58,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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Yum Setup Wizard Failed.${NL}" @@ -533,24 +70,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 ~/Naomi - chmod a+x Naomi.sh - cd ~ - exec bash + installDone else echo printf "${B_R}Notice: ${B_W}Naomi Yum Setup Wizard Failed.${NL}" @@ -558,378 +78,23 @@ 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 pacman -Syu)" ]; then - arch_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 pacman -Syu)" ]; then - arch_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 -} +#TODO: Why is there a second check? tput reset os_detect curl_check jq_check python_check git_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}" +zip_check sleep 5 +tput reset -echo +printNaomi if [ "$1" == "--uninstall" ]; then naomi_uninstall diff --git a/installers/script.deb.sh b/installers/script.deb.sh index eae8b17..2a63090 100755 --- a/installers/script.deb.sh +++ b/installers/script.deb.sh @@ -1,5 +1,8 @@ #!/bin/bash +source "scripts/misc.sh" +source "scripts/pre_checks.sh" + ######################################### # Installs python and necessary packages # for deb based Naomi. This script will install python @@ -7,64 +10,6 @@ # 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 @@ -274,7 +219,7 @@ setup_wizard() { printf "${B_R}Notice:${B_W} Error installing apt packages${NL}" >&2 exit 1 fi - fi + fi else ERROR="" if [[ $(CHECK_PROGRAM msgfmt) -ne "0" ]]; then @@ -335,7 +280,7 @@ setup_wizard() { 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 + 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}" diff --git a/naomi_requirements.sh b/naomi_requirements.sh index 03cf764..0f2e556 100755 --- a/naomi_requirements.sh +++ b/naomi_requirements.sh @@ -16,18 +16,22 @@ ArchSetup() { SUDO_APPROVE="--noconfirm" fi done + #BUG: Cant be found why? +# cd ../ xargs -a <(awk '! /^ *(#|$)/' arch_requirements.txt) -r -- pacman -Syu $SUDO_APPROVE } if [ -e /etc/os-release ]; then - /etc/os-release + . /etc/os-release os=${ID} os_like=${ID_LIKE} - if [ "${os_like}"="arch" ]; then + if [ "${os_like}" = "arch" ]; then ArchSetup - elif [ "${os}"="debian" ]; then + elif [ "${os}" = "debian" ]; then DebianSetup - elif [ "${os}"="arch" ]; then + elif [ "${os}" = "ubuntu" ]; then + DebianSetup + elif [ "${os}" = "arch" ]; then ArchSetup fi else diff --git a/python_requirements.txt b/python_requirements.txt index 7e97ba5..02e8a7c 100644 --- a/python_requirements.txt +++ b/python_requirements.txt @@ -15,7 +15,9 @@ python-slugify mad # Pocketsphinx STT engine +pocketsphinx cmuclmtk +phonetisaurus # HN module semantic diff --git a/scripts/misc.sh b/scripts/misc.sh new file mode 100755 index 0000000..3ab5ddc --- /dev/null +++ b/scripts/misc.sh @@ -0,0 +1,182 @@ +#!/bin/bash + +######################################### +# Miscellaneous Script That has variables +# For Naomi Build Scripts +######################################### + +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" + +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}ARCH 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 + + echo + printf "${B_W}=========================================================================${NL}" + printf "${B_W}SECURITY SETUP:${NL}" + printf "${B_W}Let's examine a few security settings.${NL}" + echo + printf "${B_W}By default, Naomi is configured to require a password to perform actions as${NL}" + printf "${B_W}root (e.g. 'sudo ...') as well as confirm commands before continuing.${NL}" + printf "${B_W}This means you will have to watch the setup process to confirm everytime a new${NL}" + printf "${B_W}command needs to run.${NL}" + echo + printf "${B_W}However you can enable Naomi to continue the process uninterrupted for a hands off experience${NL}" + echo + printf "${B_W}Would you like the setup to run uninterrupted or would you like to look over the setup process?${NL}" + echo + printf "${B_M} 1${B_W}) Allow the process to run uninterrupted${NL}" + printf "${B_M} 2${B_W}) Require authentication to continue and run commands${NL}" + printf "${B_Blue}Choice [${B_M}1${B_Blue}-${B_M}2${B_Blue}]: ${B_W}" +} + +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}" +} diff --git a/scripts/naomi_cmds.sh b/scripts/naomi_cmds.sh new file mode 100755 index 0000000..f5a0df2 --- /dev/null +++ b/scripts/naomi_cmds.sh @@ -0,0 +1,343 @@ +#!/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/ + 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 pacman -Syu)" ]; then + arch_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 pacman -Syu)" ]; then + arch_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 +} diff --git a/scripts/pre_checks.sh b/scripts/pre_checks.sh new file mode 100755 index 0000000..a5f9362 --- /dev/null +++ b/scripts/pre_checks.sh @@ -0,0 +1,344 @@ +#!/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 -q -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 +}