mirror of
https://github.com/YunoHost-Apps/searx_ynh.git
synced 2024-09-03 20:16:30 +02:00
61 lines
1.6 KiB
Bash
61 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$(sudo yunohost app setting searx domain)
|
|
path=$(sudo yunohost app setting searx path)
|
|
is_public=$(sudo yunohost app setting searx is_public)
|
|
|
|
|
|
# Check depends installation
|
|
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python -y
|
|
|
|
# Check Swap
|
|
if [ $(sudo swapon -s | wc -l) = 1 ];
|
|
then
|
|
sudo dd if=/dev/zero of=/tmp/myswapfile bs=1M count=128
|
|
sudo chmod 600 /tmp/myswapfile
|
|
sudo mkswap /tmp/myswapfile
|
|
sudo swapon /tmp/myswapfile
|
|
fi
|
|
|
|
# Move searx
|
|
if [ -d /opt/searx ];
|
|
then
|
|
sudo mkdir -p /opt/yunohost/searx
|
|
sudo mv /opt/searx /opt/yunohost/
|
|
sudo usermod -d /opt/yunohost/searx searx
|
|
sudo chown searx:searx -R /opt/yunohost/searx
|
|
fi
|
|
|
|
# Copy uwsgi config
|
|
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/
|
|
|
|
# Init virtualenv
|
|
sudo cp -r ../sources/* /opt/yunohost/searx/
|
|
sudo virtualenv /opt/yunohost/searx
|
|
sudo bash -c "source /opt/yunohost/searx/bin/activate && pip install -r /opt/yunohost/searx/requirements.txt"
|
|
|
|
# Disable swapfile
|
|
if [ -f /tmp/myswapfile ];
|
|
then
|
|
sudo swapoff /tmp/myswapfile
|
|
sudo rm -f /tmp/myswapfile
|
|
fi
|
|
|
|
# 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
|
|
|
|
if [ $is_public = "No" ];
|
|
then
|
|
sudo sed -i 's/#include conf/include conf/' /etc/nginx/conf.d/$domain.d/searx.conf
|
|
fi
|
|
|
|
## Reload Nginx and regenerate SSOwat conf
|
|
sudo service nginx reload
|
|
sudo service uwsgi restart
|