1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/peertube_ynh.git synced 2024-09-03 19:56:29 +02:00
This commit is contained in:
Éric Gaspar 2023-03-21 23:12:02 +01:00
parent 82d42c7782
commit 80a838b735
13 changed files with 283 additions and 224 deletions

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v5.0.1/peertube-v5.0.1.tar.xz
SOURCE_SUM=f43d36fb73b87dc1e6f86fc4d5039aba9f4619c5fff6d64669a900989bed80e2
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.xz
SOURCE_IN_SUBDIR=true
SOURCE_EXTRACT=true

View file

@ -1,13 +1,13 @@
__APP__ was successfully installed :) __APP__ was successfully installed :)
Please open your __APP__ domain: https://__DOMAIN____PATH_URL__ Please open your __APP__ domain: https://__DOMAIN____PATH__
The admin username is: root The admin username is: root
The admin password is: __ADMIN_PASS__ The admin password is: __ADMIN_PASS__
To make PeerTube Live available, you also need to make the TCP port __RTMP_PORT__ available from internet (For example, opening the port on your ISP box if it's not automatically done). To make PeerTube Live available, you also need to make the TCP port __RTMP_PORT__ available from internet (For example, opening the port on your ISP box if it's not automatically done).
To enable LDAP authentication open https://__DOMAIN____PATH_URL__admin/plugins/show/peertube-plugin-auth-ldap To enable LDAP authentication open https://__DOMAIN____PATH__admin/plugins/show/peertube-plugin-auth-ldap
Complete with the following informations : Complete with the following informations :
- URL: ldap://127.0.0.1 - URL: ldap://127.0.0.1
- Insecure TLS : checked - Insecure TLS : checked

View file

@ -1,15 +1,15 @@
__APP__ was successfully removed :) __APP__ was successfully removed :)
The domain https://__DOMAIN____PATH_URL__ is free for other apps to be installed on it. The domain https://__DOMAIN____PATH__ is free for other apps to be installed on it.
You should close the PeerTube Live TCP port __RTMP_PORT__ available from internet (For example, closing the port on your ISP box if it's not automatically done). You should close the PeerTube Live TCP port __RTMP_PORT__ available from internet (For example, closing the port on your ISP box if it's not automatically done).
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 __DATADIR__ to your new server. And if you are going to migrate to othe server you will have to move __DATA_DIR__ 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 __DATADIR__ -f rm -R __DATA_DIR__ -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

@ -88,7 +88,7 @@ location ~ ^/plugins/[^/]+(/[^/]+)?/ws/ {
# For extra performance please refer to https://github.com/denji/nginx-tuning # For extra performance please refer to https://github.com/denji/nginx-tuning
## ##
root __DATADIR__; root __DATA_DIR__;
# Enable compression for JS/CSS/HTML, for improved client load times. # Enable compression for JS/CSS/HTML, for improved client load times.
# It might be nice to compress JSON/XML as returned by the API, but # It might be nice to compress JSON/XML as returned by the API, but
# leaving that out to protect against potential BREACH attack. # leaving that out to protect against potential BREACH attack.
@ -125,14 +125,14 @@ tcp_nodelay on; # don't buffer data sent, good for small data burs
location ~ ^/client/(assets/images/(icons/icon-36x36\.png|icons/icon-48x48\.png|icons/icon-72x72\.png|icons/icon-96x96\.png|icons/icon-144x144\.png|icons/icon-192x192\.png|icons/icon-512x512\.png|logo\.svg|favicon\.png|default-playlist\.jpg|default-avatar-account\.png|default-avatar-account-48x48\.png|default-avatar-video-channel\.png|default-avatar-video-channel-48x48\.png))$ { location ~ ^/client/(assets/images/(icons/icon-36x36\.png|icons/icon-48x48\.png|icons/icon-72x72\.png|icons/icon-96x96\.png|icons/icon-144x144\.png|icons/icon-192x192\.png|icons/icon-512x512\.png|logo\.svg|favicon\.png|default-playlist\.jpg|default-avatar-account\.png|default-avatar-account-48x48\.png|default-avatar-video-channel\.png|default-avatar-video-channel-48x48\.png))$ {
more_set_headers "Cache-Control : public, max-age=31536000, immutable"; # Cache 1 year more_set_headers "Cache-Control : public, max-age=31536000, immutable"; # Cache 1 year
try_files __DATADIR__/client-overrides/$1 __FINALPATH__/client/dist/$1 @api; try_files __DATA_DIR__/client-overrides/$1 __INSTALL_DIR__/client/dist/$1 @api;
} }
# Bypass PeerTube for performance reasons. Optional. # Bypass PeerTube for performance reasons. Optional.
location ~ ^/client/(.*\.(js|css|png|svg|woff2|otf|ttf|woff|eot))$ { location ~ ^/client/(.*\.(js|css|png|svg|woff2|otf|ttf|woff|eot))$ {
more_set_headers "Cache-Control : public, max-age=31536000, immutable"; # Cache 1 year more_set_headers "Cache-Control : public, max-age=31536000, immutable"; # Cache 1 year
alias __FINALPATH__/client/dist/$1; alias __INSTALL_DIR__/client/dist/$1;
} }
# Bypass PeerTube for performance reasons. Optional. # Bypass PeerTube for performance reasons. Optional.
@ -154,7 +154,7 @@ location ~ ^/static/(thumbnails|avatars)/ {
rewrite ^/static/(.*)$ /$1 break; rewrite ^/static/(.*)$ /$1 break;
root __DATADIR__; root __DATA_DIR__;
try_files $uri @api; try_files $uri @api;
} }
@ -216,7 +216,7 @@ location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
rewrite ^/static/webseed/(.*)$ /videos/$1 break; rewrite ^/static/webseed/(.*)$ /videos/$1 break;
rewrite ^/static/(.*)$ /$1 break; rewrite ^/static/(.*)$ /$1 break;
root __DATADIR__; root __DATA_DIR__;
try_files $uri @api; try_files $uri @api;
} }

