1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mygpo_ynh.git synced 2024-09-03 19:55:52 +02:00

Manifestv2

This commit is contained in:
Salamandar 2024-03-04 12:04:56 +01:00
parent 912c9c7556
commit 2c1a9daaa6
16 changed files with 250 additions and 442 deletions

View file

@ -1,30 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 2.11.1~ynh3
upgrade=1 from_commit=a50d46ae3a01d8a5b08ca9f9e62bfc9269fdedfa
# 2.11.20210519~ynh1
upgrade=1 from_commit=59b41b65dc33c3da471175002f37576ff460dc46
# 2.11.20211020~ynh1
upgrade=1 from_commit=8284155ea371f4b8a9f0c333d486c5a2342acfae
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Tweak starting of systemd services (April 1)
manifest_arg=domain=DOMAIN&admin=USER&is_public=1&

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/gpodder/mygpo/archive/80c41dc0c9a58dc0e85f6ef56662cdfd0d6e3b16.tar.gz
SOURCE_SUM=cce51ef812e5a692ea38b82cb559a4982dcf76ad34d6adf73aff2c5299cb5573
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,4 +1,4 @@
root __FINALPATH__/static; root __INSTALL_DIR__/static;
location /media { location /media {
root /home/yunohost.app/__NAME__; root /home/yunohost.app/__NAME__;
@ -7,7 +7,7 @@ location /media {
} }
location /static/ { location /static/ {
alias __FINALPATH__/static/; alias __INSTALL_DIR__/static/;
} }
location /logo { location /logo {
@ -46,11 +46,11 @@ location @proxy_to_app {
} }
location /media/admin { location /media/admin {
alias __FINALPATH__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin;
} }
location /static/admin { location /static/admin {
alias __FINALPATH__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin;
} }
location ~ /(favicon.ico|favicon.png|robots.txt|clientconfig.json) { location ~ /(favicon.ico|favicon.png|robots.txt|clientconfig.json) {

View file

@ -5,9 +5,9 @@ After=network.target postgresql.service redis.service __APP__.scoket
[Service] [Service]
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__ WorkingDirectory=__INSTALL_DIR__
ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django
ExecReload=/bin/kill -s HUP $MAINPID ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure Restart=on-failure
KillMode=mixed KillMode=mixed

View file

@ -5,9 +5,9 @@ After=network.target postgresql.service redis.service __APP__.socket
[Service] [Service]
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__ WorkingDirectory=__INSTALL_DIR__
ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/celery -A __APP__ worker -l info -Ofair ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ worker -l info -Ofair
ExecReload=/bin/kill -s HUP $MAINPID ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure Restart=on-failure
KillMode=mixed KillMode=mixed

View file

@ -7,9 +7,9 @@ Requires=__APP__.socket
Type=notify Type=notify
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/gunicorn -c __FINALPATH__/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock
ExecReload=/bin/kill -s HUP $MAINPID ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure Restart=on-failure
KillMode=mixed KillMode=mixed

View file

@ -1,53 +0,0 @@
{
"name": "mygpo (gPodder.net)",
"id": "mygpo",
"packaging_format": 1,
"description": {
"en": "Manage podcast subscriptions, and sync them between apps and devices",
"fr": "Gérez vos sousciptions balado, et sychronisez-lez entre vos applis et appareils"
},
"version": "2.11.20221222~ynh1",
"url": "https://github.com/gpodder/mygpo",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://gpodder.net",
"demo": "https://gpodder.net",
"admindoc": "https://gpoddernet.readthedocs.io/",
"code": "https://github.com/gpodder/mygpo"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "Jules Bertholet",
"email": "jules.bertholet@gmail.com"
},
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": false,
"services": [
"nginx",
"postgresql",
"redis-server"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "is_public",
"type": "boolean",
"help": {
"en": "If set to public, anybody will be able to create an account and access some statistics about usage of the app. If set to private, some parts of the API will be blocked off",
"fr": "Si public, n'importe-qui pourra créer un compte et accéder a certaines statistiques d'utilization. Si privé, certaines parties de l'API seront inaccessibles"
},
"default": true
},
{
"name": "admin",
"type": "user"
}
]
}
}

91
manifest.toml Normal file
View file

@ -0,0 +1,91 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "mygpo"
name = "mygpo (gPodder.net)"
description.en = "Manage podcast subscriptions, and sync them between apps and devices"
description.fr = "Gérez vos sousciptions balado, et sychronisez-lez entre vos applis et appareils"
version = "2.11.20221222~ynh2"
maintainers = ["Jules Bertholet"]
[upstream]
license = "AGPL-3.0-only"
website = "https://gpodder.net"
demo = "https://gpodder.net"
admindoc = "https://gpoddernet.readthedocs.io/"
code = "https://github.com/gpodder/mygpo"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = false
ldap = true
sso = false
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.init_main_permission]
help.en = "If set to public, anybody will be able to create an account and access some statistics about usage of the app. If set to private, some parts of the API will be blocked off"
help.fr = "Si public, n'importe-qui pourra créer un compte et accéder a certaines statistiques d'utilization. Si privé, certaines parties de l'API seront inaccessibles"
type = "group"
default = "visitors"
[install.admin]
type = "user"
[resources]
[resources.sources.main]
url = "https://github.com/gpodder/mygpo/archive/80c41dc0c9a58dc0e85f6ef56662cdfd0d6e3b16.tar.gz"
sha256 = "cce51ef812e5a692ea38b82cb559a4982dcf76ad34d6adf73aff2c5299cb5573"
autoupdate.strategy = "latest_github_commit"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
api.url = "/api"
api.additional_urls = ["/clientconfig.json", "/subscriptions", "/suggestions"]
api.allowed = "visitors"
api.protected = true
api_noauth.url = "/toplist"
api_noauth.additional_urls = ["/api/2/data", "/api/2/tag", "/api/2/tags", "/search.opml", "/search.json", "/search.jsonp", "/search.txt", "/search.xml", "/toplist.opml"]
api_noauth.allowed = "visitors"
api_lists.url = "/api/2/lists"
api_lists.allowed = "visitors"
[resources.apt]
packages = [
"acl",
"libffi-dev",
"libjpeg-dev",
"libwebp-dev",
"python3",
"python3-dev",
"python3-pip",
"python3-venv",
"libpq-dev",
"redis-server",
"libldap2-dev",
"libsasl2-dev",
"postgresql",
"postgresql-contrib",
]
[resources.database]
type = "postgresql"

View file

@ -4,77 +4,61 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="acl libffi-dev libjpeg-dev libwebp-dev python3 python3-dev python3-pip python3-venv postgresql postgresql-contrib libpq-dev redis-server libldap2-dev libsasl2-dev"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
function set_permissions { function set_permissions {
mkdir -p $datadir mkdir -p $data_dir
env_path=$final_path/envs/prod env_path=$install_dir/envs/prod
mkdir -p $env_path mkdir -p $env_path
chown -R $app:$app $datadir chown -R $app:$app $data_dir
chmod o-rwx $datadir chmod o-rwx $data_dir
setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $datadir setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $data_dir
chown -R root:$app $final_path chown -R root:$app $install_dir
chmod -R g=u,g-w,o-rwx $final_path chmod -R g=u,g-w,o-rwx $install_dir
setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $final_path setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $install_dir
setfacl -n -R -m user:www-data:- -m default:user:www-data:- $final_path/envs setfacl -n -R -m user:www-data:- -m default:user:www-data:- $install_dir/envs
} }
function set_up_virtualenv { function set_up_virtualenv {
env_path=$final_path/envs/prod env_path=$install_dir/envs/prod
mkdir -p $env_path mkdir -p $env_path
pushd $final_path || ynh_die pushd $install_dir || ynh_die
chown -R $app:$app $final_path chown -R $app:$app $install_dir
ynh_exec_warn_less ynh_exec_as $app python3 -m venv $final_path/venv ynh_exec_warn_less ynh_exec_as $app python3 -m venv $install_dir/venv
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U wheel pip --cache-dir $final_path/.cache/pip setuptools ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U wheel pip --cache-dir $install_dir/.cache/pip setuptools
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements.txt ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements.txt
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-setup.txt ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-setup.txt
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-ynh.txt ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-ynh.txt
set_permissions set_permissions
popd || ynh_dies popd || ynh_dies
} }
function initialize_db { function initialize_db {
pushd $final_path || ynh_die pushd $install_dir || ynh_die
chown -R $app:$app $final_path chown -R $app:$app $install_dir
perform_db_migrations perform_db_migrations
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0
set_permissions set_permissions
popd || ynh_die popd || ynh_die
} }
function upgrade_db { function upgrade_db {
pushd $final_path || ynh_die pushd $install_dir || ynh_die
chown -R $app:$app $final_path chown -R $app:$app $install_dir
perform_db_migrations perform_db_migrations
set_permissions set_permissions
popd || ynh_die popd || ynh_die
} }
function perform_db_migrations { function perform_db_migrations {
echo "y" | ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py makemigrations --merge echo "y" | ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py makemigrations --merge
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py migrate ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py migrate
}
function get_app_settings {
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
admin=$(ynh_app_setting_get --app=$app --key=admin)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
admin_email=$(ynh_user_get_info --username=$admin --key="mail")
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)
} }
#================================================= #=================================================

View file

@ -14,18 +14,18 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." #REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
get_app_settings get_app_settings
@ -38,13 +38,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -13,53 +13,53 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN #REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH #REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN #REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
new_path="/" #REMOVEME? new_path="/"
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
get_app_settings get_app_settings
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." #REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting #REMOVEME? ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
change_domain=0 #REMOVEME? change_domain=0
if [ "$old_domain" != "$new_domain" ] #REMOVEME? if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 #REMOVEME? change_domain=1
fi fi
change_path=0 #REMOVEME? change_path=0
if [ "$old_path" != "$new_path" ] #REMOVEME? if [ "$old_path" != "$new_path" ]
then then
change_path=1 #REMOVEME? change_path=1
fi fi
#================================================= #=================================================
@ -79,24 +79,26 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the domain for NGINX # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" #REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf #REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
echo $new_domain > $final_path/envs/prod/DEFAULT_BASE_URL echo $new_domain > $install_dir/envs/prod/DEFAULT_BASE_URL
echo "$app@$new_domain" > $final_path/envs/prod/DEFAULT_FROM_EMAIL echo "$app@$new_domain" > $install_dir/envs/prod/DEFAULT_FROM_EMAIL
echo "$app@$new_domain" > $final_path/envs/prod/SERVER_EMAIL echo "$app@$new_domain" > $install_dir/envs/prod/SERVER_EMAIL
set_permissions set_permissions
@ -115,9 +117,9 @@ ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/lo
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,126 +8,42 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # INITIALIZE AND STORE SETTINGS
#================================================= #=================================================
ynh_clean_setup () { admin_email=$(ynh_user_get_info --username="$admin" --key="mail")
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
admin_email=$(ynh_user_get_info --username=$admin --key="mail")
secret_key=$(ynh_string_random --length=64) secret_key=$(ynh_string_random --length=64)
staff_token=$(ynh_string_random --length=64) staff_token=$(ynh_string_random --length=64)
#================================================= ynh_app_setting_set --app="$app" --key="random_key" --value="$secret_key"
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=random_key --value=$secret_key
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=3
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..."
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="ALTER ROLE $db_user SET statement_timeout = 5000;" --database=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
set_permissions set_permissions
#================================================= #=================================================
# ENVDIR CONFIGURATION # APP INITIAL CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Building configuration..." --weight=1 ynh_script_progression --message="Adding $app's configuration files..." --weight=1
echo "$admin <$admin_email>" > $env_path/ADMINS echo "$admin <$admin_email>" > "$env_path/ADMINS"
echo "None" > $env_path/BROKER_POOL_LIMIT echo "None" > "$env_path/BROKER_POOL_LIMIT"
echo "redis://localhost:6379" > $env_path/BROKER_URL echo "redis://localhost:6379" > "$env_path/BROKER_URL"
echo "postgres://$db_user:$db_pwd@localhost:5432/$db_name" > $env_path/DATABASE_URL echo "postgres://$db_user:$db_pwd@localhost:5432/$db_name" > "$env_path/DATABASE_URL"
echo False > $env_path/DEBUG echo "False" > "$env_path/DEBUG"
echo $domain > $env_path/DEFAULT_BASE_URL echo "$domain" > "$env_path/DEFAULT_BASE_URL"
echo "$app@$domain" > $env_path/DEFAULT_FROM_EMAIL echo "$app@$domain" > "$env_path/DEFAULT_FROM_EMAIL"
echo "django.core.mail.backends.console.EmailBackend" > $env_path/EMAIL_BACKEND echo "django.core.mail.backends.console.EmailBackend" > "$env_path/EMAIL_BACKEND"
echo "$datadir" > $env_path/MEDIA_ROOT echo "$data_dir" > "$env_path/MEDIA_ROOT"
echo $secret_key > $env_path/SECRET_KEY echo "$secret_key" > "$env_path/SECRET_KEY"
echo "$app@$domain" > $env_path/SERVER_EMAIL echo "$app@$domain" > "$env_path/SERVER_EMAIL"
echo $staff_token > $env_path/STAFF_TOKEN echo "$staff_token" > "$env_path/STAFF_TOKEN"
#================================================= #=================================================
# SET UP VIRTUALENV # SET UP VIRTUALENV
@ -143,70 +57,39 @@ set_up_virtualenv
#================================================= #=================================================
ynh_script_progression --message="Initializing database..." ynh_script_progression --message="Initializing database..."
ynh_psql_execute_as_root --sql="ALTER ROLE $db_user SET statement_timeout = 5000;" --database="$db_name"
initialize_db initialize_db
#================================================= #=================================================
# SETUP SYSTEMD # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring systemd services..." --weight=1 ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
ynh_add_systemd_config --service="$app-socket" --template systemd.socket yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service
ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service
# Some workaround bc ynh_add_system_config doesn't know sockets
ynh_add_systemd_config --service="$app-socket" --template systemd.socket
systemctl disable "$app-socket.service" --quiet systemctl disable "$app-socket.service" --quiet
mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket"
systemctl daemon-reload --quiet systemctl daemon-reload --quiet
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting systemd services..." --weight=1 ynh_script_progression --message="Starting $app's systemd services..." --weight=1
# Start systemd services # Start systemd services
ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Everyone can access to the api part
# We don't want to display the tile in the sso so we put --show_tile="false"
# And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true"
ynh_permission_create --permission="api" --url="/api" -A "/clientconfig.json" "/subscriptions" "/suggestions" --allowed="visitors" --show_tile="false" --protected="true"
ynh_permission_create --permission="api-noauth" --url="/toplist" -A "/api/2/data" "/api/2/tag" "/api/2/tags" "/search.opml" "/search.json" "/search.jsonp" "/search.txt" "/search.xml" "/toplist.opml" --show_tile="false"
ynh_permission_create --permission="api-lists" --url="/api/2/lists" --show_tile="false"
# 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"
ynh_permission_update --permission="api-noauth" --add="visitors"
ynh_permission_update --permission="api-lists" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,87 +8,28 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
get_app_settings
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then yunohost service remove "$app"
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
systemctl stop $app.socket --quiet systemctl stop "$app.socket" --quiet
systemctl disable $app.socket --quiet systemctl disable "$app.socket" --quiet
rm /etc/systemd/system/$app.socket rm "/etc/systemd/system/$app.socket"
systemctl daemon-reload --quiet systemctl daemon-reload --quiet
ynh_remove_systemd_config ynh_remove_systemd_config
ynh_remove_systemd_config -s $app-celery ynh_remove_systemd_config -s "$app-celery"
ynh_remove_systemd_config -s $app-beat ynh_remove_systemd_config -s "$app-beat"
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
@ -99,16 +38,6 @@ ynh_script_progression --message="Removing various files..."
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -14,68 +14,68 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
get_app_settings get_app_settings
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 #REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path #REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir mkdir -p $data_dir
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$datadir" chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
@ -87,11 +87,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 #REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================

View file

@ -12,9 +12,9 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
get_app_settings get_app_settings
@ -28,17 +28,17 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -62,9 +62,9 @@ systemctl disable $app-celery --quiet
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
if [ -z "$datadir" ]; then if [ -z "$data_dir" ]; then
datadir=$(ynh_app_setting_get --app=$app --key=data_path) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_path)
ynh_app_setting_set --app=$app --key=datadir --value=$datadir #REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
ynh_app_setting_delete --app=$app --key=data_path ynh_app_setting_delete --app=$app --key=data_path
ynh_app_setting_delete --app=$app --key=db_pwd ynh_app_setting_delete --app=$app --key=db_pwd
ynh_app_setting_delete --app=$app --key=admin_email ynh_app_setting_delete --app=$app --key=admin_email
@ -73,10 +73,10 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path #REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -87,7 +87,7 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
fi fi
set_permissions set_permissions
@ -95,9 +95,9 @@ set_permissions
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -159,9 +159,9 @@ ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/lo
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
test_upgrade_from.a50d46ae3a01d8a5b08ca9f9e62bfc9269fdedfa.name = "2.11.1~ynh3"
test_upgrade_from.59b41b65dc33c3da471175002f37576ff460dc46.name = "2.11.20210519~ynh1"
test_upgrade_from.8284155ea371f4b8a9f0c333d486c5a2342acfae.name = "2.11.20211020~ynh1"