Scripts cleanup
This commit is contained in:
parent
9c7a55e0c0
commit
5acde5fb76
|
@ -41,7 +41,7 @@
|
||||||
"default": "/searx"
|
"default": "/searx"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "public_site",
|
"name": "is_public",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Is it a public Searx site ?",
|
"en": "Is it a public Searx site ?",
|
||||||
"fr": "Est-ce un site public ?"
|
"fr": "Est-ce un site public ?"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
app="searx"
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
set -e
|
set -e
|
||||||
|
@ -6,30 +7,15 @@ set -e
|
||||||
# Source YNH helpers
|
# Source YNH helpers
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# This is a multi-instance app, meaning it can be installed several times independently
|
|
||||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
||||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
||||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
||||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
||||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
||||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
||||||
# The app instance name is probably what you are interested the most, since this is
|
|
||||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
||||||
# db names, ...
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
# Backup directory location for the app from where the script is executed and
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
# which will be compressed afterward
|
|
||||||
backup_dir=$YNH_APP_BACKUP_DIR
|
|
||||||
|
|
||||||
# Backup sources & data
|
# Backup sources & data
|
||||||
ynh_backup "/opt/yunohost/$app" "sources"
|
ynh_backup "/opt/yunohost/$app" "sources"
|
||||||
|
|
||||||
# Copy Nginx conf
|
# Copy Nginx conf
|
||||||
sudo mkdir -p ./conf
|
|
||||||
ynh_backup "/etc/uwsgi/apps-available/$app.ini" "conf/searx.ini"
|
ynh_backup "/etc/uwsgi/apps-available/$app.ini" "conf/searx.ini"
|
||||||
ynh_backup "/opt/yunohost/$app/searx/settings.yml" "conf/settings.yml"
|
ynh_backup "/opt/yunohost/$app/searx/settings.yml" "conf/settings.yml"
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"
|
||||||
|
|
|
@ -1,27 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
app="searx"
|
||||||
|
|
||||||
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$1
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$2
|
path=$YNH_APP_ARG_PATH
|
||||||
is_public=$3
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
|
# Remove trailing slash to path
|
||||||
|
path=${path%/}
|
||||||
|
#force location to be / or /foo
|
||||||
|
location=${path:-/}
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a searx
|
sudo yunohost app checkurl $domain$path -a $app \
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|| (echo "Path not available: $domain$path" && exit 1)
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Path need a trailing slash, and location does not.
|
|
||||||
# See conf/nginx.conf* usage
|
|
||||||
location=$path
|
|
||||||
if [[ ! $path == */ ]]; then
|
|
||||||
# no trailing slash, so add it
|
|
||||||
path=$path/
|
|
||||||
fi
|
|
||||||
if [[ ! "$location" == "/" ]]; then
|
|
||||||
# remove possible trailing slash
|
|
||||||
location=${location%/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save specific settings
|
# Save specific settings
|
||||||
sudo yunohost app setting searx is_public -v $is_public
|
sudo yunohost app setting searx is_public -v $is_public
|
||||||
|
@ -46,7 +44,7 @@ then
|
||||||
sudo swapon $tmp_swap_file
|
sudo swapon $tmp_swap_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
final_path=/opt/yunohost/searx
|
final_path=/opt/yunohost/$app
|
||||||
|
|
||||||
# Init virtualenv
|
# Init virtualenv
|
||||||
if [ ! -d $final_path ];
|
if [ ! -d $final_path ];
|
||||||
|
@ -79,17 +77,17 @@ sudo useradd searx -d $final_path
|
||||||
sudo chown searx:searx -R $final_path
|
sudo chown searx:searx -R $final_path
|
||||||
|
|
||||||
# Copy uwsgi config
|
# Copy uwsgi config
|
||||||
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/
|
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/$app.ini
|
||||||
sudo ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/
|
sudo ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/$app.ini
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf*
|
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf*
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf*
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf*
|
||||||
if [ "$path" != "/" ];
|
if [ "$path" != "/" ];
|
||||||
then
|
then
|
||||||
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/searx.conf
|
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
else
|
else
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/searx.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix permission
|
# Fix permission
|
||||||
|
@ -99,11 +97,10 @@ fi
|
||||||
## Reload Nginx and regenerate SSOwat conf
|
## Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo service uwsgi restart
|
sudo service uwsgi restart
|
||||||
sudo yunohost service add uwsgi -l /var/log/uwsgi/app/searx.log
|
sudo yunohost service add uwsgi -l /var/log/uwsgi/app/$app.log
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting searx unprotected_uris -v "/"
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
app="searx"
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting searx domain)
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
sudo rm -Rf /opt/yunohost/searx
|
# Retrieve arguments
|
||||||
sudo rm -f /etc/uwsgi/apps-enabled/searx.ini
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
sudo rm -f /etc/uwsgi/apps-available/searx.ini
|
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/searx.conf
|
# Remove files
|
||||||
|
sudo rm -Rf /opt/yunohost/$app
|
||||||
|
sudo rm -f /etc/uwsgi/apps-enabled/$app.ini
|
||||||
|
sudo rm -f /etc/uwsgi/apps-available/$app.ini
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
|
# Remove services
|
||||||
sudo service uwsgi stop
|
sudo service uwsgi stop
|
||||||
sudo killall uwsgi
|
sudo killall uwsgi
|
||||||
sudo service uwsgi start
|
sudo service uwsgi start
|
||||||
sudo service nginx reload
|
|
||||||
sudo yunohost app ssowatconf
|
# Remove user
|
||||||
sudo userdel searx
|
sudo userdel searx
|
||||||
|
|
||||||
|
# Reload Nginx
|
||||||
|
sudo service nginx reload
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
app="searx"
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
set -e
|
set -e
|
||||||
|
@ -6,22 +7,15 @@ set -e
|
||||||
# Source YNH helpers
|
# Source YNH helpers
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# This is a multi-instance app, meaning it can be installed several times independently
|
# Retrieve arguments
|
||||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
||||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
||||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
||||||
# The app instance name is probably what you are interested the most, since this is
|
|
||||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
||||||
# db names, ...
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Get old parameter of the app
|
# Remove trailing slash to path
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
path=${path%/}
|
||||||
path=$(sudo yunohost app setting $app path)
|
#force location to be / or /foo
|
||||||
is_public=$(sudo yunohost app setting $app is_public)
|
location=${path:-/}
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a $app
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
|
@ -30,7 +24,7 @@ if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
final_path=/opt/yunohost/searx
|
final_path=/opt/yunohost/$app
|
||||||
if [ -d $final_path ]; then
|
if [ -d $final_path ]; then
|
||||||
echo "There is already a directory: $final_path " | sudo tee /dev/stderr
|
echo "There is already a directory: $final_path " | sudo tee /dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -45,21 +39,8 @@ fi
|
||||||
# Run install script
|
# Run install script
|
||||||
# sudo bash -c "./install $domain $path $is_public $app"
|
# sudo bash -c "./install $domain $path $is_public $app"
|
||||||
|
|
||||||
|
|
||||||
# Path need a trailing slash, and location does not.
|
|
||||||
# See conf/nginx.conf* usage
|
|
||||||
location=$path
|
|
||||||
if [[ ! $path == */ ]]; then
|
|
||||||
# no trailing slash, so add it
|
|
||||||
path=$path/
|
|
||||||
fi
|
|
||||||
if [[ ! "$location" == "/" ]]; then
|
|
||||||
# remove possible trailing slash
|
|
||||||
location=${location%/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save specific settings
|
# Save specific settings
|
||||||
sudo yunohost app setting searx is_public -v $is_public
|
sudo yunohost app setting $app is_public -v $is_public
|
||||||
|
|
||||||
# Check depends installation
|
# Check depends installation
|
||||||
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python -y
|
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python -y
|
||||||
|
@ -82,7 +63,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore sources
|
# Restore sources
|
||||||
final_path=/opt/yunohost/searx
|
final_path=/opt/yunohost/$app
|
||||||
sudo cp -a "./sources" $final_path
|
sudo cp -a "./sources" $final_path
|
||||||
|
|
||||||
# Init virtualenv
|
# Init virtualenv
|
||||||
|
@ -110,14 +91,13 @@ sudo ln -s "/etc/uwsgi/apps-available/$app.ini" /etc/uwsgi/apps-enabled/
|
||||||
# Nginx conf
|
# Nginx conf
|
||||||
sudo cp "conf/nginx.conf" $nginx_conf
|
sudo cp "conf/nginx.conf" $nginx_conf
|
||||||
|
|
||||||
## Reload Nginx and regenerate SSOwat conf
|
|
||||||
sudo service nginx reload
|
|
||||||
sudo service uwsgi restart
|
|
||||||
sudo yunohost service add uwsgi -l /var/log/uwsgi/app/searx.log
|
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting searx unprotected_uris -v "/"
|
sudo yunohost app setting searx unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
## Reload services
|
||||||
|
sudo service nginx reload
|
||||||
|
sudo service uwsgi restart
|
||||||
|
sudo yunohost service add uwsgi -l /var/log/uwsgi/app/$app.log
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
app="searx"
|
||||||
|
|
||||||
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(sudo yunohost app setting searx domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(sudo yunohost app setting searx path)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
is_public=$(sudo yunohost app setting searx is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
|
|
||||||
# Path need a trailing slash, and location does not.
|
# Remove trailing slash to path
|
||||||
# See conf/nginx.conf usage
|
path=${path%/}
|
||||||
location=$path
|
#force location to be / or /foo
|
||||||
if [[ ! $path == */ ]]; then
|
location=${path:-/}
|
||||||
# no trailing slash, so add it
|
|
||||||
path=$path/
|
|
||||||
fi
|
|
||||||
if [[ ! "$location" == "/" ]]; then
|
|
||||||
# remove possible trailing slash
|
|
||||||
location=${location%/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check depends installation
|
# Check depends installation
|
||||||
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python -y
|
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python -y
|
||||||
|
@ -36,7 +36,7 @@ then
|
||||||
sudo swapon $tmp_swap_file
|
sudo swapon $tmp_swap_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
final_path=/opt/yunohost/searx
|
final_path=/opt/yunohost/$app
|
||||||
sudo cp -r ../sources/* $final_path
|
sudo cp -r ../sources/* $final_path
|
||||||
sudo bash -c "source $final_path/bin/activate && pip install -r $final_path/requirements-ynh.txt --upgrade"
|
sudo bash -c "source $final_path/bin/activate && pip install -r $final_path/requirements-ynh.txt --upgrade"
|
||||||
|
|
||||||
|
@ -47,12 +47,6 @@ then
|
||||||
sudo rm -f $tmp_swap_file
|
sudo rm -f $tmp_swap_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove trailing "/" for next commands if installing on a subpath
|
|
||||||
if [ "$path" != "/" ];
|
|
||||||
then
|
|
||||||
path=${path%/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Configuration Searx
|
#Configuration Searx
|
||||||
sudo cp ../conf/settings.yml $final_path/searx/
|
sudo cp ../conf/settings.yml $final_path/searx/
|
||||||
sudo sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" $final_path/searx/settings.yml
|
sudo sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" $final_path/searx/settings.yml
|
||||||
|
@ -70,30 +64,29 @@ fi
|
||||||
sudo chown searx:searx -R $final_path
|
sudo chown searx:searx -R $final_path
|
||||||
|
|
||||||
# Copy uwsgi config
|
# Copy uwsgi config
|
||||||
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/
|
sudo cp ../conf/searx.ini /etc/uwsgi/apps-available/$app.ini
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf*
|
sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf*
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf*
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf*
|
||||||
if [ "$path" != "/" ];
|
if [ "$path" != "/" ];
|
||||||
then
|
then
|
||||||
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/searx.conf
|
sudo cp ../conf/nginx.conf-noroot /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
else
|
else
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/searx.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix permission
|
# Fix permission
|
||||||
#sudo find $final_path/ -type d -exec chmod 2755 {} \;
|
#sudo find $final_path/ -type d -exec chmod 2755 {} \;
|
||||||
#sudo find $final_path/ -type f -exec chmod g+r,o+r {} \;
|
#sudo find $final_path/ -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" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting searx skipped_uris -d
|
sudo yunohost app setting searx skipped_uris -d
|
||||||
sudo yunohost app setting searx unprotected_uris -v "/"
|
sudo yunohost app setting searx unprotected_uris -v "/"
|
||||||
fi
|
fi
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
## Reload services
|
||||||
|
sudo service nginx reload
|
||||||
|
sudo service uwsgi restart
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue