searx_ynh/scripts/install

70 lines
1.9 KiB
Plaintext
Raw Normal View History

2014-05-10 11:54:15 +02:00
#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a searx
sudo yunohost app setting searx skipped_uris -v "$path"
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Check depends installation
2014-05-10 12:03:56 +02:00
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev -y
2014-05-10 11:54:15 +02:00
2014-05-12 21:44:08 +02:00
# Check Swap
2014-05-16 21:25:52 +02:00
if [ $(sudo swapon -s | wc -l) = 1 ];
2014-05-12 21:44:08 +02:00
then
sudo dd if=/dev/zero of=/tmp/myswapfile bs=1M count=1024
sudo chmod 600 /tmp/myswapfile
sudo mkswap /tmp/myswapfile
sudo swapon /tmp/myswapfile
fi
2014-05-10 11:54:15 +02:00
# Init virtualenv
2014-05-10 11:58:58 +02:00
if [ ! -d /opt/searx ];
then
2014-05-10 12:05:28 +02:00
sudo mkdir /opt/searx
2014-05-10 11:58:58 +02:00
fi
2014-05-10 12:05:28 +02:00
sudo cp -r ../sources/* /opt/searx
2014-05-10 11:58:58 +02:00
sudo virtualenv /opt/searx
2014-05-10 12:06:42 +02:00
sudo bash -c "source /opt/searx/bin/activate && pip install -r /opt/searx/requirements.txt"
2014-05-10 11:54:15 +02:00
2014-05-12 21:44:08 +02:00
# Disable swapfile
if [ -f /tmp/myswapfile ];
then
sudo swapoff /tmp/myswapfile
sudo rm -f /tmp/myswapfile
fi
2014-05-10 11:54:15 +02:00
#Configuration Searx
2014-05-10 12:12:51 +02:00
sudo cp ../conf/settings.yml /opt/searx/searx/
sudo sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" /opt/searx/searx/settings.yml
2014-05-10 11:54:15 +02:00
# Set permissions to searx directory
2014-05-10 12:16:24 +02:00
sudo useradd searx -d /opt/searx
sudo chown searx:searx -R /opt/searx
2014-05-10 11:54:15 +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
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/searx.conf
# Fix permission
#sudo chmod 755 /etc/searx/
#sudo find /opt/yunohost/searx/ -type d -exec chmod 2755 {} \;
#sudo find /opt/yunohost/searx/ -type f -exec chmod g+r,o+r {} \;
#sudo chmod 644 /etc/searx/*
## Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo service uwsgi restart
2014-05-16 21:26:33 +02:00
#sudo yunohost app setting searx skipped_uris -v "/"
2014-05-10 11:54:15 +02:00
sudo yunohost app ssowatconf