View file

@ -113,20 +113,20 @@ defaults:
# From the project root directory # From the project root directory
storage: storage:
tmp: '__DATADIR__/tmp/' # Use to download data (imports etc), store uploaded files before processing... tmp: '__DATA_DIR__/tmp/' # Use to download data (imports etc), store uploaded files before processing...
bin: '__DATADIR__/bin/' bin: '__DATA_DIR__/bin/'
avatars: '__DATADIR__/avatars/' avatars: '__DATA_DIR__/avatars/'
videos: '__DATADIR__/videos/' videos: '__DATA_DIR__/videos/'
streaming_playlists: '__DATADIR__/streaming-playlists/' streaming_playlists: '__DATA_DIR__/streaming-playlists/'
redundancy: '__DATADIR__/redundancy/' redundancy: '__DATA_DIR__/redundancy/'
logs: '/var/log/__APP__/' logs: '/var/log/__APP__/'
previews: '__DATADIR__/previews/' previews: '__DATA_DIR__/previews/'
thumbnails: '__DATADIR__/thumbnails/' thumbnails: '__DATA_DIR__/thumbnails/'
torrents: '__DATADIR__/torrents/' torrents: '__DATA_DIR__/torrents/'
captions: '__DATADIR__/captions/' captions: '__DATA_DIR__/captions/'
cache: '__DATADIR__/cache/' cache: '__DATA_DIR__/cache/'
plugins: '__DATADIR__/plugins/' plugins: '__DATA_DIR__/plugins/'
well_known: '__DATADIR__/well-known/' well_known: '__DATA_DIR__/well-known/'
# Overridable client files in client/dist/assets/images: # Overridable client files in client/dist/assets/images:
# - logo.svg # - logo.svg
# - favicon.png # - favicon.png
@ -137,7 +137,7 @@ storage:
# Could contain for example assets/images/favicon.png # Could contain for example assets/images/favicon.png
# If the file exists, peertube will serve it # If the file exists, peertube will serve it
# If not, peertube will fallback to the default file # If not, peertube will fallback to the default file
client_overrides: '__DATADIR__/client-overrides/' client_overrides: '__DATA_DIR__/client-overrides/'
static_files: static_files:
# Require and check user authentication when accessing private files (internal/private video files) # Require and check user authentication when accessing private files (internal/private video files)

View file

@ -5,12 +5,12 @@ After=network.target postgresql.service redis-server.service
[Service] [Service]
Type=simple Type=simple
Environment=NODE_ENV=production Environment=NODE_ENV=production
Environment=NODE_CONFIG_DIR=__FINALPATH__/config Environment=NODE_CONFIG_DIR=__INSTALL_DIR__/config
Environment="__YNH_NODE_LOAD_PATH__" Environment="__YNH_NODE_LOAD_PATH__"
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
ExecStart=__YNH_NODE__ __FINALPATH__/dist/server ExecStart=__YNH_NODE__ __INSTALL_DIR__/dist/server
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog
SyslogIdentifier=__APP__ SyslogIdentifier=__APP__

65
manifest.toml Normal file
View file

