2014-09-23 12:04:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-05-29 14:20:44 +02:00
|
|
|
# Retrieve arguments
|
2014-05-29 14:44:56 +02:00
|
|
|
domain=$(sudo yunohost app setting searx domain)
|
|
|
|
path=$(sudo yunohost app setting searx path)
|
|
|
|
is_public=$(sudo yunohost app setting searx is_public)
|
2014-05-29 14:20:44 +02:00
|
|
|
|
2014-07-22 12:04:58 +02:00
|
|
|
# Remove trailing "/" for next commands
|
|
|
|
path=${path%/}
|
|
|
|
|
2014-07-21 23:53:27 +02:00
|
|
|
# Check depends installation
|
|
|
|
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev -y
|
2014-05-29 14:20:44 +02:00
|
|
|
|
|
|
|
# Check Swap
|
2014-09-23 12:03:58 +02:00
|
|
|
tmp_swap_file=/tmp/searx_swapfile
|
2014-05-29 14:20:44 +02:00
|
|
|
if [ $(sudo swapon -s | wc -l) = 1 ];
|
|
|
|
then
|
2014-09-23 13:24:30 +02:00
|
|
|
sudo dd if=/dev/zero of=$tmp_swap_file bs=1M count=256
|
2014-09-23 12:03:58 +02:00
|
|
|
sudo chmod 600 $tmp_swap_file
|
|
|
|
sudo mkswap $tmp_swap_file
|
|
|
|
sudo swapon $tmp_swap_file
|
2014-07-21 23:53:27 +02:00
|
|
|
fi
|
|
|
|
|
2014-09-23 12:20:00 +02:00
|
|
|
final_path=/opt/yunohost/searx
|
|
|
|
|
2014-07-21 23:53:27 +02:00
|
|
|
# Init virtualenv
|
2014-09-23 12:20:00 +02:00
|
|
|
if [ ! -d $final_path ];
|
2014-07-21 23:53:27 +02:00
|
|
|
then
|
2014-09-23 12:20:00 +02:00
|
|
|
sudo mkdir $final_path
|
2014-07-21 23:53:27 +02:00
|
|
|
fi
|
2014-09-23 12:20:00 +02:00
|
|
|
sudo cp -r ../sources/* $final_path
|
|
|
|
sudo virtualenv $final_path
|
|
|
|
sudo bash -c "source $final_path/bin/activate && pip install -r $final_path/requirements.txt"
|
2014-05-29 14:20:44 +02:00
|
|
|
|
|
|
|
# Disable swapfile
|
2014-09-23 12:03:58 +02:00
|
|
|
if [ -f $tmp_swap_file ];
|
2014-05-29 14:20:44 +02:00
|
|
|
then
|
2014-09-23 12:03:58 +02:00
|
|
|
sudo swapoff $tmp_swap_file
|
|
|
|
sudo rm -f $tmp_swap_file
|
2014-07-21 23:53:27 +02:00
|
|
|
fi
|
|
|
|
|
2014-07-22 12:04:58 +02:00
|
|
|
# Remove trailing "/" for next commands if installing on a subpath
|
|
|
|
if [ "$path" != "/" ];
|
|
|
|
then
|
|
|
|
path=${path%/}
|
|
|
|
fi
|
|
|
|
|
2014-07-21 23:53:27 +02:00
|
|
|
#Configuration Searx
|
2014-09-23 12:20:00 +02:00
|
|
|
sudo cp ../conf/settings.yml $final_path/searx/
|
|
|
|
sudo sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" $final_path/searx/settings.yml
|
2014-07-21 23:53:27 +02:00
|
|
|
if [ "$path" != "/" ];
|
|
|
|
then
|
2014-09-23 12:20:00 +02:00
|
|
|
sudo sed -i -e "s@ynhbaseurl@https://$domain$path/@g" $final_path/searx/settings.yml
|
2014-07-21 23:53:27 +02:00
|
|
|
else
|
2014-12-01 12:27:58 +01:00
|
|
|
sudo sed -i -e "s@ynhbaseurl@False@g" $final_path/searx/settings.yml
|
2014-07-21 23:53:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set permissions to searx directory
|
2014-09-23 12:20:00 +02:00
|
|
|
sudo useradd searx -d $final_path
|
|
|
|
sudo chown searx:searx -R $final_path
|
2014-07-21 23:53:27 +02:00
|
|
|
|
|
|
|
# Copy uwsgi config
|
|
|
|
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/
|
|
|
|
sudo ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
|
|
|
|
if [ "$path" != "/" ];
|
|
|
|
then
|
|
|
|
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/searx.conf
|
|
|
|
else
|
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/searx.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fix permission
|
2014-09-23 12:20:00 +02:00
|
|
|
#sudo find $final_path/ -type d -exec chmod 2755 {} \;
|
|
|
|
#sudo find $final_path/ -type f -exec chmod g+r,o+r {} \;
|
2014-07-21 23:53:27 +02:00
|
|
|
|
|
|
|
## Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo service uwsgi restart
|
|
|
|
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
2014-10-30 12:50:49 +01:00
|
|
|
sudo yunohost app setting searx skipped_uris -d
|
|
|
|
sudo yunohost app setting searx unprotected_uris -v "/"
|
2014-07-21 23:53:27 +02:00
|
|
|
fi
|
|
|
|
sudo yunohost app ssowatconf
|
2014-07-23 00:14:40 +02:00
|
|
|
|