mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Improve root installation
This commit is contained in:
parent
361939a431
commit
2ad658b921
6 changed files with 104 additions and 17 deletions
|
@ -24,7 +24,7 @@
|
|||
multi_instance=1
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
|
|
|
@ -22,6 +22,8 @@ new_path=$YNH_APP_NEW_PATH
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
final_path=/var/www/$app
|
||||
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
@ -66,7 +68,8 @@ fi
|
|||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
finalnginxconf=$nginx_conf_path
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
|
@ -78,7 +81,47 @@ fi
|
|||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
mv "$nginx_conf_path" "/etc/nginx/conf.d/${new_domain}.d/${app}.conf"
|
||||
finalnginxconf="/etc/nginx/conf.d/${new_domain}.d/${app}.conf"
|
||||
mv "$nginx_conf_path" "$finalnginxconf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# Edit specific content from nginx configuration
|
||||
#=================================================
|
||||
|
||||
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
|
||||
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
|
||||
then
|
||||
# uwsgi_param is only needed for non-root installation
|
||||
ynh_replace_string "#uwsgi_param " "wsgi_param " "$finalnginxconf"
|
||||
ynh_replace_string "#uwsgi_modifier1 " "uwsgi_modifier1 " "$finalnginxconf"
|
||||
|
||||
if [ "$is_public" -eq 0 ]
|
||||
then
|
||||
# ynh panel is only comptable with non-root installation
|
||||
# ynh panel is useless for public websites
|
||||
ynh_replace_string " #include conf.d/" " include conf.d/" "$finalnginxconf"
|
||||
fi
|
||||
# root install as an empty PATHURL to prevent '//static'
|
||||
ynh_replace_string "URL_PREFIX = ''" "URL_PREFIX = '$new_path'" "$settings"
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
fi
|
||||
|
||||
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
|
||||
then
|
||||
# uwsgi_param is only needed for non-root installation
|
||||
ynh_replace_string "uwsgi_param " "#wsgi_param " "$finalnginxconf"
|
||||
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
|
||||
|
||||
# ynh panel is only comptable with non-root installation
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
|
||||
# root install as an empty PATHURL to prevent '//static'
|
||||
ynh_replace_string "URL_PREFIX = '$old_path'" "URL_PREFIX = ''" "$settings"
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -102,6 +102,20 @@ systemctl reload postgresql
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
if [ "$path_url" == "/" ]
|
||||
then
|
||||
# $finalnginxconf comes from ynh_add_nginx_config
|
||||
# uwsgi_param is only needed for non-root installation
|
||||
ynh_replace_string "uwsgi_param " "#wsgi_param " "$finalnginxconf"
|
||||
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
|
||||
ynh_replace_string "location //" "location /" "$finalnginxconf"
|
||||
|
||||
# ynh panel is only comptable with non-root installation
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -152,7 +166,10 @@ cp ../conf/hub_config "$final_path/.config/hub"
|
|||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/.config/hub"
|
||||
ynh_replace_string "__GITHUBTOKEN__" "$github_token" "$final_path/.config/hub"
|
||||
|
||||
echo "alias git=hub" > "$final_path/.bashrc"
|
||||
cat <<EOF > "$final_path/.bashrc"
|
||||
alias git=hub
|
||||
PATH="$PATH:~/bin"
|
||||
EOF
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
|
@ -198,19 +215,26 @@ db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
|||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||
key=$(ynh_string_random)
|
||||
memc_port=$(ynh_find_port 8080)
|
||||
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
cp ../conf/settings.py "$settings"
|
||||
|
||||
cp ../conf/settings.py "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__NAME__" "$app" "$settings"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$settings"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$settings"
|
||||
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$settings"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$settings"
|
||||
ynh_replace_string "__KEY__" "$key" "$settings"
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$settings"
|
||||
ynh_replace_string "__MEMCPORT__" "$memc_port" "$settings"
|
||||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$settings"
|
||||
|
||||
ynh_replace_string "__NAME__" "$app" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__KEY__" "$key" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__PATHURL__" "$path_url" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__MEMCPORT__" "$memc_port" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||
# root install as an empty PATHURL to prevent '//static'
|
||||
if [ "$path_url" == "/" ]
|
||||
then
|
||||
ynh_replace_string "__PATHURL__" "" "$settings"
|
||||
else
|
||||
ynh_replace_string "__PATHURL__" "$path_url" "$settings"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP Filling up the database
|
||||
|
@ -273,6 +297,9 @@ if [ "$is_public" -eq 1 ]
|
|||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
|
||||
# ynh panel is not needed
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
set -u
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ chown -R "$app": "$final_path"
|
|||
|
||||
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
|
||||
libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \
|
||||
postgresql libpq-dev uwsgi uwsgi-plugin-python
|
||||
postgresql libpq-dev uwsgi uwsgi-plugin-python memcached
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PostgreSQL DATABASE
|
||||
|
|
|
@ -57,6 +57,20 @@ path_url=$(ynh_normalize_url_path "$path_url")
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
if [ "$path_url" == "/" ]
|
||||
then
|
||||
# $finalnginxconf comes from ynh_add_nginx_config
|
||||
# uwsgi_param is only needed for non-root installation
|
||||
ynh_replace_string "uwsgi_param " "#wsgi_param " "$finalnginxconf"
|
||||
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
|
||||
ynh_replace_string "location //" "location /" "$finalnginxconf"
|
||||
|
||||
# ynh panel is only comptable with non-root installation
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -123,6 +137,9 @@ if [ $is_public -eq 1 ]
|
|||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
|
||||
# ynh panel is not needed
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue