diff --git a/check_process b/check_process index f34e813..470ce69 100644 --- a/check_process +++ b/check_process @@ -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 ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" password="randompass" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 github_account="myaccount" github_token="myoauthtoken" ; Checks @@ -23,7 +18,6 @@ upgrade=1 from_commit=cef22ac5634565cecd2d8545229efe3fe79d85bc backup_restore=1 multi_instance=1 - port_already_use=0 change_url=1 ;;; Options Email= diff --git a/conf/hub_config b/conf/hub_config index 289ab03..99df3d0 100644 --- a/conf/hub_config +++ b/conf/hub_config @@ -1,4 +1,4 @@ github.com: -- user: __GITHUBUSER__ - oauth_token: __GITHUBTOKEN__ +- user: __GITHUB_ACCOUNT__ + oauth_token: __GITHUB_TOKEN__ protocol: https diff --git a/conf/settings.py b/conf/settings.py index e15e977..1d8ced6 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -42,7 +42,7 @@ from logging.handlers import SysLogHandler DEBUG = False ADMINS = ( - ('__ADMIN__', '__ADMINMAIL__'), + ('__ADMIN__', '__ADMIN_MAIL__'), ) MANAGERS = ADMINS @@ -52,9 +52,9 @@ DATABASES = { # Use "postgresql" or "mysql". "ENGINE": "django.db.backends.postgresql", # Database name. - "NAME": "__NAME__", + "NAME": "__APP__", # Database user. - "USER": "__NAME__", + "USER": "__APP__", # Name of role to alter to set parameters in PostgreSQL, # use in case role name is different than user used for authentication. # "ALTER_ROLE": "weblate", @@ -221,8 +221,8 @@ TEMPLATES = [ # GitHub username and token for sending pull requests. # Please see the documentation for more details. -GITHUB_USERNAME = "__GITHUBUSER__" -GITHUB_TOKEN = "__GITHUBTOKEN__" +GITHUB_USERNAME = "__GITHUB_ACCOUNT__" +GITHUB_TOKEN = "__GITHUB_TOKEN__" # GitLab username and token for sending merge requests. # Please see the documentation for more details. diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index 31a67b9..3a9e12f 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -5,7 +5,7 @@ protocol = uwsgi 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 -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 # Weblate by pip diff --git a/doc/screenshots/BigScreenshot.png b/doc/screenshots/BigScreenshot.png new file mode 100644 index 0000000..b2bf4d9 Binary files /dev/null and b/doc/screenshots/BigScreenshot.png differ diff --git a/scripts/install b/scripts/install index 0c7bdaf..5a561e4 100755 --- a/scripts/install +++ b/scripts/install @@ -100,9 +100,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell ynh_script_progression --message="Configure hub..." mkdir "$final_path/.config/" -cp ../conf/hub_config "$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" +ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" cat < "$final_path/.bashrc" 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) key=$(ynh_string_random --length=50) redis_db=$(ynh_redis_get_free_db) - +path_url="${path_url%/}" 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_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_add_config --template="../conf/settings.py" --destination="$settings" 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..." - 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_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" +ynh_add_config --template="../conf/uwsgi.ini" --destination="$finaluwsgiini" #================================================= # SETUP SYSTEMD @@ -235,10 +211,8 @@ ynh_add_systemd_config --service="$app" --template="weblate.service" ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" -cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf" +ynh_add_config --template="../conf/celery-weblate" --destination="$celeryconf" 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 #================================================= -ynh_script_progression --message="Configuring SSOwat..." - - +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary 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" +#================================================= +# END OF SCRIPT +#================================================= + ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/upgrade b/scripts/upgrade index 9763411..7e59937 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,15 +58,6 @@ fi #================================================= 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/" ]] then 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..." mkdir -p "$final_path/.config/" -cp ../conf/hub_config "$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" +ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" cat < "$final_path/.bashrc" eval "$(hub alias -s /bin/bash)" @@ -136,15 +125,8 @@ EOF ynh_script_progression --message="Configure uwsgi..." 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_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" +ynh_add_config --template="../conf/uwsgi.ini" --destination="$finaluwsgiini" #================================================= # SETUP SYSTEMD @@ -159,10 +141,8 @@ ynh_add_systemd_config --service="$app" --template="weblate.service" ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" -cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf" +ynh_add_config --template="../conf/celery-weblate" --destination="$celeryconf" ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" @@ -205,25 +185,9 @@ upgrade() { ynh_script_progression --message="Create weblate configuration file..." # save old settings file settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" + path_url="${path_url%/}" - ynh_backup_if_checksum_is_different --file="$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_add_config --template="../conf/settings.py" --destination="$settings" 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-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 #================================================= @@ -345,4 +297,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" --last