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/upgrade

144 lines
3.9 KiB
Text
Raw Normal View History

2014-07-23 00:00:31 +02:00
<<<<<<< HEAD
2014-05-28 17:58:58 +02:00
#!/bin/bash
2014-07-23 00:00:31 +02:00
=======
>>>>>>> 90736b2cc32bd424c78355499e1bfb61062af8ca
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-23 00:00:31 +02:00
<<<<<<< HEAD
2014-05-29 14:20:44 +02:00
# 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
2014-07-23 00:00:31 +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-07-23 00:00:31 +02:00
>>>>>>> 90736b2cc32bd424c78355499e1bfb61062af8ca
2014-05-29 14:20:44 +02:00
# Check Swap
if [ $(sudo swapon -s | wc -l) = 1 ];
then
2014-07-23 00:00:31 +02:00
<<<<<<< HEAD
2014-05-29 14:20:44 +02:00
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/
2014-05-29 14:21:36 +02:00
sudo usermod -d /opt/yunohost/searx searx
2014-05-29 14:20:44 +02:00
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"
2014-07-23 00:00:31 +02:00
=======
2014-07-21 23:53:27 +02:00
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
# Init virtualenv
if [ ! -d /opt/searx ];
then
sudo mkdir /opt/searx
fi
sudo cp -r ../sources/* /opt/searx
sudo virtualenv /opt/searx
sudo bash -c "source /opt/searx/bin/activate && pip install -r /opt/searx/requirements.txt"
2014-07-23 00:00:31 +02:00
>>>>>>> 90736b2cc32bd424c78355499e1bfb61062af8ca
2014-05-29 14:20:44 +02:00
# Disable swapfile
if [ -f /tmp/myswapfile ];
then
2014-07-23 00:00:31 +02:00
<<<<<<< HEAD
2014-05-29 14:20:44 +02:00
sudo swapoff /tmp/myswapfile
sudo rm -f /tmp/myswapfile
fi
2014-05-29 14:44:56 +02:00
# 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
2014-05-29 14:20:44 +02:00
## Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo service uwsgi restart
2014-07-23 00:00:31 +02:00
=======
2014-07-21 23:53:27 +02:00
sudo swapoff /tmp/myswapfile
sudo rm -f /tmp/myswapfile
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
sudo cp ../conf/settings.yml /opt/searx/searx/
sudo sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" /opt/searx/searx/settings.yml
if [ "$path" != "/" ];
then
sudo sed -i -e "s@ynhbaseurl@https://$domain$path/@g" /opt/searx/searx/settings.yml
else
sudo sed -i -e "s@ynhbaseurl@https://$domain$path@g" /opt/searx/searx/settings.yml
fi
# Set permissions to searx directory
sudo useradd searx -d /opt/searx
sudo chown searx:searx -R /opt/searx
# 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
#sudo find /opt/searx/ -type d -exec chmod 2755 {} \;
#sudo find /opt/searx/ -type f -exec chmod g+r,o+r {} \;
## Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo service uwsgi restart
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting searx skipped_uris -v "/"
fi
sudo yunohost app ssowatconf
2014-07-23 00:00:31 +02:00
>>>>>>> 90736b2cc32bd424c78355499e1bfb61062af8ca