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

Add logrotate

This commit is contained in:
ericgaspar 2021-01-11 10:35:35 +01:00
parent 2b099e605a
commit 19fd621d8a
No known key found for this signature in database
GPG key ID: 574F281483054D44
5 changed files with 78 additions and 16 deletions

View file

@ -50,6 +50,12 @@ ynh_backup --src_path="/home/yunohost.app/$app"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================

View file

@ -66,13 +66,6 @@ ynh_script_progression --message="Finding an available port..." --weight=3
port=$(ynh_find_port --port=8065)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# SET UP INSTALLATION VARIABLES
#=================================================
data_path="/home/yunohost.app/$app"
logs_path="/var/log/$app"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
@ -102,8 +95,32 @@ 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"
mkdir -p "$data_path"
mkdir -p "$logs_path"
#=================================================
# CREATE DIRECTORY FOR DATA
#=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1
# Create datadir folder
mkdir -p "/home/yunohost.app/$app"
# Define app's data directory
data_path="/home/yunohost.app/$app"
# Give permission to the datadir
chown -R $app: "$data_path"
#=================================================
# HANDLE LOG FILES AND LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Create log directory
mkdir -p /var/log/$app
#touch /var/log/$app/$app.log
logs_path="/var/log/$app"
touch $install_log
chown $app -R $logs_path
# Setup logrotate
ynh_use_logrotate
#=================================================
# EDIT MATTERMOST CONFIG
@ -135,8 +152,6 @@ ynh_store_file_checksum --file="$final_path/config/config.json"
#=================================================
chown -R $app: $final_path
chown -R $app: $data_path
chown -R $app: $logs_path
chmod -R g+w $final_path
#=================================================

View file

@ -68,6 +68,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE LOG FILE
#=================================================

View file

@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -61,6 +64,7 @@ ynh_restore_file --origin_path="$final_path"
#=================================================
ynh_restore_file --origin_path="/home/yunohost.app/$app"
chown -R $app: "/home/yunohost.app/$app"
#=================================================
# RESTORE THE MYSQL DATABASE
@ -85,9 +89,7 @@ ynh_system_user_create --username=$app
# Restore permissions on app files
chown -R $app: $final_path
#mkdir -p $data_path
chown -R $app: $data_path
chmod -R g+w $final_path
logs_path="/var/log/$app"
mkdir -p $logs_path
@ -116,6 +118,12 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Mattermost"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -33,6 +36,7 @@ language=$(ynh_app_setting_get --app=$app --key=language)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
@ -81,7 +85,7 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -142,14 +146,35 @@ ynh_add_systemd_config
# mv "/var/log/${app}.log" "$logs_path/"
# fi
#=================================================
# CREATE DIRECTORY FOR DATA
#=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1
# Define app's data directory
data_path="/home/yunohost.app/$app"
# Create datadir folder
mkdir -p $data_path
# Give permission to the datadir
chown -R $app: "$data_path"
#=================================================
# RESTORE FILE PERMISSIONS
#=================================================
chown -R $app: $final_path
chown -R $app: "/home/yunohost.app/$app"
chmod -R g+w $final_path
chown -R $app: "/var/log/$app"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================