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

Add logrotate

This commit is contained in:
ericgaspar 2021-10-03 13:54:44 +02:00
parent 1f484e2149
commit 77a7af95e9
No known key found for this signature in database
GPG key ID: 574F281483054D44
8 changed files with 82 additions and 60 deletions

View file

@ -11,10 +11,8 @@
setup_private=1
setup_public=1
upgrade=1
# 4.3.3
upgrade=1 from_commit=198004df76b0b3ef22a6dfe1b9a2738af62f0786
# 4.9.4
upgrade=1 from_commit=7a150ab29ee969f72dd7846539ae12ac1975165b
upgrade=1 from_commit=7a150ab29ee969f72dd7846539ae12ac1975165b
backup_restore=1
multi_instance=1
change_url=0
@ -22,7 +20,5 @@
Email=
Notification=none
;;; Upgrade options
; commit=198004df76b0b3ef22a6dfe1b9a2738af62f0786
name=4.3.3
; commit=7a150ab29ee969f72dd7846539ae12ac1975165b
name=4.9.4

View file

@ -3,4 +3,3 @@ SOURCE_SUM=DE7041DA31362BB8DF1043864A94026D6B692EBCEF8FEBD886F635BEF8E3DA84
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=

View file

@ -3,8 +3,8 @@
"id": "ghost",
"packaging_format": 1,
"description": {
"en": "Just a blogging platform",
"fr": "Plateforme de blogging"
"en": "Publishing, memberships, subscriptions and newsletters platform",
"fr": "Plateforme d'édition, d'adhésions, d'abonnements et de newsletters"
},
"version": "4.16.0~ynh1",
"url": "https://ghost.org/",

View file

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

View file

@ -72,6 +72,14 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
# Install Yarn
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
@ -81,15 +89,6 @@ db_name=$(ynh_sanitize_dbid --db_name=$app)
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
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -104,6 +103,10 @@ ynh_setup_source --dest_dir="$final_path"
mkdir -p $final_path/core/client/Admin
ynh_setup_source --dest_dir="$final_path/core/client/Admin" --source_id="admin"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -120,14 +123,15 @@ ynh_add_nginx_config
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json"
chmod 400 "$final_path/config.production.json"
chown $app:$app "$final_path/config.production.json"
#==============================================
# BUILD GHOST
#==============================================
ynh_script_progression --message="Building $app... (this will take some time and resources!)"
pushd "$final_path" || ynh_die
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less yarn install --non-interactive --silent
ynh_exec_warn_less yarn global add knex-migrator
@ -135,8 +139,7 @@ pushd "$final_path" || ynh_die
ynh_exec_warn_less yarn global add grunt-cli ember-cli
ynh_exec_warn_less NODE_ENV=production grunt symlink
ynh_exec_warn_less NODE_ENV=production grunt init --force
popd || ynh_die
popd
#=================================================
# SETUP SYSTEMD
@ -147,14 +150,12 @@ ynh_script_progression --message="Configuring a systemd service..."
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
# SETUP LOGROTATE
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
ynh_script_progression --message="Configuring log rotation..."
# Set permissions to app files
chown -R $app: $final_path
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST

View file

@ -43,6 +43,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
@ -77,6 +85,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing log files..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -57,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
@ -66,13 +66,9 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SPECIFIC RESTORATION
@ -107,6 +103,13 @@ ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================

View file

@ -27,10 +27,24 @@ 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)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_clean_check_starting
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -49,21 +63,6 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_clean_check_starting
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -79,7 +78,7 @@ ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -147,23 +146,25 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json"
chmod 400 "$final_path/config.production.json"
chown $app:$app "$final_path/config.production.json"
#==============================================
# BUILD GHOST
#==============================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building $app... (this will take some time and resources!)"
pushd "$final_path" || ynh_die
pushd "$final_path"
ynh_exec_warn_less yarn install
ynh_exec_warn_less yarn global add knex-migrator
ynh_exec_warn_less NODE_ENV=production knex-migrator init
ynh_exec_warn_less yarn global add grunt
ynh_exec_warn_less NODE_ENV=production grunt symlink
ynh_exec_warn_less NODE_ENV=production grunt init --force
popd || ynh_die
popd
fi
#=================================================
@ -177,12 +178,12 @@ ynh_script_progression --message="Upgrading systemd configuration..."
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Securing files and directories..."
ynh_script_progression --message="Upgrading logrotate configuration..."
# Set permissions on app files
chown -R $app: $final_path
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST