mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Apply example_ynh
This commit is contained in:
parent
657cee7db6
commit
8656afe8ae
5 changed files with 40 additions and 31 deletions
|
@ -2,9 +2,9 @@
|
|||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
admin="john"
|
||||
password="randompass"
|
||||
is_public=1
|
||||
admin="john"
|
||||
password="1Strong-Password"
|
||||
github_account="myaccount"
|
||||
github_token="myoauthtoken"
|
||||
; Checks
|
||||
|
|
|
@ -17,9 +17,6 @@ borgbackup_dependencies="libacl1-dev libacl1 libssl-dev liblz4-dev libzstd-dev l
|
|||
|
||||
pkg_dependencies="$weblate_dependencies $borgbackup_dependencies"
|
||||
|
||||
# Weblate's version for PIP and settings file
|
||||
weblate_version="4.13"
|
||||
|
||||
debian_maj_version=$(sed 's/\..*//' /etc/debian_version)
|
||||
|
||||
if [ "$debian_maj_version" -eq 9 ] ; then
|
||||
|
@ -30,6 +27,10 @@ elif [ "$debian_maj_version" -eq 11 ] ; then
|
|||
weblate_pypath="python3.9"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
@ -141,5 +142,5 @@ ynh_redis_remove_db() {
|
|||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -25,8 +25,8 @@ ynh_abort_if_errors
|
|||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
github_account=$YNH_APP_ARG_GITHUB_ACCOUNT
|
||||
github_token=$YNH_APP_ARG_GITHUB_TOKEN
|
||||
|
@ -83,7 +83,6 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
|
|||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
|
||||
|
@ -145,7 +144,7 @@ chown -R $app: "$final_path"
|
|||
# Read the "Note" section in https://docs.weblate.org/en/weblate-4.11/admin/install/venv-debian.html#python-modules
|
||||
sudo --user=$app $final_path/venv/bin/pip install --force-reinstall --no-binary :all: cffi
|
||||
# Still needed with latest version of weblate?
|
||||
sudo --user=$app BORG_OPENSSL_PREFIX=/usr/lib/x86_64-linux-gnu/ $final_path/venv/bin/pip install Weblate=="$weblate_version"
|
||||
sudo --user=$app BORG_OPENSSL_PREFIX=/usr/lib/x86_64-linux-gnu/ $final_path/venv/bin/pip install Weblate=="$(ynh_app_upstream_version)"
|
||||
sudo --user=$app $final_path/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply
|
||||
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
|
||||
# specific to YunoHost package:
|
||||
|
@ -245,6 +244,8 @@ ynh_script_progression --message="Configuring permissions..." --weight=1
|
|||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -43,13 +43,6 @@ test ! -d $final_path \
|
|||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -85,7 +78,14 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=40
|
|||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PostgreSQL DATABASE
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
|
||||
|
||||
|
|
|
@ -23,13 +23,20 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||
github_account=$(ynh_app_setting_get --app=$app --key=github_account)
|
||||
github_token=$(ynh_app_setting_get --app=$app --key=github_token)
|
||||
key=$(ynh_string_random 50)
|
||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||
key=$(ynh_string_random --length=50)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -89,6 +96,13 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
|
|||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -97,13 +111,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
|
@ -210,7 +217,7 @@ upgrade() {
|
|||
|
||||
# Check the configuration
|
||||
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
|
||||
if [ "$new_version" == "$weblate_version" ]; then
|
||||
if [ "$new_version" == "$(ynh_app_upstream_version)" ]; then
|
||||
sudo --user=$app $final_path/venv/bin/weblate check --deploy || true
|
||||
fi
|
||||
)
|
||||
|
@ -238,7 +245,7 @@ then
|
|||
upgrade "4.1.1" "../conf/settings.4.1.1.py"
|
||||
fi
|
||||
|
||||
upgrade $weblate_version "../conf/settings.py"
|
||||
upgrade $(ynh_app_upstream_version) "../conf/settings.py"
|
||||
|
||||
# Set right permissions for curl installation
|
||||
mkdir -p "$final_path/avatar-cache"
|
||||
|
|
Loading…
Reference in a new issue