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:
parent
9d688fd9f1
commit
01b375cb9e
8 changed files with 40 additions and 31 deletions
|
@ -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.
|
||||
|
||||
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) :
|
||||
|
||||
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
|
|
@ -26,7 +26,7 @@ location ~ ^/static/(thumbnails|avatars)/ {
|
|||
# Cache 2 hours
|
||||
more_set_headers "Cache-Control : public, max-age=7200";
|
||||
|
||||
root /home/yunohost.app/__NAME__/storage;
|
||||
root __DATADIR__;
|
||||
|
||||
rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
|
||||
try_files $uri /;
|
||||
|
@ -97,7 +97,7 @@ location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
|
|||
access_log off;
|
||||
}
|
||||
|
||||
root /home/yunohost.app/__NAME__/storage;
|
||||
root __DATADIR__;
|
||||
|
||||
rewrite ^/static/webseed/(.*)$ /videos/$1 break;
|
||||
rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;
|
||||
|
|
|
@ -70,18 +70,18 @@ email:
|
|||
|
||||
# From the project root directory
|
||||
storage:
|
||||
tmp: '/home/yunohost.app/__APP__/storage/tmp/' # Use to download data (imports etc), store uploaded files before processing...
|
||||
avatars: '/home/yunohost.app/__APP__/storage/avatars/'
|
||||
videos: '/home/yunohost.app/__APP__/storage/videos/'
|
||||
streaming_playlists: '/home/yunohost.app/__APP__/storage/streaming-playlists/'
|
||||
redundancy: '/home/yunohost.app/__APP__/storage/videos/'
|
||||
logs: '/home/yunohost.app/__APP__/storage/logs/'
|
||||
previews: '/home/yunohost.app/__APP__/storage/previews/'
|
||||
thumbnails: '/home/yunohost.app/__APP__/storage/thumbnails/'
|
||||
torrents: '/home/yunohost.app/__APP__/storage/torrents/'
|
||||
captions: '/home/yunohost.app/__APP__/storage/captions/'
|
||||
cache: '/home/yunohost.app/__APP__/storage/cache/'
|
||||
plugins: '/home/yunohost.app/__APP__/storage/plugins/'
|
||||
tmp: '__DATADIR__/tmp/' # Use to download data (imports etc), store uploaded files before processing...
|
||||
avatars: '__DATADIR__/avatars/'
|
||||
videos: '__DATADIR__/videos/'
|
||||
streaming_playlists: '__DATADIR__/streaming-playlists/'
|
||||
redundancy: '__DATADIR__/videos/'
|
||||
logs: '__DATADIR__/logs/'
|
||||
previews: '__DATADIR__/previews/'
|
||||
thumbnails: '__DATADIR__/thumbnails/'
|
||||
torrents: '__DATADIR__/torrents/'
|
||||
captions: '__DATADIR__/captions/'
|
||||
cache: '__DATADIR__/cache/'
|
||||
plugins: '__DATADIR__/plugins/'
|
||||
|
||||
log:
|
||||
level: 'info' # debug/info/warning/error
|
||||
|
|
|
@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
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
|
||||
|
@ -74,7 +75,7 @@ ynh_psql_dump_db --database="$db_name" > db.sql
|
|||
#=================================================
|
||||
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
|
||||
|
|
|
@ -32,6 +32,9 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
|||
|
||||
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
|
||||
#=================================================
|
||||
|
@ -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_pass --value=$admin_pass
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -116,7 +120,7 @@ ynh_setup_source --dest_dir="$final_path"
|
|||
ynh_script_progression --message="Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_nginx_config "datadir"
|
||||
|
||||
#=================================================
|
||||
# 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..."
|
||||
|
||||
# Define app's data directory
|
||||
datadir="/home/yunohost.app/${app}/storage"
|
||||
|
||||
# Create app folders
|
||||
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="__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="__DATADIR__" --replace_string="$datadir" --target_file="$config"
|
||||
|
||||
#Create the admin settings file
|
||||
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..."
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
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
|
||||
|
|
|
@ -23,6 +23,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
|
|||
db_user=$app
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# 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="__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="__DATADIR__" --replace_string="$datadir" --target_file="../conf/message_remove"
|
||||
|
||||
ynh_send_readme_to_admin --app_message="../conf/message_remove" --recipients=$admin_email --type='remove'
|
||||
|
||||
|
|
|
@ -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_user=$app
|
||||
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
|
||||
|
@ -84,12 +85,10 @@ chown -R $app:$app $final_path
|
|||
#=================================================
|
||||
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.
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p "$datadir/storage"
|
||||
mkdir -p "$datadir"
|
||||
|
||||
# Give permission to the datadir
|
||||
chown -R "$app":"$app" "$datadir"
|
||||
|
@ -137,7 +136,7 @@ systemctl enable $app.service
|
|||
#=================================================
|
||||
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
|
||||
|
|
|
@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -46,6 +47,12 @@ elif [ "$is_public" = "No" ]; then
|
|||
is_public=0
|
||||
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
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
|
@ -129,7 +136,7 @@ fi
|
|||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_nginx_config "datadir"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
|
@ -171,9 +178,6 @@ ynh_system_user_create --username=$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Creating the data directory..."
|
||||
|
||||
# Define app's data directory
|
||||
datadir="/home/yunohost.app/${app}/storage"
|
||||
|
||||
if [ ! -d "$datadir" ]
|
||||
then
|
||||
# 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="__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="__DATADIR__" --replace_string="$datadir" --target_file="$config"
|
||||
ynh_store_file_checksum --file="$config"
|
||||
|
||||
local_config="$final_path/config/local-production.json"
|
||||
|
|
Loading…
Reference in a new issue