update to packaging version 2

This commit is contained in:
Emmanuel Averty 2023-05-27 17:52:29 +02:00 committed by grosmanal
parent 161e1b415f
commit 40d74127f9
5 changed files with 50 additions and 84 deletions

View file

@ -5,14 +5,15 @@ name = "Forgejo"
description.en = "Lightweight software forge" description.en = "Lightweight software forge"
description.fr = "Forge logiciel légère" description.fr = "Forge logiciel légère"
version = "1.18.5-0~ynh3" version = "1.19.3-0~ynh1"
maintainers = ["Emmanuel Averty"] maintainers = ["Emmanuel Averty"]
[upstream] [upstream]
license = "MIT" license = "MIT"
website = "https://forgejo.org" website = "https://forgejo.org"
admindoc = "https://docs.gitea.io/" admindoc = "https://forgejo.org/docs/latest/admin/"
userdoc = "https://forgejo.org/docs/latest/user/"
code = "https://codeberg.org/forgejo/forgejo" code = "https://codeberg.org/forgejo/forgejo"
[integration] [integration]
@ -20,10 +21,10 @@ yunohost = ">= 11.1.17"
architectures = ["amd64", "arm64", "armhf"] architectures = ["amd64", "arm64", "armhf"]
multi_instance = true multi_instance = true
ldap = true ldap = true
sso = false sso = true
disk = "50M" disk = "150M"
ram.build = "50M" ram.build = "50M"
ram.runtime = "50M" ram.runtime = "2G"
[install] [install]
[install.domain] [install.domain]
@ -43,23 +44,27 @@ ram.runtime = "50M"
default = "visitors" default = "visitors"
[resources] [resources]
[resources.sources.main] [resources.sources.main]
arm64.url = "https://codeberg.org/attachments/64d9189e-edb5-4d8e-9886-6d7b733fb146" amd64.url = "https://codeberg.org/attachments/8dc303a9-8a4e-416c-8d6c-62e0d3e289e8"
arm64.sha256 = "a463f0c160a3769d27a1b1e5cff8fbb75d0d04fd6fda481bcd9e083c8fd8d175" amd64.sha256 = "84ad6db129c491c9e4b935cdb6ad7003a804d27fb70e9bc3c653d931cf62d92d"
amd64.url = "https://codeberg.org/attachments/415526b5-e483-45b6-9d46-a7078dcea461" arm64.url = "https://codeberg.org/attachments/dc0a8d51-e2f9-4395-a286-e5f6cbbc20bc"
amd64.sha256 = "3157da621960c32b6284aa55e9d3c3c0d3e7ff534e832e712a2eb7d92952aab8" arm64.sha256 = "e1514b0075223aef8d7992cef0b30cb9869171d4fbec4651693305ad724a530d"
armhf.url = "https://codeberg.org/attachments/14e7bdbb-a2e7-4065-885f-c5fd26d00940" armhf.url = "https://codeberg.org/attachments/b1643658-7394-45c8-9fad-9d286ec29c7d"
armhf.sha256 = "1eb64795db5fd2fc94a1d8ea640f20cdf43d2667512c6f96a665605666d17d38" armhf.sha256 = "b8265436d3af7a46ffbf306917aacbe5ee00fd74dc1eee79f1d4b4cba97ec395"
rename = "forgejo" format = "xz"
extract = false # will be extracted during install script
rename = "forgejo.xz"
[resources.system_user] [resources.system_user]
allow_ssh = true
[resources.ports] [resources.ports]
main.default = 6000
[resources.install_dir] [resources.install_dir]
[resources.data_dir] [resources.data_dir]
subdirs = ".ssh" subdirs = ['.ssh']
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"

View file

@ -29,11 +29,8 @@ ynh_change_url_nginx_config
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
#REMOVEME?
domain=$new_domain
path=$new_path
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
ynh_exec_warn_less ynh_add_config --template="../conf/app.ini" --destination="$install_dir/custom/conf/app.ini" ynh_exec_warn_less ynh_add_config --template="../conf/app.ini" --destination="$install_dir/custom/conf/app.ini"
chmod 640 "$install_dir/custom/conf/app.ini" chmod 640 "$install_dir/custom/conf/app.ini"

View file

@ -10,22 +10,19 @@ source ./_common.sh
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Create a system user
ynh_system_user_create --username=$app --home_dir=$data_dir --groups ssh.app --use_shell
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # Create install and data subdirs
#================================================= #=================================================
ynh_script_progression --message="Installing sources files..." --weight=10 ynh_setup_source --dest_dir="$install_dir"
xz -d "$install_dir/forgejo.xz"
ynh_setup_source --dest_dir=$install_dir chmod +x "$install_dir/forgejo"
mkdir -p "$install_dir/custom/conf" mkdir -p "$install_dir/custom/conf"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir/custom"
chown -R $app:$app "$install_dir" chown -R $app:$app "$install_dir/custom"
chmod +x "$install_dir/forgejo"
chmod 700 $data_dir/.ssh
#================================================= #=================================================
# KEYS GENERATION # KEYS GENERATION
@ -38,13 +35,6 @@ ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
ynh_app_setting_set --app=$app --key=lfs_jwt_secret --value=$lfs_jwt_secret ynh_app_setting_set --app=$app --key=lfs_jwt_secret --value=$lfs_jwt_secret
ynh_app_setting_set --app=$app --key=internal_token --value=$internal_token ynh_app_setting_set --app=$app --key=internal_token --value=$internal_token
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
ynh_add_nginx_config
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
@ -59,10 +49,17 @@ chown $app:$app "$install_dir/custom/conf/app.ini"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_add_nginx_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -70,24 +67,25 @@ ynh_add_systemd_config
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_script_progression --message="Configuring log rotation..." --weight=1
# Configure logrotate # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile "/var/log/$app/forgejo.log" ynh_use_logrotate --logfile "/var/log/$app" --nonappend
chown $app:$app /var/log/$app chown -R $app:$app "/var/log/$app"
chmod u=rwX,g=rX,o= "/var/log/$app" chmod u=rwX,g=rX,o= "/var/log/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log" yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_script_progression --message="Starting a systemd service..." --weight=3
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:"
#================================================= #=================================================

View file

@ -23,57 +23,23 @@ then
fi fi
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_script_progression --message="Removing systemd configuration..." --weight=1
ynh_remove_systemd_config ynh_remove_systemd_config
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE THE DATABASE
#=================================================
ynh_script_progression --message="Removing the database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=3
# Remove the app directory securely
ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the app data directory with the command `yunohost app remove forgejo --purge`
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=2
ynh_secure_remove --file="$data_dir"
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_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_remove_nginx_config ynh_remove_nginx_config
# Remove the dedicated Fail2Ban config # Remove the dedicated Fail2Ban config
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
# Remove logs
ynh_script_progression --message="Removing logs..." --weight=2
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================

View file

@ -21,7 +21,6 @@ upgrade_type=$(ynh_check_app_version_changed)
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=2 ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#================================================= #=================================================
@ -54,6 +53,7 @@ fi
ynh_script_progression --message="Setting up source files..." --weight=3 ynh_script_progression --message="Setting up source files..." --weight=3
ynh_setup_source --dest_dir=$install_dir ynh_setup_source --dest_dir=$install_dir
xz -f -d "$install_dir/forgejo.xz"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir" chown -R $app:$app "$install_dir"
@ -107,7 +107,7 @@ yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.l
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=3
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:"