@ -0,0 +1,65 @@
packaging_format = 2
id = "peertube"
name = "PeerTube"
description.en = "Federated video streaming platform using P2P directly in the web browser"
description.fr = "Plateforme fédéralisé de diffusion vidéo par P2P directement dans le navigateur"
version = "5.0.1~ynh1"
maintainers = ["yalh76"]
[upstream]
license = "AGPL-3.0-only"
website = "https://joinpeertube.org/fr"
demo = "http://peertube.cpy.re"
admindoc = "https://docs.joinpeertube.org"
code = "https://github.com/Chocobozzz/PeerTube"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 11.0.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = false
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
full_domain = true
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "user"
[resources]
[resources.sources.main]
url = "https://github.com/Chocobozzz/PeerTube/releases/download/v5.0.1/peertube-v5.0.1.tar.xz"
sha256 = "f43d36fb73b87dc1e6f86fc4d5039aba9f4619c5fff6d64669a900989bed80e2"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
[[resources.apt.extras]]
repo = "deb https://dl.yarnpkg.com/debian/ stable main"
key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
packages = "yarn"
[resources.database]
type = "postgresql"

View file

@ -5,8 +5,8 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="ffmpeg postgresql postgresql-contrib openssl g++ mailutils apt-transport-https" #REMOVEME? pkg_dependencies="ffmpeg postgresql postgresql-contrib openssl g++ mailutils apt-transport-https"
app_dependencies="prosody" #REMOVEME? app_dependencies="prosody"
nodejs_version=16 nodejs_version=16

View file

@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." #REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -41,13 +41,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -16,48 +16,48 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url="/" path="/"
is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN #REMOVEME? admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
admin_mail=$(ynh_user_get_info --username=$admin --key="mail") admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
admin_pass=$(ynh_string_random --length=24) admin_pass=$(ynh_string_random --length=24)
secrets_peertube=$(ynh_string_random --length=24) secrets_peertube=$(ynh_string_random --length=24)
# Define app's data directory # Define app's data directory
datadir="/home/yunohost.app/${app}/storage" #REMOVEME? data_dir="/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
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." #REMOVEME? ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app #REMOVEME? install_dir=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." #REMOVEME? ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=admin --value=$admin #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=secrets_peertube --value=$secrets_peertube ynh_app_setting_set --app=$app --key=secrets_peertube --value=$secrets_peertube
#================================================= #=================================================
@ -65,16 +65,16 @@ ynh_app_setting_set --app=$app --key=secrets_peertube --value=$secrets_peertube
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." #REMOVEME? ynh_script_progression --message="Finding an available port..."
# Find an available port # Find an available port
port=$(ynh_find_port --port=8095) #REMOVEME? port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
# PeerTube Live port # PeerTube Live port
rtmp_port=1935 rtmp_port=1935
ynh_port_available --port=$rtmp_port || ynh_die --message="Port $rtmp_port is needs to be available for this app" ynh_port_available --port=$rtmp_port || ynh_die --message="Port $rtmp_port is needs to be available for this app"
ynh_app_setting_set --app=$app --key=rtmp_port --value=$rtmp_port #REMOVEME? ynh_app_setting_set --app=$app --key=rtmp_port --value=$rtmp_port
# Open the port # Open the port
ynh_script_progression --message="Configuring firewall..." ynh_script_progression --message="Configuring firewall..."
@ -83,33 +83,33 @@ ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." #REMOVEME? ynh_script_progression --message="Installing dependencies..."
ynh_exec_warn_less ynh_install_apps --apps="$app_dependencies" ynh_exec_warn_less ynh_install_apps --apps="$app_dependencies"
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #REMOVEME? ynh_exec_warn_less 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 # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." #REMOVEME? ynh_script_progression --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." #REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..."
db_name="peertube_${app}" #REMOVEME? db_name="peertube_${app}"
db_user=$(ynh_sanitize_dbid --db_name=$app) #REMOVEME? db_user=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user #REMOVEME? ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
@ -126,13 +126,13 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -149,20 +149,20 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." ynh_script_progression --message="Creating a data directory..."
ynh_app_setting_set --app=$app --key=datadir --value=$datadir #REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
mkdir -p $datadir mkdir -p $data_dir
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$datadir" chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# BUILD YARN DEPENDENCIES # BUILD YARN DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Building Yarn dependencies..." #REMOVEME? ynh_script_progression --message="Building Yarn dependencies..."
pushd "$final_path" pushd "$install_dir"
ynh_use_nodejs 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 install --production --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean
@ -173,15 +173,15 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml" ynh_add_config --template="../conf/production.yaml" --destination="$install_dir/config/production.yaml"
chmod 400 "$final_path/config/production.yaml" chmod 400 "$install_dir/config/production.yaml"
chown $app:$app "$final_path/config/production.yaml" chown $app:$app "$install_dir/config/production.yaml"
ynh_add_config --template="../conf/local-production.json" --destination="$final_path/config/local-production.json" ynh_add_config --template="../conf/local-production.json" --destination="$install_dir/config/local-production.json"
chmod 600 "$final_path/config/local-production.json" chmod 600 "$install_dir/config/local-production.json"
chown $app:$app "$final_path/config/local-production.json" chown $app:$app "$install_dir/config/local-production.json"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -206,8 +206,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
ynh_script_progression --message="Installing LDAP plugin..." ynh_script_progression --message="Installing LDAP plugin..."
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap
popd popd
#================================================= #=================================================
@ -215,8 +215,8 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Installing PeerTube livechat plugin..." ynh_script_progression --message="Installing PeerTube livechat plugin..."
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-livechat ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-livechat
popd popd
#================================================= #=================================================
@ -224,8 +224,8 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Changing PeerTube admin password..." ynh_script_progression --message="Changing PeerTube admin password..."
pushd "$final_path" pushd "$install_dir"
echo $admin_pass | ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run reset-password -- -u root echo $admin_pass | ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run reset-password -- -u root
popd popd
#================================================= #=================================================
@ -264,24 +264,24 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." #REMOVEME? ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] #REMOVEME? if [ $is_public -eq 1 ]
then then
# Everyone can access the app. # Everyone can access the app.
# The "main" permission is automatically created before the install script. # The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" #REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi fi
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" #REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN

