1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/searx_ynh.git synced 2024-09-03 20:16:30 +02:00
searx_ynh/scripts/install

86 lines
2.3 KiB
Text
Raw Normal View History

2014-05-10 11:54:15 +02:00
#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
2014-05-27 12:20:21 +02:00
is_public=$3
2014-05-10 11:54:15 +02:00
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a searx
if [[ ! $? -eq 0 ]]; then
2014-05-29 13:06:31 +02:00
exit 1
2014-05-10 11:54:15 +02:00
fi
2014-05-29 13:06:31 +02:00
sudo yunohost app setting searx is_public -v $is_public
2014-05-10 11:54:15 +02:00
# Check depends installation
2014-05-27 16:15:41 +02:00
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python -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
2014-05-31 12:19:18 +02:00
sudo dd if=/dev/zero of=/tmp/myswapfile bs=1M count=256
2014-05-12 21:44:08 +02:00
sudo chmod 600 /tmp/myswapfile
sudo mkswap /tmp/myswapfile
sudo swapon /tmp/myswapfile
fi
2014-05-12 21:44:08 +02:00
2014-05-10 11:54:15 +02:00
# Init virtualenv
2014-05-29 12:45:06 +02:00
if [ ! -d /opt/yunohost/searx ];
2014-05-10 11:58:58 +02:00
then
2014-05-29 12:45:06 +02:00
sudo mkdir -p /opt/yunohost/searx
2014-05-10 11:58:58 +02:00
fi
2014-05-29 12:45:06 +02:00
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"
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
if [ $path != "/" ];
2014-05-27 12:13:54 +02:00
then
2014-05-29 12:45:06 +02:00
sudo cp ../conf/settings.yml-noroot /opt/yunohost/searx/searx/settings.yml
2014-05-27 12:13:54 +02:00
else
2014-05-29 12:45:06 +02:00
sudo cp ../conf/settings.yml /opt/yunohost/searx/searx/
2014-05-27 12:13:54 +02:00
fi
2014-05-29 12:45:06 +02:00
sudo sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" /opt/yunohost/searx/searx/settings.yml
2014-05-10 11:54:15 +02:00
# Set permissions to searx directory
2014-05-29 12:45:06 +02:00
sudo useradd searx -d /opt/yunohost/searx
sudo chown searx:searx -R /opt/yunohost/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
2014-05-27 12:04:01 +02:00
sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
if [ $path != "/" ];
2014-05-27 12:04:01 +02:00
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
2014-05-10 11:54:15 +02:00
# Fix permission
2014-05-29 12:45:06 +02:00
#sudo find /opt/yunohost/searx/ -type d -exec chmod 2755 {} \;
#sudo find /opt/yunohost/searx/ -type f -exec chmod g+r,o+r {} \;
2014-05-10 11:54:15 +02:00
## Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo service uwsgi restart
2014-05-27 12:13:54 +02:00
if [ $is_public = "Yes" ];
2014-05-27 12:13:54 +02:00
then
2014-05-29 14:41:28 +02:00
sudo yunohost app setting searx skipped_uris -v "/"
else
sudo sed -i 's/#include conf/include conf/' /etc/nginx/conf.d/$domain.d/searx.conf
2014-05-27 12:13:54 +02:00
fi
2014-05-10 11:54:15 +02:00
sudo yunohost app ssowatconf