From b0721359ba7e444ec46ee6424e68b328d9172616 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:12:51 +0100 Subject: [PATCH] try install/remove --- manifest.toml | 18 ++++++++- scripts/_common.sh | 72 ------------------------------------ scripts/install | 92 ++-------------------------------------------- scripts/remove | 46 ----------------------- 4 files changed, 20 insertions(+), 208 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9b46c0a..41ad2cb 100644 --- a/manifest.toml +++ b/manifest.toml @@ -72,6 +72,14 @@ ram.runtime = "3G" optional = true [resources] + + [resources.sources] + [resources.sources.libxxhash] + url = "https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.1.tar.gz" + sha256 = "3bb6b7d6f30c591dd65aaaff1c8b7a5b94d81687998ca9400082c739a690436c" + in_subdir = true + autoupdate.strategy = "latest_github_tag" + [resources.system_user] [resources.install_dir] @@ -80,7 +88,15 @@ ram.runtime = "3G" main.url = "/" [resources.apt] - packages = "libxml2-dev, libxslt-dev, libfreetype6-dev, libjpeg-dev, libz-dev, libyaml-dev, libacl1-dev, libacl1, libssl-dev, liblz4-dev, libzstd-dev, libxxhash-dev" + #first ยง = weblate dependecies, second ยง = borgbackup dependencies + packages = "libxml2-dev, libxslt-dev, libfreetype6-dev, libjpeg-dev, libz-dev, libyaml-dev \ + libffi-dev, libcairo-dev, gir1.2-pango-1.0, libgirepository1.0-dev \ + libacl1-dev, libssl-dev, libpq-dev, libjpeg62-turbo-dev, build-essential \ + python3-gdbm, python3-dev, python3-pip, python3-virtualenv, virtualenv, git \ + uwsgi, uwsgi-plugin-python3, redis-server, postgresql, postgresql-contrib, hub + + libacl1-dev, libacl1, libssl-dev, liblz4-dev, libzstd-dev, libxxhash-dev \ + build-essential, pkg-config, python3-pkgconfig" [resources.database] type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 47f84c9..9b485c5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,17 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#REMOVEME? weblate_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \ - libffi-dev libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev \ - libacl1-dev libssl-dev libpq-dev libjpeg62-turbo-dev build-essential \ - python3-gdbm python3-dev python3-pip python3-virtualenv virtualenv git \ - uwsgi uwsgi-plugin-python3 redis-server postgresql postgresql-contrib hub" - -# because weblate install borgbackup -#REMOVEME? borgbackup_dependencies="libacl1-dev libacl1 libssl-dev liblz4-dev libzstd-dev libxxhash-dev \ - build-essential pkg-config python3-pkgconfig" - #REMOVEME? pkg_dependencies="$weblate_dependencies $borgbackup_dependencies" debian_maj_version=$(sed 's/\..*//' /etc/debian_version) @@ -49,67 +38,6 @@ set_forge_variables() { # EXPERIMENTAL HELPERS #================================================= -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="โ˜๏ธ๐Ÿ†ˆ๐Ÿ…ฝ๐Ÿ…ทโ˜๏ธ: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$app_message - ---- -Automatic diagnosis data from YunoHost - -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} - #================================================= # # Redis HELPERS diff --git a/scripts/install b/scripts/install index 2e9d9ce..b2f7939 100755 --- a/scripts/install +++ b/scripts/install @@ -9,53 +9,18 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? admin=$YNH_APP_ARG_ADMIN -#REMOVEME? password=$YNH_APP_ARG_PASSWORD -#REMOVEME? used_forge=$YNH_APP_ARG_USED_FORGE -#REMOVEME? forge_username=$YNH_APP_ARG_FORGE_USERNAME -#REMOVEME? forge_token=$YNH_APP_ARG_FORGE_TOKEN - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) key=$(ynh_string_random --length=50) -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token @@ -63,40 +28,19 @@ ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token #================================================= # STANDARD MODIFICATIONS #================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=40 - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 +REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? 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 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -mkdir -p "$install_dir" mkdir -p "$install_dir/avatar-cache" mkdir -p "$install_dir/data" @@ -165,6 +109,7 @@ chown -R $app: "$install_dir" sudo --user=$app BORG_OPENSSL_PREFIX=/usr/lib/x86_64-linux-gnu/ $install_dir/venv/bin/pip install Weblate=="$(ynh_app_upstream_version)" sudo --user=$app $install_dir/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: sudo --user=$app $install_dir/venv/bin/pip install django_sendmail_backend ) @@ -256,37 +201,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=5 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/weblate.log" --line_match="spawned uWSGI" ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --line_match="mingle: all alone" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -#REMOVEME? if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name="nginx" --action="reload" - -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -message=" -Weblate settings file : $settings -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/weblate_ynh -" - -ynh_send_readme_to_admin "$message" "$admin" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index b899e7f..f6d4bd6 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - #================================================= # STANDARD REMOVE #================================================= @@ -58,22 +46,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=2 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -82,14 +54,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=10 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_exec_warn_less ynh_remove_app_dependencies - #================================================= # REMOVE XXHASH #================================================= @@ -116,16 +80,6 @@ ynh_secure_remove --file="/var/run/$app-celery" ynh_redis_remove_db -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #=================================================