mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Add ynh_add_config
This commit is contained in:
parent
3f8363cdc5
commit
96ef2e0de9
7 changed files with 28 additions and 106 deletions
|
@ -1,15 +1,10 @@
|
||||||
# See here for more informations
|
|
||||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
|
||||||
|
|
||||||
# Move this file from check_process.default to check_process when you have filled it.
|
|
||||||
|
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld"
|
||||||
path="/path" (PATH)
|
path="/path"
|
||||||
admin="john" (USER)
|
admin="john"
|
||||||
password="randompass"
|
password="randompass"
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1
|
||||||
github_account="myaccount"
|
github_account="myaccount"
|
||||||
github_token="myoauthtoken"
|
github_token="myoauthtoken"
|
||||||
; Checks
|
; Checks
|
||||||
|
@ -23,7 +18,6 @@
|
||||||
upgrade=1 from_commit=cef22ac5634565cecd2d8545229efe3fe79d85bc
|
upgrade=1 from_commit=cef22ac5634565cecd2d8545229efe3fe79d85bc
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
port_already_use=0
|
|
||||||
change_url=1
|
change_url=1
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
github.com:
|
github.com:
|
||||||
- user: __GITHUBUSER__
|
- user: __GITHUB_ACCOUNT__
|
||||||
oauth_token: __GITHUBTOKEN__
|
oauth_token: __GITHUB_TOKEN__
|
||||||
protocol: https
|
protocol: https
|
||||||
|
|
|
@ -42,7 +42,7 @@ from logging.handlers import SysLogHandler
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
ADMINS = (
|
ADMINS = (
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
('__ADMIN__', '__ADMIN_MAIL__'),
|
||||||
)
|
)
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
MANAGERS = ADMINS
|
||||||
|
@ -52,9 +52,9 @@ DATABASES = {
|
||||||
# Use "postgresql" or "mysql".
|
# Use "postgresql" or "mysql".
|
||||||
"ENGINE": "django.db.backends.postgresql",
|
"ENGINE": "django.db.backends.postgresql",
|
||||||
# Database name.
|
# Database name.
|
||||||
"NAME": "__NAME__",
|
"NAME": "__APP__",
|
||||||
# Database user.
|
# Database user.
|
||||||
"USER": "__NAME__",
|
"USER": "__APP__",
|
||||||
# Name of role to alter to set parameters in PostgreSQL,
|
# Name of role to alter to set parameters in PostgreSQL,
|
||||||
# use in case role name is different than user used for authentication.
|
# use in case role name is different than user used for authentication.
|
||||||
# "ALTER_ROLE": "weblate",
|
# "ALTER_ROLE": "weblate",
|
||||||
|
@ -221,8 +221,8 @@ TEMPLATES = [
|
||||||
|
|
||||||
# GitHub username and token for sending pull requests.
|
# GitHub username and token for sending pull requests.
|
||||||
# Please see the documentation for more details.
|
# Please see the documentation for more details.
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
GITHUB_USERNAME = "__GITHUB_ACCOUNT__"
|
||||||
GITHUB_TOKEN = "__GITHUBTOKEN__"
|
GITHUB_TOKEN = "__GITHUB_TOKEN__"
|
||||||
|
|
||||||
# GitLab username and token for sending merge requests.
|
# GitLab username and token for sending merge requests.
|
||||||
# Please see the documentation for more details.
|
# Please see the documentation for more details.
|
||||||
|
|
|
@ -5,7 +5,7 @@ protocol = uwsgi
|
||||||
socket = /var/run/__APP__/socket
|
socket = /var/run/__APP__/socket
|
||||||
|
|
||||||
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
|
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
|
||||||
mount = __PATH__=__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/wsgi.py
|
mount = __PATH__=__FINALPATH__/venv/lib/__WEBLATE_PYPATH__/site-packages/weblate/wsgi.py
|
||||||
|
|
||||||
# Add path to Weblate checkout if you did not install
|
# Add path to Weblate checkout if you did not install
|
||||||
# Weblate by pip
|
# Weblate by pip
|
||||||
|
|
BIN
doc/screenshots/BigScreenshot.png
Normal file
BIN
doc/screenshots/BigScreenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
|
@ -100,9 +100,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||||
ynh_script_progression --message="Configure hub..."
|
ynh_script_progression --message="Configure hub..."
|
||||||
|
|
||||||
mkdir "$final_path/.config/"
|
mkdir "$final_path/.config/"
|
||||||
cp ../conf/hub_config "$final_path/.config/hub"
|
ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub"
|
||||||
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub"
|
|
||||||
ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub"
|
|
||||||
|
|
||||||
cat <<EOF > "$final_path/.bashrc"
|
cat <<EOF > "$final_path/.bashrc"
|
||||||
eval "$(hub alias -s /bin/bash)"
|
eval "$(hub alias -s /bin/bash)"
|
||||||
|
@ -147,25 +145,10 @@ db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||||
key=$(ynh_string_random --length=50)
|
key=$(ynh_string_random --length=50)
|
||||||
redis_db=$(ynh_redis_get_free_db)
|
redis_db=$(ynh_redis_get_free_db)
|
||||||
|
path_url="${path_url%/}"
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
cp "../conf/settings.py" "$settings"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings"
|
ynh_add_config --template="../conf/settings.py" --destination="$settings"
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings"
|
|
||||||
|
|
||||||
# remove last "/" of $path_url
|
|
||||||
ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings"
|
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
|
|
||||||
|
@ -211,16 +194,9 @@ ynh_store_file_checksum --file="$settings"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configure uwsgi..."
|
ynh_script_progression --message="Configure uwsgi..."
|
||||||
|
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini"
|
ynh_add_config --template="../conf/uwsgi.ini" --destination="$finaluwsgiini"
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini"
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini"
|
|
||||||
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$finaluwsgiini"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -235,10 +211,8 @@ ynh_add_systemd_config --service="$app" --template="weblate.service"
|
||||||
ynh_script_progression --message="Configure celery..."
|
ynh_script_progression --message="Configure celery..."
|
||||||
|
|
||||||
celeryconf="$final_path/celery-weblate"
|
celeryconf="$final_path/celery-weblate"
|
||||||
cp ../conf/celery-weblate "$celeryconf"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf"
|
ynh_add_config --template="../conf/celery-weblate" --destination="$celeryconf"
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf"
|
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service"
|
ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service"
|
||||||
|
|
||||||
|
@ -276,9 +250,7 @@ yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
ynh_script_progression --message="Configuring permissions..."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ "$is_public" -eq 1 ]
|
if [ "$is_public" -eq 1 ]
|
||||||
|
@ -312,4 +284,8 @@ If you facing an issue or want to improve this app, please open a new issue in t
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message" "$admin"
|
ynh_send_readme_to_admin "$message" "$admin"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -58,15 +58,6 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
# Fix is_public as a boolean value
|
|
||||||
if [ "$is_public" = "Yes" ]; then
|
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
|
||||||
is_public=1
|
|
||||||
elif [ "$is_public" = "No" ]; then
|
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
|
||||||
is_public=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d "$final_path/bin/" ]]
|
if [[ -d "$final_path/bin/" ]]
|
||||||
then
|
then
|
||||||
ynh_secure_remove --file="$final_path/bin/"
|
ynh_secure_remove --file="$final_path/bin/"
|
||||||
|
@ -122,9 +113,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||||
ynh_script_progression --message="Configure hub..."
|
ynh_script_progression --message="Configure hub..."
|
||||||
|
|
||||||
mkdir -p "$final_path/.config/"
|
mkdir -p "$final_path/.config/"
|
||||||
cp ../conf/hub_config "$final_path/.config/hub"
|
ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub"
|
||||||
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub"
|
|
||||||
ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub"
|
|
||||||
|
|
||||||
cat <<EOF > "$final_path/.bashrc"
|
cat <<EOF > "$final_path/.bashrc"
|
||||||
eval "$(hub alias -s /bin/bash)"
|
eval "$(hub alias -s /bin/bash)"
|
||||||
|
@ -136,15 +125,8 @@ EOF
|
||||||
ynh_script_progression --message="Configure uwsgi..."
|
ynh_script_progression --message="Configure uwsgi..."
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
ynh_backup_if_checksum_is_different --file="$finaluwsgiini"
|
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini"
|
ynh_add_config --template="../conf/uwsgi.ini" --destination="$finaluwsgiini"
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini"
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini"
|
|
||||||
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$finaluwsgiini"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -159,10 +141,8 @@ ynh_add_systemd_config --service="$app" --template="weblate.service"
|
||||||
ynh_script_progression --message="Configure celery..."
|
ynh_script_progression --message="Configure celery..."
|
||||||
|
|
||||||
celeryconf="$final_path/celery-weblate"
|
celeryconf="$final_path/celery-weblate"
|
||||||
cp ../conf/celery-weblate "$celeryconf"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf"
|
ynh_add_config --template="../conf/celery-weblate" --destination="$celeryconf"
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf"
|
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service"
|
ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service"
|
||||||
|
|
||||||
|
@ -205,25 +185,9 @@ upgrade() {
|
||||||
ynh_script_progression --message="Create weblate configuration file..."
|
ynh_script_progression --message="Create weblate configuration file..."
|
||||||
# save old settings file
|
# save old settings file
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
|
path_url="${path_url%/}"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$settings"
|
ynh_add_config --template="../conf/settings.py" --destination="$settings"
|
||||||
cp "$settings_template" "$settings"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings"
|
|
||||||
|
|
||||||
# remove last "/" of $path_url
|
|
||||||
ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings"
|
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
|
|
||||||
|
@ -322,18 +286,6 @@ ynh_script_progression --message="Starting systemd services..." --weight=5
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="start"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
|
||||||
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ "$is_public" -eq 1 ]
|
|
||||||
then
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
||||||
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -345,4 +297,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Reference in a new issue