Bladeren bron

Compatible with MACOS (darwin)

Gamaliel Espinoza 8 jaren geleden
bovenliggende
commit
59e7276fee
1 gewijzigde bestanden met toevoegingen van 127 en 97 verwijderingen
  1. 127 97
      fourier_install.sh

+ 127 - 97
fourier_install.sh

@@ -1,121 +1,142 @@
 #install essential software
 #sudo apt-get update
 
+programspath=~/programs
+installerpath=$(pwd)
+configfile='/etc/fourier-config.json'
+gitbase="https://git.miralo.xyz/AudioValid"
+
+if [[ "$OSTYPE" == darwin* ]]; then
+	programspath=~/fourier
+fi
+
+[ ! -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
 
-ssh-keygen -t rsa -b 2048 -C "$HOSTNAME"
+
+if [[ "$OSTYPE" == darwin* ]]; then
+	keyfile="$programspath/fourier.key"
+	[ ! -f "$keyfile" ] && ssh-keygen -t rsa -b 2048 -f $keyfile
+else
+	keyfile="~/.ssh/id_rsa"
+	ssh-keygen -t rsa -b 2048 -C "$HOSTNAME" -f $keyfile
+fi
 
 echo "Please add the following public key to server's authorized keys:"
 
-cat ~/.ssh/id_rsa.pub
+cat $keyfile.pub
 
 read -p "Press enter to continue"
 
-echo "/usr/bin/autossh -N -f -M 7$PORT -oPubkeyAuthentication=yes -oPasswordAuthentication=no -oLogLevel=error  -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i /home/niofis/.ssh/id_rsa -R 6$PORT:localhost:22 rtunnel@server.fourier.audio -p 22" > ssh-tunnel.sh
-
-curl -L -o ssh-tunnel.service https://gist.githubusercontent.com/niofis/bc24f1b33414fd77d77f/raw/
-sudo mv ssh-tunnel.service /etc/systemd/system/ssh-tunnel.service
-
-sudo systemctl enable ssh-tunnel
-sudo systemctl start ssh-tunnel
-
-curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
-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 mysql-server mysql-client
-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
-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 python-mysqldb
-sudo apt-get install -y curl
-#sudo pip install mysql-connector==2.1.4
-sudo pip install requests
-
+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 /home/niofis/.ssh/id_rsa -R 6$PORT:localhost:22 rtunnel@server.fourier.audio -p 22" > ssh-tunnel.sh
+	curl -L -o ssh-tunnel.service https://gist.githubusercontent.com/niofis/bc24f1b33414fd77d77f/raw/
+	sudo mv ssh-tunnel.service /etc/systemd/system/ssh-tunnel.service
+	
+	sudo systemctl enable ssh-tunnel
+	sudo systemctl start ssh-tunnel
+fi
 
 
-#download fourier software
-cd ~
-mkdir programs
-cd ~/programs
-
-if [ "$REPOSRC" == "edesarrollos" ]; then
-	git clone https://git.miralo.xyz/AudioValid/fourier-common.git common
-	git clone https://git.miralo.xyz/AudioValid/fourier-server.git server
-	git clone https://git.miralo.xyz/AudioValid/fourier-fourier.git fourier
-	git clone https://git.miralo.xyz/AudioValid/fourier-alt.git fourier-alt
-	git clone https://git.miralo.xyz/AudioValid/fourier-monitor.git monitor
-	git clone https://git.miralo.xyz/AudioValid/fourier-uploader.git uploader
-	git clone https://git.miralo.xyz/AudioValid/fourier-ondemand.git ondemand
-	git clone https://git.miralo.xyz/AudioValid/fourier-admanager.git admanager
+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
-	git clone https://niofis@bitbucket.org/niofis/fourier-server.git server
-	git clone https://niofis@bitbucket.org/niofis/fourier.git fourier
-	git clone https://niofis@bitbucket.org/niofis/fourier-alt.git fourier-alt
-	git clone https://niofis@bitbucket.org/niofis/fourier-monitor.git monitor
-	git clone https://niofis@bitbucket.org/niofis/fourier-uploader.git uploader
-	git clone https://niofis@bitbucket.org/niofis/fourier-ondemand.git ondemand
-	git clone https://niofis@bitbucket.org/niofis/fourier-admanager.git admanager
+	curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
+	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
+	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 python-mysqldb
+	sudo apt-get install -y curl
+	#sudo pip install mysql-connector==2.1.4
+	sudo pip install requests
 fi
 
+cd $programspath
+
+#download fourier software
+git clone $gitbase/fourier-common.git common
+git clone $gitbase/fourier-server.git server
+git clone $gitbase/fourier-fourier.git fourier
+git clone $gitbase/fourier-alt.git fourier-alt
+git clone $gitbase/fourier-monitor.git monitor
+git clone $gitbase/fourier-uploader.git uploader
+git clone $gitbase/fourier-ondemand.git ondemand
+git clone $gitbase/fourier-admanager.git admanager
+
 #install fourier-server dependencies
-cd ~/programs/server
+cd $programspath/server
 npm install
 #install fourier-monitor dependencies
-cd ~/programs/monitor
+cd $programspath/monitor
 npm install
 #install fourier-uploader dependencies
-cd ~/programs/uploader
+cd $programspath/uploader
 npm install
 #install fourier-ondemand dependencies
-cd ~/programs/ondemand
+cd $programspath/ondemand
 npm install
 #install fourier-admanager dependencies
-cd ~/programs/admanager
+cd $programspath/admanager
 npm install
 
 sudo npm install -g pm2
 
-#build sdr lib
-sudo apt-get install -y libusb-1.0-0-dev
-cd ~/programs
-git clone https://github.com/niofis/rtl-sdr.git
-cd ~/programs/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
-#sudo make install
-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 ~/programs
-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=~/programs/nim-0.17.0/bin:$PATH" >> ~/.bashrc
+# build sdr lib
+if [[ "$OSTYPE" != darwin* ]]; then
+	sudo apt-get install -y libusb-1.0-0-dev
+	cd $programspath
+	git clone https://github.com/niofis/rtl-sdr.git
+	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
 
 #build fourier-alt
-cd ~/programs/fourier-alt
+cd $programspath/fourier-alt
 nimble build
 
 #configure ramdisk
@@ -130,19 +151,28 @@ nimble build
 #sudo mv fourier.service /etc/systemd/system/fourier.service
 #sudo systemctl enable fourier
 
-sudo mysql -u root -e "create database fourier;"
-sudo mysql -u root -e "create user 'fourier'@'localhost' identified by 'Sup3rDuper!';"
-sudo mysql -u root -e "grant all privileges on fourier.* to 'fourier'@'localhost';flush privileges;"
+if [[ "$OSTYPE" == darwin* ]]; then
+	[ ! -f "$configfile" ] && \
+	python $installerpath/configure.py \
+		   $installerpath/fourier-config.json \
+		   $configfile \
+		   -programs "$programspath" \
+		   -receivers $RECEIVERS_COUNT
+else
+	sudo mysql -u root -e "create database fourier;"
+	sudo mysql -u root -e "create user 'fourier'@'localhost' identified by 'Sup3rDuper!';"
+	sudo mysql -u root -e "grant all privileges on fourier.* to 'fourier'@'localhost';flush privileges;"
 
-cd ~
-curl -L -o fourier.sql https://gist.githubusercontent.com/niofis/cd843500ac96fe8ddc8f39a58a4afc55/raw/
-sudo mysql -u root -h localhost fourier < fourier.sql
+	cd ~
+	curl -L -o fourier.sql https://gist.githubusercontent.com/niofis/cd843500ac96fe8ddc8f39a58a4afc55/raw/
+	sudo mysql -u root -h localhost fourier < fourier.sql
 
-curl -L -o fourier-config.json https://gist.githubusercontent.com/niofis/0e95b950faa333909407b5a65270376d/raw/
-sudo mv fourier-config.json /etc/fourier-config.json
+	curl -L -o fourier-config.json https://gist.githubusercontent.com/niofis/0e95b950faa333909407b5a65270376d/raw/
+	sudo mv fourier-config.json /etc/fourier-config.json
 
-curl -L -o Fourier-key.json https://gist.githubusercontent.com/niofis/7f8ced8fc878acf8c9b45d8db3bb5458/raw/
-sudo mv Fourier-key.json /etc/Fourier-key.json
+	curl -L -o Fourier-key.json https://gist.githubusercontent.com/niofis/7f8ced8fc878acf8c9b45d8db3bb5458/raw/
+	sudo mv Fourier-key.json /etc/Fourier-key.json
+fi
 
 echo "****************************************************************************"
 echo "REMEMBER: Initialize attached storage and create a symlink named /var/fourier pointing to the storage volume"