# version 1.0.2 # install essential software # sudo apt-get update installer_version=1.0.3 programspath=~/programs installerpath=$(pwd) configfile='/etc/fourier-config.json' gitbase="gogs@git.miralo.xyz:AudioValid" tunnel_user=rtunnel datapath='/var/fourier' serverhost='monitor.audiovalid.com' tunnelfile="$programspath/ssh-tunnel.sh" mysql_user=fourier mysql_passwd='Sup3rDuper!' mysql_db=fourier echo "Fourier installer $installer_version" echo "------------------------------------" if [[ "$OSTYPE" == darwin* ]]; then programspath=~/fourier fi clonerepo() { GIT_SSH_COMMAND="ssh -i $installerpath/repokey" \ git clone $gitbase/$1 $2 } [ ! -d "$programspath" ] && mkdir $programspath read -p "Whats this box port (last 3 numbers with zero for padding)? " PORT read -p "How many receivers has this box? " RECEIVERS_COUNT read -p "Box ID (from API): " BOX_ID read -p "API secret: " API_SECRET findmnt /media/datadrive if [ "$?" -neq 0 ]; then echo -e '\e[34mData drive is not mounted\e[0m' fi if [[ "$OSTYPE" == darwin* ]]; then keyfile="$programspath/fourier.key" [ ! -f "$keyfile" ] && ssh-keygen -t rsa -b 2048 -f $keyfile else keyspath=~/.ssh keyfile="$keyspath/id_rsa" [ ! -d "$keyspath" ] && mkdir $keyspath ssh-keygen -t rsa -b 2048 -C "$HOSTNAME" -f $keyfile fi echo -e "\e[33mPlease add the following public key to server's authorized keys:\e[0m" cat $keyfile.pub read -p "Press enter to continue" if [[ "$OSTYPE" != darwin* ]]; then echo "/usr/bin/autossh -N -f -M 7$PORT -oPubkeyAuthentication=yes -oPasswordAuthentication=no -oLogLevel=error -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i $keyfile -R 6$PORT:localhost:22 $tunnel_user@$serverhost -p 22" > $tunnelfile sudo mv $installerpath/ssh-tunnel.service /etc/systemd/system/ssh-tunnel.service sudo systemctl enable ssh-tunnel sudo systemctl start ssh-tunnel fi if [[ "$OSTYPE" == darwin* ]]; then depend=( python gcc vim tmux autossh lame nodejs \ ezstream libusb rtl-sdr nim portaudio ) for dep in "${depend[@]}" do brew list $dep > /dev/null [ "$?" -eq 1 ] && brew install $dep done envpath="$programspath/env" [ ! -d "$envpath" ] && virtualenv $programspath/env source $envpath/bin/activate pip install -r $installerpath/requirements.txt else curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install alsa-utils sudo apt-get install -y libudev-dev sudo apt-get install -y tmux sudo apt-get install -y vim sudo apt-get install -y autossh sudo apt-get install -y git-core sudo apt-get install -y build-essential sudo apt-get install -y nodejs sudo apt-get install -y python-dev sudo apt-get install -y lame sudo apt-get install -y ezstream sudo apt-get install -y cmake sudo apt-get install -y rtl-sdr sudo apt-get install sqlite3 wget https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py sudo apt-get install -y portaudio19-dev sudo pip install pyaudio sudo apt-get install -y ffmpeg sudo pip install pydub sudo pip install numpy sudo apt-get install -y gfortran libopenblas-dev liblapack-dev sudo pip install scipy sudo apt-get install -y python-matplotlib sudo apt-get install -y curl sudo pip install requests sudo pip install python-firebase cd tools sudo python ./setup.py install cd .. fi sudo chmod 0600 $installerpath/repokey cd $programspath clonerepo fourier-module.git module clonerepo fourier-common.git common clonerepo fourier-server.git server clonerepo fourier-fourier.git fourier clonerepo fourier-alt.git fourier-alt clonerepo fourier-monitor.git monitor clonerepo fourier-uploader.git uploader clonerepo fourier-ondemand.git ondemand cd $programspath/server npm install cd $programspath/monitor npm install cd $programspath/uploader npm install cd $programspath/module sudo python setup.py install cd $programspath/ondemand sudo python setup.py install sudo npm install -g pm2 # build sdr lib if [[ "$OSTYPE" != darwin* ]]; then sudo apt-get install -y libusb-1.0-0-dev cd $programspath clonerepo rtl-sdr.git rtl-sdr cd $programspath/rtl-sdr mkdir build cd build cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON make sudo cp ./src/rtl_fm /usr/bin/rtl_fm echo "SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", MODE:="0666"" | sudo tee -a /etc/udev/rules.d/rtl-sdr.rules #build and install nim cd $programspath curl -L https://nim-lang.org/download/nim-0.17.0.tar.xz -o nim-0.17.0.tar.xz tar xvf nim-0.17.0.tar.xz cd nim-0.17.0 sh build.sh bin/nim c koch ./koch tools echo "export PATH=$programspath/nim-0.17.0/bin:$PATH" >> ~/.bashrc fi cd $programspath/fourier-alt nimble build # --------------------------------- # # Generación de los scripts con pm2 # # --------------------------------- # # cd $programspath # pm2 start fourier-ondemand --interpreter python --name ondemand # pm2 start server # pm2 start monitor # pm2 start uploader [ ! -f "$configfile" ] && \ sudo python $installerpath/configure.py \ $installerpath/fourier-config.json \ $configfile \ -programs "$programspath" \ -receivers $RECEIVERS_COUNT \ -api-secret $API_SECRET \ -box-id "$BOX_ID" if [[ "$OSTYPE" != darwin* ]]; then sudo mysql -u root -e "create database $mysql_db;" sudo mysql -u root -e "create user '$mysql_user'@'localhost' identified by '$mysql_passwd';" sudo mysql -u root -e "grant all privileges on $mysql_db.* to '$mysql_user'@'localhost';flush privileges;" cd ~ sudo mysql -u root -h localhost $mysql_db < $installerpath/fourier.sql sudo cp $installerpath/fourier-key.json /etc/Fourier-key.json fi echo "****************************************************************************" echo "REMEMBER: Initialize attached storage and create a symlink named $datapath pointing to the storage volume" echo "****************************************************************************"