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

Merge pull request #69 from YunoHost-Apps/example_ynh

Apply example_ynh
This commit is contained in:
yalh76 2020-01-01 16:23:20 +01:00 committed by GitHub
commit 915b59366d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 34 deletions

View file

@ -49,7 +49,6 @@ LDAP is supported but HTTP auth is still not supported
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/wekan%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/wekan/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/wekan%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/wekan/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/wekan%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/wekan/)
## Links

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -36,9 +37,9 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping $app service..."
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
# BACKUP THE APP MAIN DIR
@ -73,10 +74,12 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Wekan, task board"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
#=================================================
# END OF SCRIPT

View file

@ -30,9 +30,29 @@ ynh_print_info --message="Loading installation settings..."
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info --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 () {
# 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
#=================================================
@ -54,9 +74,9 @@ fi
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping $app service..."
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
# MODIFY URL IN NGINX CONF
@ -101,10 +121,12 @@ ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Wekan, task board"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
#=================================================
# RELOAD NGINX

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -23,6 +24,7 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
@ -64,7 +66,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
ynh_print_info --message="Configuring firewall..."
# Find a free port
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
@ -79,9 +81,9 @@ ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# START MONGODB
# CREATE A MONGODB DATABASE
#=================================================
ynh_print_info --message="Starting mongodb ..."
ynh_print_info --message="Creating a MongoDB database..."
# Start mongodb
systemctl enable mongodb
@ -130,6 +132,7 @@ ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
config_file="$final_path/.env"
cp "../conf/.env" $config_file
@ -143,6 +146,7 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config_file"
@ -152,7 +156,7 @@ ynh_store_file_checksum --file="$config_file"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info --message="Configuring file permissions ..."
ynh_print_info --message="Securing files and directories..."
# Set strong right permissions to app files
chown -R $app: "$final_path"
@ -160,20 +164,24 @@ chmod -R 640 "$final_path"
find "$final_path" -type d -print0 | xargs -0 chmod 750
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --description "Wekan daemon"
yunohost service add mongodb --description "MongoDB daemon" --log "/var/log/mongodb/mongodb.log"
yunohost service add mongodb --log "/var/log/mongodb/mongodb.log"
yunohost service add $app
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_print_info --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Meteor APM: completed instrumenting the app"
sleep 30
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Meteor APM: completed instrumenting the app"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
#=================================================
# SETUP SSOWAT

View file

@ -19,16 +19,17 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
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)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
ynh_print_info --message="Removing service integration in YunoHost..."
# Remove a service from the admin panel, added by `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
then
ynh_print_info --message="Removing $app service..."
@ -63,7 +64,7 @@ ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info --message="Removing app main directory"
ynh_print_info --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -68,6 +69,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_print_info --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: "$final_path"
@ -106,19 +108,23 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --description "Wekan daemon"
yunohost service add mongodb --log "/var/log/mongodb/mongodb.log"
yunohost service add $app
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Wekan, task board"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
#=================================================
# GENERIC FINALIZATION

View file

@ -46,6 +46,9 @@ fi
# CHECK VERSION NUMBER
#=================================================
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
abort_if_up_to_date
# previous function is what defines 'version', more precisely the 'previous version'
previous_version="${version}"
@ -166,9 +169,9 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping $app service..."
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -238,6 +241,7 @@ ynh_add_systemd_config
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files
chown -R $app: "$final_path"
@ -261,8 +265,10 @@ fi
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Wekan, task board"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
#=================================================
# RELOAD NGINX