View file

@ -15,20 +15,20 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." #REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port) #REMOVEME? rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user) #REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
admin_mail=$(ynh_user_get_info --username=$admin --key="mail") admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
@ -64,10 +64,10 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." #REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE THE REDIS DATABASE # REMOVE THE REDIS DATABASE
@ -79,10 +79,10 @@ ynh_redis_remove_db "$redis_db"
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." #REMOVEME? ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE DATA DIR # REMOVE DATA DIR
@ -92,7 +92,7 @@ ynh_secure_remove --file="$final_path"
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then then
ynh_script_progression --message="Removing app data directory..." ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir" #REMOVEME? ynh_secure_remove --file="$data_dir"
fi fi
#================================================= #=================================================
@ -106,11 +106,11 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." #REMOVEME? ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_nodejs ynh_remove_nodejs
ynh_remove_app_dependencies #REMOVEME? ynh_remove_app_dependencies
ynh_remove_apps ynh_remove_apps
#================================================= #=================================================
@ -138,10 +138,10 @@ ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." #REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app #REMOVEME? ynh_system_user_delete --username=$app
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN

View file

@ -15,81 +15,81 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." #REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port) #REMOVEME? rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user) #REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." #REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir mkdir -p $data_dir
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$datadir" chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
ynh_exec_warn_less ynh_install_apps --apps="$app_dependencies" ynh_exec_warn_less ynh_install_apps --apps="$app_dependencies"
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
@ -101,11 +101,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." #REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================

View file

