| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- # 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
- mount_point=/media/datadrive
- echo "Fourier installer $installer_version"
- echo "------------------------------------"
- if [[ "$OSTYPE" == darwin* ]]; then
- programspath=~/fourier
- fi
- clonerepo() {
- GIT_SSH_COMMAND="ssh -i $installerpath/repokey -o StrictHostKeychecking=no" \
- 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
- sudo apt-get install -y python python-pip
- findmnt "$mount_point"
- if [ "$?" -neq 0 ]; then
- echo -e 'Data drive is not mounted'
- 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 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 -y alsa-utils alsa-tools
- 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 -y sqlite3
- sudo apt-get install -y portaudio19-dev
- sudo pip install pyaudio pyusb pydub numpy requests \
- scipy python-firebase
- sudo apt-get install -y ffmpeg
- sudo apt-get install -y gfortran libopenblas-dev liblapack-dev
- sudo apt-get install -y python-matplotlib
- sudo apt-get install -y curl
- sudo pip install
- sudo npm install -g http-server
- 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
- fi
- # --------------------------------- #
- # 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 "****************************************************************************"
|