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

Fix logs and .cache too big

This commit is contained in:
yalh76 2022-02-08 01:41:44 +01:00
parent f3f8a6533e
commit 7b0573e657
5 changed files with 36 additions and 17 deletions

View file

@ -88,7 +88,7 @@ storage:
videos: '__DATADIR__/videos/'
streaming_playlists: '__DATADIR__/streaming-playlists/'
redundancy: '__DATADIR__/redundancy/'
logs: '__DATADIR__/logs/'
logs: '/var/log/__APP__/'
previews: '__DATADIR__/previews/'
thumbnails: '__DATADIR__/thumbnails/'
torrents: '__DATADIR__/torrents/'

View file

@ -55,7 +55,6 @@ ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
#=================================================
# STANDARD MODIFICATIONS
@ -163,11 +162,13 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Creating a data directory..."
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
chmod 750 "$datadir/.."
chmod -R o-rwx "$datadir/.."
chown -R $app:www-data "$datadir/.."
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# BUILD YARN DEPENDENCIES
@ -177,6 +178,7 @@ ynh_script_progression --message="Building Yarn dependencies..."
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean
popd
#=================================================
@ -207,6 +209,8 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Starting a systemd service..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP server listening on localhost"
@ -253,14 +257,14 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="$datadir/logs/peertube.log"
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for Peertube" --log="$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port
yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $rtmp_port
#=================================================
# START SYSTEMD SERVICE

View file

@ -151,6 +151,16 @@ then
ynh_exec_warn_less yunohost firewall disallow TCP $rtmp_port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -60,7 +60,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 --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
@ -99,9 +99,6 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
# Install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
# 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"
if ! yunohost app list | grep -q "prosody"
then
yunohost tools update
@ -143,6 +140,8 @@ systemctl enable $app.service --quiet
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
@ -150,7 +149,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for Peertube" --log="$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port
yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $rtmp_port
#=================================================
# START SYSTEMD SERVICE

View file

@ -143,13 +143,18 @@ fi
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
yunohost tools regen-conf nginx
# Remove old log file
ynh_secure_remove --file="$datadir/logs"
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -236,9 +241,9 @@ ynh_script_progression --message="Creating a data directory..."
mkdir -p $datadir
chmod 750 "$datadir/.."
chmod -R o-rwx "$datadir/.."
chown -R $app:www-data "$datadir/.."
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# UPDATE A CONFIG FILE
@ -261,6 +266,7 @@ ynh_script_progression --message="Building Yarn dependencies..."
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean
popd
#=================================================
@ -331,7 +337,7 @@ ynh_use_logrotate --non-append
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for Peertube" --log="$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port
yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $rtmp_port
#=================================================
# START SYSTEMD SERVICE