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

Apply last example_ynh

This commit is contained in:
yalh76 2022-06-26 20:30:44 +02:00
parent 1764ad385e
commit 4c6bc2cd5a
9 changed files with 100 additions and 120 deletions

View file

@ -2,8 +2,8 @@
; Manifest
domain="domain.tld"
path="/path"
admin="john"
is_public=1
admin="john"
password="1Strong-Password"
; Checks
pkg_linter=1
@ -17,12 +17,8 @@
upgrade=1 from_commit=9280c034e8843e7e69622f0daa02ee74c916faa1
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=9280c034e8843e7e69622f0daa02ee74c916faa1
name=Testing (#118)
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&password=pass&port=666&

View file

@ -24,4 +24,4 @@ location /.well-known/matrix/ {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}

View file

@ -21,15 +21,15 @@
"name": "eric_G",
"email": ""
},
"requirements": {
"yunohost": ">> 4.3.2"
},
"multi_instance": true,
"services": [
"nginx"
],
"requirements": {
"yunohost": ">> 4.3.2"
},
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"
@ -40,14 +40,6 @@
"example": "/rocketchat",
"default": "/rocketchat"
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password"
},
{
"name": "is_public",
"type": "boolean",
@ -56,6 +48,14 @@
"fr": "Si cette case est cochée, RocketChat sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
},
"default": true
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password"
}
]
}

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
@ -24,6 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -32,7 +32,10 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# STANDARD BACKUP STEPS
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
@ -45,14 +48,14 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================

View file

@ -38,6 +38,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
# 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"
@ -108,7 +109,7 @@ fi
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="SERVER RUNNING"
#=================================================
# RELOAD NGINX

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
true
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -26,12 +26,13 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
password=$YNH_APP_ARG_PASSWORD
admin=$YNH_APP_ARG_ADMIN
email=$(ynh_user_get_info --username=$admin --key=mail)
password=$YNH_APP_ARG_PASSWORD
app=$YNH_APP_INSTANCE_NAME
email=$(ynh_user_get_info --username=$admin --key=mail)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@ -70,11 +71,17 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=20
ynh_install_app_dependencies $pkg_dependencies
# Install Nodejs
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo
ynh_exec_warn_less ynh_install_mongo
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# CREATE A MONGODB DATABASE
@ -86,14 +93,6 @@ db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -101,7 +100,7 @@ ynh_script_progression --message="Setting up source files..." --weight=2
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path
ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
@ -136,9 +135,9 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring a mongod..." --weight=1
ynh_script_progression --message="Configuring mongod..." --weight=1
sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf
sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
@ -167,31 +166,23 @@ ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
#=================================================
# START MONGO SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a MongoDB service..." --weight=2
# Start a mongod service
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
ynh_systemd_action --service_name=$mongodb_servicename --action="restart"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
sleep 60
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="SERVER RUNNING"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# 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"
fi

View file

@ -28,19 +28,13 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# 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
then
ynh_script_progression --message="Removing $app service..." --weight=1
nh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
if ynh_exec_warn_less yunohost service status "$mongodb_servicename" >/dev/null
then
ynh_script_progression --message="Removing $mongodb_servicename service integration..."
yunohost service remove "$mongodb_servicename"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
@ -66,16 +60,6 @@ ynh_script_progression --message="Removing the MongoDB database..."
# Remove a database if it exists, along with the associated user
ynh_mongo_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
ynh_remove_nodejs
ynh_remove_mongo
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -96,6 +80,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_mongo
ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -1,5 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -13,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
@ -41,12 +42,6 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -74,10 +69,16 @@ chown -R $app:$app "$final_path"
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo
ynh_exec_warn_less ynh_install_mongo
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE MONGODB DATABASE
@ -89,9 +90,9 @@ ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mongo_restore_db --database="$db_name" < ./dump.bson
#=================================================
# MODIFY A CONFIG FILE
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring a mongod..." --weight=3
ynh_script_progression --message="Configuring mongod..." --weight=3
sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf
sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
@ -125,22 +126,12 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
#=================================================
# START MONGO SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a MongoDB service..." --weight=2
# Start a mongod service
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
ynh_systemd_action --service_name=$mongodb_servicename --action="restart"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=5
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
sleep 60
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="SERVER RUNNING"
#=================================================
# GENERIC FINALIZATION

View file

@ -29,6 +29,7 @@ email=$(ynh_app_setting_get --app=$app --key=email)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -40,12 +41,22 @@ 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 () {
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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -64,15 +75,6 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -98,6 +100,15 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=7
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_mongo
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -107,14 +118,7 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=7
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo
# SPECIFIC UPGRADE
#==============================================
# INSTALL ROCKETCHAT
#==============================================
@ -134,20 +138,22 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
# CONFIGURE MONGOD
#=================================================
ynh_script_progression --message="Configuring a mongod..." --weight=1
ynh_script_progression --message="Configuring mongod..." --weight=1
sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf
sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
ynh_systemd_action --service_name=$mongodb_servicename --action="restart"
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
sleep 10
mongo --eval "printjson(rs.initiate())"
ynh_mongo_exec --command="printjson(rs.initiate())" --eval
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
@ -168,9 +174,7 @@ yunohost service add $app --description="Team collaboration communication platfo
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=10
ynh_systemd_action --service_name=$mongodb_servicename --action="restart" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
sleep 60
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="SERVER RUNNING"
#=================================================
# RELOAD NGINX