@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." #REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port) #REMOVEME? rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user) #REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
admin_mail=$(ynh_user_get_info --username=$admin --key="mail") admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
secrets_peertube=$(ynh_app_setting_get --app=$app --key=secrets_peertube) #REMOVEME? secrets_peertube=$(ynh_app_setting_get --app=$app --key=secrets_peertube)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -42,17 +42,17 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -74,19 +74,19 @@ ynh_app_setting_delete --app=$app --key=admin_mail
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
db_name="peertube_${app}" db_name="peertube_${app}"
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi fi
# If db_user doesn't exist, create it # If db_user doesn't exist, create it
if [ -z "$db_user" ]; then if [ -z "$db_user" ]; then
db_user=$app db_user=$app
ynh_app_setting_set --app=$app --key=db_user --value=$db_user #REMOVEME? ynh_app_setting_set --app=$app --key=db_user --value=$db_user
fi fi
# If db_pwd doesn't exist, create it # If db_pwd doesn't exist, create it
if [ -z "$db_pwd" ]; then if [ -z "$db_pwd" ]; then
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd #REMOVEME? ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
fi fi
# If redis_db doesn't exist, create it # If redis_db doesn't exist, create it
@ -95,10 +95,10 @@ if [ -z "$redis_db" ]; then
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
fi fi
if [ -z "$datadir" ]; if [ -z "$data_dir" ];
then then
datadir="/home/yunohost.app/${app}/storage" data_dir="/home/yunohost.app/${app}/storage"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir #REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
fi fi
# Close a port # Close a port
@ -122,7 +122,7 @@ if [ -z "$rtmp_port" ];
then then
rtmp_port=1935 rtmp_port=1935
ynh_port_available --port=$rtmp_port || ynh_die --message="Port $rtmp_port is needs to be available for this app" ynh_port_available --port=$rtmp_port || ynh_die --message="Port $rtmp_port is needs to be available for this app"
ynh_app_setting_set --app=$app --key=rtmp_port --value=$rtmp_port #REMOVEME? ynh_app_setting_set --app=$app --key=rtmp_port --value=$rtmp_port
# Open the port # Open the port
ynh_script_progression --message="Configuring firewall..." ynh_script_progression --message="Configuring firewall..."
@ -130,15 +130,15 @@ then
fi fi
# Cleaning legacy permissions # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then #REMOVEME? if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all #REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
# Create a permission if needed # Create a permission if needed
if ! ynh_permission_exists --permission="api"; then #REMOVEME? if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" #REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
fi fi
# Remove hook # Remove hook
@ -146,17 +146,17 @@ ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
yunohost tools regen-conf nginx yunohost tools regen-conf nginx
# Remove old log file # Remove old log file
ynh_secure_remove --file="$datadir/logs" #REMOVEME? ynh_secure_remove --file="$data_dir/logs"
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app" chown -R $app:$app "/var/log/$app"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -167,23 +167,23 @@ then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --full_replace=1 --dest_dir="$final_path" \ ynh_setup_source --full_replace=1 --dest_dir="$install_dir" \
--keep="config/production.yaml config/local-production.json config/local.yaml" --keep="config/production.yaml config/local-production.json config/local.yaml"
fi fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." #REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_apps --apps="$app_dependencies" ynh_exec_warn_less ynh_install_apps --apps="$app_dependencies"
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -200,11 +200,11 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." ynh_script_progression --message="Creating a data directory..."
mkdir -p $datadir mkdir -p $data_dir
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$datadir" chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# Generate secrets if they don't exist # Generate secrets if they don't exist
@ -219,9 +219,9 @@ fi
#================================================= #=================================================
# BUILD YARN DEPENDENCIES # BUILD YARN DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Building Yarn dependencies..." #REMOVEME? ynh_script_progression --message="Building Yarn dependencies..."
pushd "$final_path" pushd "$install_dir"
ynh_use_nodejs 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 install --production --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean
@ -232,15 +232,15 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Updating a config file..." ynh_script_progression --message="Updating a config file..."
ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml" ynh_add_config --template="../conf/production.yaml" --destination="$install_dir/config/production.yaml"
chmod 400 "$final_path/config/production.yaml" chmod 400 "$install_dir/config/production.yaml"
chown $app:$app "$final_path/config/production.yaml" chown $app:$app "$install_dir/config/production.yaml"
ynh_backup_if_checksum_is_different --file="$final_path/config/local-production.json" ynh_backup_if_checksum_is_different --file="$install_dir/config/local-production.json"
chmod 600 "$final_path/config/local-production.json" chmod 600 "$install_dir/config/local-production.json"
chown $app:$app "$final_path/config/local-production.json" chown $app:$app "$install_dir/config/local-production.json"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -265,8 +265,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
ynh_script_progression --message="Installing LDAP plugin..." ynh_script_progression --message="Installing LDAP plugin..."
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap
popd popd
#================================================= #=================================================
@ -274,8 +274,8 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Installing PeerTube livechat plugin..." ynh_script_progression --message="Installing PeerTube livechat plugin..."
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-livechat ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-livechat
popd popd
#================================================= #=================================================
@ -284,15 +284,15 @@ popd
if ynh_compare_current_package_version --comparison lt --version 4.0.0~ynh1; then if ynh_compare_current_package_version --comparison lt --version 4.0.0~ynh1; then
ynh_script_progression --message="Running Peertube 4.0.0 migration script..." ynh_script_progression --message="Running Peertube 4.0.0 migration script..."
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_node dist/scripts/migrations/peertube-4.0.js ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node dist/scripts/migrations/peertube-4.0.js
popd popd
fi fi
if ynh_compare_current_package_version --comparison lt --version 4.2.0~ynh1; then if ynh_compare_current_package_version --comparison lt --version 4.2.0~ynh1; then
ynh_script_progression --message="Running Peertube 4.2.0 migration script..." ynh_script_progression --message="Running Peertube 4.2.0 migration script..."
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_node dist/scripts/migrations/peertube-4.2.js ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node dist/scripts/migrations/peertube-4.2.js
popd popd
fi fi
@ -332,9 +332,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT