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

Globally define datadir

This commit is contained in:
yalh76 2020-09-27 19:00:21 +02:00
parent 9d688fd9f1
commit 01b375cb9e
8 changed files with 40 additions and 31 deletions

View file

@ -3,12 +3,12 @@ __APP__ was successfully removed :)
__APP__ was successfully removed. The domain https://__DOMAIN____PATH_URL__ is free for other apps to be installed on it. __APP__ was successfully removed. The domain https://__DOMAIN____PATH_URL__ is free for other apps to be installed on it.
But a futher action is required from your side to completely remove the __APP__ data folder. If you have backup and plan to restore this app in the future DON'T RUN THIS COMMAND. But a futher action is required from your side to completely remove the __APP__ data folder. If you have backup and plan to restore this app in the future DON'T RUN THIS COMMAND.
And if you are going to migrate to othe server you will have to move /home/yunohost.app/__APP__ to your new server. And if you are going to migrate to othe server you will have to move __DATADIR__ to your new server.
You need to run this command to remove the data (warning all your videos will be removed) : You need to run this command to remove the data (warning all your videos will be removed) :
rm -R /home/yunohost.app/__APP__ -f rm -R __DATADIR__ -f
If you facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/peertube_ynh If you facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/peertube_ynh

View file

@ -26,7 +26,7 @@ location ~ ^/static/(thumbnails|avatars)/ {
# Cache 2 hours # Cache 2 hours
more_set_headers "Cache-Control : public, max-age=7200"; more_set_headers "Cache-Control : public, max-age=7200";
root /home/yunohost.app/__NAME__/storage; root __DATADIR__;
rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break; rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
try_files $uri /; try_files $uri /;
@ -97,7 +97,7 @@ location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
access_log off; access_log off;
} }
root /home/yunohost.app/__NAME__/storage; root __DATADIR__;
rewrite ^/static/webseed/(.*)$ /videos/$1 break; rewrite ^/static/webseed/(.*)$ /videos/$1 break;
rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break; rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;

View file

@ -70,18 +70,18 @@ email:
# From the project root directory # From the project root directory
storage: storage:
tmp: '/home/yunohost.app/__APP__/storage/tmp/' # Use to download data (imports etc), store uploaded files before processing... tmp: '__DATADIR__/tmp/' # Use to download data (imports etc), store uploaded files before processing...
avatars: '/home/yunohost.app/__APP__/storage/avatars/' avatars: '__DATADIR__/avatars/'
videos: '/home/yunohost.app/__APP__/storage/videos/' videos: '__DATADIR__/videos/'
streaming_playlists: '/home/yunohost.app/__APP__/storage/streaming-playlists/' streaming_playlists: '__DATADIR__/streaming-playlists/'
redundancy: '/home/yunohost.app/__APP__/storage/videos/' redundancy: '__DATADIR__/videos/'
logs: '/home/yunohost.app/__APP__/storage/logs/' logs: '__DATADIR__/logs/'
previews: '/home/yunohost.app/__APP__/storage/previews/' previews: '__DATADIR__/previews/'
thumbnails: '/home/yunohost.app/__APP__/storage/thumbnails/' thumbnails: '__DATADIR__/thumbnails/'
torrents: '/home/yunohost.app/__APP__/storage/torrents/' torrents: '__DATADIR__/torrents/'
captions: '/home/yunohost.app/__APP__/storage/captions/' captions: '__DATADIR__/captions/'
cache: '/home/yunohost.app/__APP__/storage/cache/' cache: '__DATADIR__/cache/'
plugins: '/home/yunohost.app/__APP__/storage/plugins/' plugins: '__DATADIR__/plugins/'
log: log:
level: 'info' # debug/info/warning/error level: 'info' # debug/info/warning/error

View file

@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db) db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -74,7 +75,7 @@ ynh_psql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
ynh_print_info --message="Backing up data directory..." ynh_print_info --message="Backing up data directory..."
ynh_backup --src_path="/home/yunohost.app/${app}" --is_big ynh_backup --src_path="$datadir" --is_big
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -32,6 +32,9 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Define app's data directory
datadir="/home/yunohost.app/${app}/storage"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
@ -52,6 +55,7 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
ynh_app_setting_set --app=$app --key=admin_pass --value=$admin_pass ynh_app_setting_set --app=$app --key=admin_pass --value=$admin_pass
ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -116,7 +120,7 @@ ynh_setup_source --dest_dir="$final_path"
ynh_script_progression --message="Configuring nginx web server..." ynh_script_progression --message="Configuring nginx web server..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config "datadir"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -133,9 +137,6 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
ynh_script_progression --message="Creating the data directory..." ynh_script_progression --message="Creating the data directory..."
# Define app's data directory
datadir="/home/yunohost.app/${app}/storage"
# Create app folders # Create app folders
mkdir -p "$datadir" mkdir -p "$datadir"
@ -155,6 +156,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config" ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$config"
#Create the admin settings file #Create the admin settings file
local_config="$final_path/config/local-production.json" local_config="$final_path/config/local-production.json"
@ -205,14 +207,14 @@ chown -R $app:$app $final_path
ynh_script_progression --message="Configuring log rotation..." ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/home/yunohost.app/${app}/storage/logs/peertube.log" ynh_use_logrotate --logfile="$datadir/logs/peertube.log"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log" yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -23,6 +23,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_user=$app db_user=$app
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -115,6 +116,7 @@ ynh_script_progression --message="Sending a readme for the admin..."
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message_remove" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message_remove" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message_remove" ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/message_remove"
ynh_send_readme_to_admin --app_message="../conf/message_remove" --recipients=$admin_email --type='remove' ynh_send_readme_to_admin --app_message="../conf/message_remove" --recipients=$admin_email --type='remove'

View file

@ -34,6 +34,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db) db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_user=$app db_user=$app
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -84,12 +85,10 @@ chown -R $app:$app $final_path
#================================================= #=================================================
ynh_script_progression --message="Restoring data directory..." --weight=2 ynh_script_progression --message="Restoring data directory..." --weight=2
datadir="/home/yunohost.app/$app"
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p "$datadir/storage" mkdir -p "$datadir"
# Give permission to the datadir # Give permission to the datadir
chown -R "$app":"$app" "$datadir" chown -R "$app":"$app" "$datadir"
@ -137,7 +136,7 @@ systemctl enable $app.service
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log" yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db) db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -46,6 +47,12 @@ elif [ "$is_public" = "No" ]; then
is_public=0 is_public=0
fi fi
if [ -z "$datadir" ];
then
datadir="/home/yunohost.app/${app}/storage"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi
# Close a port # Close a port
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
@ -129,7 +136,7 @@ fi
ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_script_progression --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config "datadir"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
@ -171,9 +178,6 @@ ynh_system_user_create --username=$app
#================================================= #=================================================
ynh_script_progression --message="Creating the data directory..." ynh_script_progression --message="Creating the data directory..."
# Define app's data directory
datadir="/home/yunohost.app/${app}/storage"
if [ ! -d "$datadir" ] if [ ! -d "$datadir" ]
then then
# Create app folders # Create app folders
@ -197,6 +201,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config" ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$config"
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
local_config="$final_path/config/local-production.json" local_config="$final_path/config/local-production.json"