1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sogo_ynh.git synced 2024-09-03 20:26:07 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-07-15 17:15:49 +02:00
parent 5f3792a3a9
commit 90eaa2a593
10 changed files with 195 additions and 156 deletions

View file

@ -1,29 +1,23 @@
# 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"
path="/SOGo"
admin="john"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=0
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1
upgrade=1 from_commit=2fc174c57586df38506a07195decb08eed02f55f
backup_restore=1
multi_instance=0
change_url=0
; Manifest
domain="domain.tld"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=0
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1
upgrade=1 from_commit=2fc174c57586df38506a07195decb08eed02f55f
backup_restore=1
multi_instance=0
change_url=0
;;; Upgrade options
; commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1
name=Before group permission support
; commit=2fc174c57586df38506a07195decb08eed02f55f
name=Before refactoring
; commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1
name=Before group permission support
; commit=2fc174c57586df38506a07195decb08eed02f55f
name=Before refactoring

View file

@ -1,27 +1,29 @@
# SOGo Proxying
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location ^~ __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_redirect http://127.0.0.1:__PORT__/SOGo/ /SOGo;
# forward user's IP address
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
proxy_set_header x-webobjects-remote-host 127.0.0.1;
proxy_set_header x-webobjects-server-name $server_name;
proxy_set_header x-webobjects-server-url $scheme://$host;
include conf.d/yunohost_panel.conf.inc;
proxy_pass http://127.0.0.1:__PORT__;
proxy_redirect http://127.0.0.1:__PORT__/SOGo/ /SOGo;
# forward user's IP address
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
proxy_set_header x-webobjects-remote-host 127.0.0.1;
proxy_set_header x-webobjects-server-name $server_name;
proxy_set_header x-webobjects-server-url $scheme://$host;
client_max_body_size 100M;
client_max_body_size 100M;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
location __PATH__.woa/WebServerResources/ {
alias /usr/lib/GNUstep/SOGo/WebServerResources/;
alias /usr/lib/GNUstep/SOGo/WebServerResources/;
}
location __PATH__/WebServerResources/ {
alias /usr/lib/GNUstep/SOGo/WebServerResources/;
alias /usr/lib/GNUstep/SOGo/WebServerResources/;
}
location ^__PATH__/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ {
alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
}

View file

@ -4,13 +4,13 @@ After=network.target
After=mariadb.service
[Service]
Type=forking
User=__APP__
Environment="PREFORK=3"
Environment="LD_LIBRARY_PATH=/lib:/usr/lib:/opt/yunohost/__APP__/Library/Libraries/sogo:/opt/yunohost/__APP__/Local/Library/Libraries/sogo"
EnvironmentFile=-/etc/default/__APP__
Type=forking
ExecStart=/opt/yunohost/__APP__/sbin/sogod -WOWorkersCount ${PREFORK} -WOPidFile /run/__APP__/sogo.pid -WOLogFile /var/log/__APP__/sogo.log
PIDFile=/run/__APP__/sogo.pid
User=__APP__
# Sandboxing options to harden security
# Depending on specificities of your service/app, you may need to tweak these

View file

@ -25,32 +25,32 @@
"email": "mattronix@weho.st",
"url": "http://sogo.nu"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx",
"mysql"
],
"requirements": {
"yunohost": ">= 4.3.0"
},
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "admin",
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
"help": {
"help": {
"en": "If it's not public, everybody which want to access to any page of SOGo need to be authenticated on the SSO. On the public mode anybody can access to the authentication page. The shared calendar will be also accessible by anybody who has this link",
"fr": "Si n'est pas publique, n'importe qui veux accéder à n'importe quelle page de SOGo doit être authentifié dans le SSO. Dans le mode publique n'importe qui peut accéder à la page d'authentification de SOGo. Les agenda partagé seront aussi accessible par n'import qui qui à ce liens."
},
"default": true
},
{
"name": "admin",
"type": "user"
}
]
}

View file

@ -1,14 +1,14 @@
#!/bin/bash
#=================================================
# SET ALL CONSTANTS
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="sogo stunnel4 memcached"
#=================================================
# DEFINE ALL COMMON FONCTIONS
# PERSONAL HELPERS
#=================================================
config_stunnel() {
@ -60,3 +60,11 @@ set_permission() {
chown -R $app:$app /var/log/$app
chmod u=rwX,g=rX,o= -R /var/log/$app
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
@ -43,27 +42,14 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP SOGo CONFIGURATION
# SPECIFIC BACKUP
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/$app"
#=================================================
# BACKUP STUNNEL CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/stunnel/$app.conf"
#=================================================
# BACKUP CRON
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP LOGS
#=================================================
ynh_backup --src_path="/var/log/$app"
#=================================================

View file

@ -12,12 +12,12 @@ source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_script_progression --message="Loading installation settings..."
# RETRIEVE ARGUMENTS
old_domain=$YNH_APP_OLD_DOMAIN
domain=$YNH_APP_NEW_DOMAIN
path_url=$YNH_APP_NEW_PATH
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/SOGo"
app=$YNH_APP_INSTANCE_NAME
@ -26,31 +26,68 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
port=$(ynh_app_setting_get --app=$app --key=web_port)
admin=$(ynh_app_setting_get --app=$app --key=admin)
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Check if the new path stay /SOGo if not exit
# Add settings here as needed by your application
port=$(ynh_app_setting_get --app=$app --key=web_port)
admin=$(ynh_app_setting_get --app=$app --key=admin)
if [[ $path_url != "/SOGo" ]]
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
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.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
ynh_die --message "You can't use an other path than '/SOGo'"
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
ynh_script_progression --message="Updating NGINX configuration..."
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the domain for nginx
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file "$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
domain=$new_domain
path_url=$new_path
#Configure Nginx
config_nginx

View file

@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -25,8 +24,9 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
admin=$YNH_APP_ARG_ADMIN
path_url="/SOGo"
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
@ -35,9 +35,6 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# Set variable
path_url="/SOGo"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -80,6 +77,16 @@ db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
config_nginx
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
@ -105,13 +112,6 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
config_nginx
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@ -129,6 +129,7 @@ chmod u=rwX,g=rX,o= -R /var/log/$app
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
#=================================================
@ -143,6 +144,7 @@ yunohost service add $app --description="Groupware for E-Mail, Contacts and Cale
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd"
ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="systemd"
@ -151,14 +153,15 @@ ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="system
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false --label="Sync client" --protected=true --show_tile=false --additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
#=================================================
# RELOAD NGINX

View file

@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -33,13 +32,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -48,10 +40,12 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
# Restore all config and data
#ynh_script_progression --message="Restoring files..." --weight=10
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
#ynh_restore
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE MYSQL DATABASE
@ -88,12 +82,14 @@ chmod u=rwX,g=rX,o= -R /var/log/$app
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
#=================================================
@ -112,7 +108,9 @@ ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd"
ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="systemd"
#=================================================
# RELOAD NGINX AND PHP-FPM
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1

View file

@ -28,6 +28,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -39,59 +40,67 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# UPGRADE SETTINGS FROM OLD INSTALL
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [[ -z $port ]]; then
# Find a port for SOGo
port=$(ynh_find_port --port=20000)
ynh_app_setting_set --app=$app --key=web_port --value=$port
# Find a port for SOGo
port=$(ynh_find_port --port=20000)
ynh_app_setting_set --app=$app --key=web_port --value=$port
fi
if [[ -z $db_name ]]; then
db_name=$app
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
db_name=$app
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
if [[ -z $db_user ]]; then
db_user=$app
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
db_user=$app
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
ynh_app_setting_delete --app=$app --key=is_public
fi
# Manage migrations
ynh_script_progression --message="Migrating database if needed..."
if ynh_compare_current_package_version --comparison le --version 4.0.0~ynh0; then
ynh_replace_string --match_string __APP__ --replace_string $app --target_file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh
bash migrations/3.2-4.0.sh
ynh_replace_string --match_string __APP__ --replace_string $app --target_file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh
bash migrations/3.2-4.0.sh
fi
if ! ynh_permission_exists --permission="sync_client"; then
# Create the required permissions
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
# Create the required permissions
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
@ -99,6 +108,15 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
config_nginx
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
@ -122,13 +140,6 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
config_nginx
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@ -145,15 +156,15 @@ chmod u=rwX,g=rX,o= -R /var/log/$app
ynh_script_progression --message="Configuring permissions..."
if ! ynh_permission_exists --permission sync_client; then
ynh_permission_create --permission="sync_client" --allowed 'visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
python3 remove_sso_conf_persistent.py $domain \
|| ynh_print_warn --message="Your file /etc/ssowat/""conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
ynh_permission_create --permission="sync_client" --allowed 'visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
python3 remove_sso_conf_persistent.py $domain \
|| ynh_print_warn --message="Your file /etc/ssowat/""conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
else
ynh_permission_update --permission="sync_client" --add='visitors' --label="Sync client" --protected=true --show_tile=false
ynh_permission_url --permission "sync_client" --auth_header=false\
--add_url="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
ynh_permission_update --permission="sync_client" --add='visitors' --label="Sync client" --protected=true --show_tile=false
ynh_permission_url --permission "sync_client" --auth_header=false\
--add_url="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
fi
#=================================================