diff --git a/check_process b/check_process index 6464c1b..b05adb8 100644 --- a/check_process +++ b/check_process @@ -2,8 +2,8 @@ ; Manifest domain="domain.tld" path="/path" - admin="john" is_public=1 + admin="john" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -18,5 +18,5 @@ port_already_use=0 change_url=1 ;;; Options -Email=jean-baptiste@holcroft.fr -Notification=all +Email= +Notification=none diff --git a/conf/pagure.cfg.sample b/conf/pagure.cfg.sample index e7e4597..ca6d250 100644 --- a/conf/pagure.cfg.sample +++ b/conf/pagure.cfg.sample @@ -75,24 +75,12 @@ GIT_URL_SSH = 'ssh://git@__DOMAIN____PATH__' GIT_URL_GIT = 'git://__DOMAIN____PATH__' ### Folder containing to the git repos -GIT_FOLDER = os.path.join( - os.path.abspath(os.path.dirname(__file__)), - '..', - 'repos' -) +GIT_FOLDER = '__DATADIR__/repos' -REPOSPANNER_PSEUDO_FOLDER = os.path.join( - os.path.abspath(os.path.dirname(__file__)), - '..', - 'pseudo' -) +REPOSPANNER_PSEUDO_FOLDER = '__DATADIR__/pseudo' ### Folder containing the clones for the remote pull-requests -REMOTE_GIT_FOLDER = os.path.join( - os.path.abspath(os.path.dirname(__file__)), - '..', - 'remotes' -) +REMOTE_GIT_FOLDER = '__DATADIR__/remotes' ### Whether to enable scanning for viruses in attachments VIRUS_SCAN_ATTACHMENTS = False diff --git a/manifest.json b/manifest.json index a15e843..863ef68 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "A git-centered forge, python based using pygit2." }, - "version": "5.13.3~ynh1", + "version": "5.13.3~ynh2", "url": "https://pagure.io/pagure", "upstream": { "license": "AGPL-3.0", @@ -38,14 +38,14 @@ "example": "/pagure", "default": "/pagure" }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", "default": true + }, + { + "name": "admin", + "type": "user" } ] } diff --git a/scripts/backup b/scripts/backup index b4c2ad9..83b1d0d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -42,6 +43,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/change_url b/scripts/change_url index dbe8dd1..0ecc55e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -39,6 +39,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP diff --git a/scripts/install b/scripts/install index eb93a1c..278535a 100755 --- a/scripts/install +++ b/scripts/install @@ -27,8 +27,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 app=$YNH_APP_INSTANCE_NAME @@ -110,6 +110,21 @@ 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 + +mkdir -p $datadir +mkdir -p "${datadir}"/{repos,remotes,attachments,releases} + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # ADD A CONFIGURATION #================================================= @@ -157,8 +172,9 @@ pushd "$final_path" pip install psycopg2 pip install pyyaml pip install pygit2 + pip install "jinja2<3.1.0" pip install -r requirements.txt - mkdir -p "${final_path}"/lcl/{repos,remotes,attachments,releases} + read -p "ppp" ynh_add_config --template="../conf/alembic.ini" --destination="$final_path/alembic.ini" PAGURE_CONFIG=${final_path}/pagure.cfg python createdb.py --initial alembic.ini 2>&1 popd diff --git a/scripts/remove b/scripts/remove index 0e24eb8..9fa3329 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,6 +22,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= @@ -135,6 +136,17 @@ ynh_script_progression --message="Removing app main directory..." # 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 #================================================= diff --git a/scripts/restore b/scripts/restore index 92f184e..1f67525 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,6 +34,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) 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 +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -71,6 +72,20 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir +mkdir -p "${datadir}"/{repos,remotes,attachments,releases} + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # SPECIFIC RESTORATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6b9d66f..b15a845 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ 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) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) @@ -168,8 +169,8 @@ pushd "$final_path" pip install psycopg2 pip install pyyaml pip install pygit2 + pip install "jinja2<3.1.0" pip install -r requirements.txt - mkdir -p "${final_path}"/lcl/{repos,remotes,attachments,releases} ynh_add_config --template="../conf/alembic.ini" --destination="$final_path/alembic.ini" PAGURE_CONFIG=${final_path}/pagure.cfg alembic upgrade head 2>&1 popd