Compare commits

..

2 commits

Author SHA1 Message Date
anmol26s 7750fb1de1 updated sources 2018-07-18 03:03:31 +05:30
anmol26s 1d63c3fea9 fix x-frame PR:https://github.com/Chocobozzz/PeerTube/pull/812 2018-07-17 14:56:17 +05:30
12 changed files with 242 additions and 223 deletions

View file

@ -4,11 +4,17 @@
[![Install Peertube with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=peertube)<br><br>
=======
Shipped Version: **1.2.1**
Shipped Version: **v1.0.0-beta.9**
## What is Peertube ?
PeerTube is a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser, using <a href="https://github.com/feross/webtorrent">WebTorrent</a>.
<p>
<strong>Peertube is running <a href="https://www.kisskissbankbank.com/en/projects/peertube-a-free-and-federated-video-platform">a crowdfunding campaign</a> to pave the road to version 1.0 of PeerTube! If you liked the app, please donate.</strong>
</p>
## Why Peertube ?
We can't build a FOSS video streaming alternatives to YouTube, Dailymotion, Vimeo... with a centralized software. One organization alone cannot have enough money to pay bandwidth and video storage of its server.
@ -34,28 +40,28 @@ Want to see in action?
### Guidelines
1. Require **dedicated domain** like **peertube.domain.tld**.
1. **No LDAP** support (blocked until Peertube core upstream implements it)
1. URL can not be changed once selected. Choose the domain wisely.
1. Require dedicated domain like **peertube.domain.tld**.
1. No LDAP support (blocked until upstream implements it)
1. URL can not be changed once selected.
1. You need more then **1GB** of ram. If you don't have it, please create a **swap memory**.
$ dd if=/dev/zero of=/swapfile bs=1024 count=1048576
$ mkswap /swapfile
$ swapon /swapfile
$ echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
1. This app is **multi-instance** (you can have more then one Peertube instance running on a YunoHost server)
1. This app is multi-instance (you can have more then one Peertube instance running on a YunoHost server)
### Installing guide
### Install
1. App can be installed by YunoHost **admin web-interface** or by **running following command**:
1. **App can be installed by YunoHost admin interface or by the following command:**
$ sudo yunohost app install https://github.com/YunoHost-Apps/peertube_ynh
1. Admin username is : **root**.
1. **Admin password** will be sent to the email address given at the time of the installation.
1. **TLS** and **starttls** are disabled for the outgoing mails. If you intent to use email address not hosted on your local server,it's advised to have a proper SMTP configured with tls and starttls settings by editing **/var/www/peertube/config/production.yml**.
1. **root** is the admin username.
1. **root Password** will be sent to the email address given at the time of the installation.
1. **TLS** and **starttls** are disabled for the outgoing mails. If you intent to use email address not hosted on your local server,it's advised to have a proper SMTP configured with tls and starttls settings by editing **/var/www/peertube/config/porduction.yml**.
### Update Guide
1. App can be updated by YunoHost **admin web-interface** or with the following command**:
### Updation
1. **App can be updated by YunoHost admin interface or with the following command:**
$ sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/peertube_ynh peertube

View file

@ -1,6 +1,6 @@
SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v1.2.1/peertube-v1.2.1.tar.xz
SOURCE_SUM=77517c06133704e36b755bdae4f68838221e657ca70a1a40d5c8652655978ed5
SOURCE_URL=https://github.com/Chocobozzz/PeerTube/archive/aa1c3d929f524f57930f8bb0ae8b07e8b51f9952.zip
SOURCE_SUM=41418eea43be5ca4930aa9e617184e6b96e96d1940d1830316eaae4bddba60c2
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.xz
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,32 +1,13 @@
# Bypass PeerTube for performance reasons. Could be removed
location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ {
add_header Cache-Control "public, max-age=31536000, immutable";
alias __FINALPATH__/client/dist/$1;
}
# Bypass PeerTube for performance reasons. Could be removed
location ~ ^/static/(thumbnails|avatars)/ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
location ~ ^/static/(thumbnails|avatars)/(.*)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
# Cache 2 hours
add_header Cache-Control "public, max-age=7200";
root /home/yunohost.app/__NAME__/storage;
rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
try_files $uri /;
alias /home/yunohost.app/__NAME__/storage/$1/$2;
}
location / {
@ -37,26 +18,17 @@
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# This is the maximum upload size, which roughly matches the maximum size of a video file
# you can send via the API or the web interface. By default this is 8GB, but administrators
# can increase or decrease the limit. Currently there's no way to communicate this limit
# to users automatically, so you may want to leave a note in your instance 'about' page if
# you change this.
#
# Note that temporary space is needed equal to the total size of all concurrent uploads.
# This data gets stored in /var/lib/nginx by default, so you may want to put this directory
# on a dedicated filesystem.
#
client_max_body_size 8G;
# Hard limit, PeerTube does not support videos > 4GB
client_max_body_size 4G;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
# Bypass PeerTube for performance reasons. Could be removed
location ~ ^/static/(webseed|redundancy)/ {
# Bypass PeerTube webseed route for better performances
location /static/webseed {
# Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
limit_rate 800k;
@ -79,14 +51,7 @@
access_log off;
}
root /home/yunohost.app/__NAME__/storage;
rewrite ^/static/webseed/(.*)$ /videos/$1 break;
rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;
try_files $uri /;
alias /home/yunohost.app/__NAME__/storage/videos;
}
# Websocket tracker
@ -101,18 +66,3 @@
proxy_set_header Host $host;
proxy_pass http://localhost:__PORT__;
}
location /socket.io {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:__PORT__;
# enable WebSockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

View file

@ -2,7 +2,7 @@ listen:
hostname: 'localhost'
port: __PORT__
# Correspond to your reverse proxy server_name/listen configuration
# Correspond to your reverse proxy "listen" configuration
webserver:
https: true
hostname: '__domain__'
@ -22,12 +22,8 @@ database:
suffix: '___db_name__'
username: '__db_name__'
password: '__db_pwd__'
pool:
max: 5
# Redis server for short time storage
# You can also specify a 'socket' path to a unix socket but first need to
# comment out hostname and port
# Your object store
redis:
hostname: 'localhost'
port: 6379
@ -37,65 +33,30 @@ redis:
# SMTP server to send emails
smtp:
hostname: 'localhost'
port: 25 # If you use StartTLS: 587
port: 25
username: null
password: null
tls: false # If you use StartTLS: false
tls: false
disable_starttls: true
ca_file: null # Used for self signed certificates
from_address: 'admin@__domain__'
# From the project root directory
storage:
tmp: '/home/yunohost.app/__app__/storage/tmp/' # Used to download data (imports etc), store uploaded files before processing...
avatars: '/home/yunohost.app/__app__/storage/avatars/'
videos: '/home/yunohost.app/__app__/storage/videos/'
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/'
log:
level: 'info' # debug/info/warning/error
search:
# Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance
# If enabled, the associated group will be able to "escape" from the instance follows
# That means they will be able to follow channels, watch videos, list videos of non followed instances
remote_uri:
users: true
anonymous: false
trending:
videos:
interval_days: 7 # Compute trending videos for the last x days
# Cache remote videos on your server, to help other instances to broadcast the video
# You can define multiple caches using different sizes/strategies
# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following
#redundancy:
# videos:
# check_interval: '6 hour' # How often you want to check new videos to cache
# strategies:
# -
# size: '10GB'
# strategy: 'most-views' # Cache videos that have the most views
# -
# size: '10GB'
# strategy: 'trending' # Cache trending videos
# -
# size: '1GB'
# # Minimum time the video must remain in the cache. Only accept values > 10 hours (to not overload remote instances)
# min_lifetime: '48 hours'
# strategy: 'recently-added' # Cache recently added videos
# min_views: 10 # Having at least x views
###############################################################################
#
# From this point, all the following keys can be overridden by the web interface
# From this point, all the following keys can be overriden by the web interface
# (local-production.json file). If you need to change some values, prefer to
# use the web interface because the configuration will be automatically
# reloaded without any need to restart PeerTube.
@ -107,23 +68,14 @@ trending:
cache:
previews:
size: 500 # Max number of previews you want to cache
captions:
size: 500 # Max number of video captions/subtitles you want to cache
size: 100 # Max number of previews you want to cache
admin:
# Used to generate the root user at first startup
# And to receive emails from the contact form
email: '__email__'
contact_form:
enabled: true
signup:
enabled: false
limit: 10 # When the limit is reached, registrations are disabled. -1 == unlimited
requires_email_verification: false
filters:
cidr: # You can specify CIDR ranges to whitelist (empty = no filtering) or blacklist
whitelist: []
@ -133,15 +85,12 @@ user:
# Default value of maximum video BYTES the user can upload (does not take into account transcoded files).
# -1 == unlimited
video_quota: -1
video_quota_daily: -1
# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag
# In addition, if some resolutions are enabled the mp4 video file will be transcoded to these new resolutions.
# Please, do not disable transcoding since many uploaded videos will not work
transcoding:
enabled: true
# Allow your users to upload .mkv, .mov, .avi, .flv videos
allow_additional_extensions: true
threads: 1
resolutions: # Only created if the original video has a higher resolution, uses more storage!
240p: false
@ -149,14 +98,6 @@ transcoding:
480p: false
720p: false
1080p: false
import:
# Add ability for your users to import remote videos (from YouTube, torrent...)
videos:
http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html
enabled: false
torrent: # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file)
enabled: false
# Instance settings
instance:
@ -174,14 +115,9 @@ instance:
# Robot.txt rules. To disallow robots to crawl your instance and disallow indexation of your site, add '/' to "Disallow:'
robots: |
User-agent: *
Disallow:
# Security.txt rules. To discourage researchers from testing your instance and disable security.txt integration, set this to an empty string.
securitytxt:
"# If you would like to report a security issue\n# you may report it to:\nContact: https://github.com/Chocobozzz/PeerTube/blob/develop/SECURITY.md\nContact: mailto:"
Disallow: ''
services:
# You can provide a reporting endpoint for Content Security Policy violations
csp-logger:
# Cards configuration to format video in Twitter
twitter:
username: '@yunohost' # Indicates the Twitter account for the website or platform on which the content was published

View file

@ -1,6 +1,5 @@
[Unit]
Description=__APP__ daemon
After=network.target postgresql.service redis-server.service
Description=PeerTube daemon
[Service]
Type=simple
@ -8,32 +7,12 @@ Environment=NODE_ENV=production
Environment=NODE_CONFIG_DIR=__FINALPATH__/config
User=__APP__
Group=__APP__
Environment="PATH=__ENV_PATH__"
ExecStart=/bin/sh -c ' npm start'
ExecStart=/bin/sh -c 'PATH=/opt/node_n/bin:$PATH exec npm start'
WorkingDirectory=__FINALPATH__/
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=__APP__
Restart=always
; Some security directives.
; Use private /tmp and /var/tmp folders inside a new file system namespace,
; which are discarded after the process stops.
PrivateTmp=true
; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
ProtectSystem=full
; Sets up a new /dev mount for the process and only adds API pseudo devices
; like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled
; by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=false
; Ensures that the service process and all its children can never gain new
; privileges through execve().
NoNewPrivileges=true
; This makes /home, /root, and /run/user inaccessible and empty for processes invoked
; by this unit. Make sure that you do not depend on data inside these folders.
ProtectHome=false
; Drops the sys admin capability from the daemon.
CapabilityBoundingSet=~CAP_SYS_ADMIN
[Install]
WantedBy=multi-user.target

View file

@ -3,10 +3,9 @@
"id": "peertube",
"packaging_format": 1,
"description": {
"en": "Video streaming platform using P2P directly in the web browser, connected to a federated network",
"fr": "Plateforme de diffusion vidéo par P2P directement dans le navigateur, et connectée à un réseau fédéralisé"
"en": "Video streaming platform using P2P directly in the web browser, connected to a federated network"
},
"version": "1.2.1",
"version": "1.0.0-beta.9",
"url": "https://github.com/Chocobozzz/PeerTube",
"license": "AGPL-3.0-only",
"maintainer": {

View file

@ -48,7 +48,7 @@ ynh_send_readme_to_admin() {
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` has important message for you"
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.

View file

@ -22,7 +22,7 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/peertube"
path_url="/"
admin_email=$YNH_APP_ARG_EMAIL
admin_pass=$(ynh_string_random 24)
is_public=$YNH_APP_ARG_IS_PUBLIC
@ -56,10 +56,10 @@ ynh_webpath_register "$app" "$domain" "$path_url"
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" admin_email "$admin_email"
ynh_app_setting_set "$app" admin_pass "$admin_pass"
ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" admin_pass "$admin_pass"
ynh_app_setting_set "$app" is_public "$is_public"
#=================================================
# STANDARD MODIFICATIONS
@ -69,6 +69,9 @@ ynh_app_setting_set "$app" is_public "$is_public"
# Find a free port
port=$(ynh_find_port 9000)
# Open this port
yunohost firewall allow Both "$port" 2>&1
ynh_app_setting_set "$app" port "$port"
#=================================================
@ -87,18 +90,18 @@ mkdir -p "$datadir"
# install nodejs
ynh_install_nodejs 8
# Add backports for Debian Jessie (required to install ffmpeg)
# add backports for Debian Jessie (required to install ffmpeg)
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list
fi
# Add yarn repo for Debian
# add yarn repo for Debian
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
ynh_package_update
# install dependencies
ynh_install_app_dependencies postgresql postgresql-contrib openssl g++ ffmpeg redis-server redis-tools mailutils yarn apt-transport-https
# install postgresql, ffmpeg, redis
ynh_install_app_dependencies postgresql ffmpeg redis-server redis-tools mailutils yarn
#=================================================
# DATABASE SETUP
@ -113,8 +116,6 @@ ynh_psql_test_if_first_run
ynh_psql_create_user "$app" "$db_pwd"
ynh_psql_execute_as_root \
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
ynh_psql_execute_as_root "\connect $db_name
CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS pg_trgm;"
#=================================================
# CREATE DEDICATED USER
@ -140,7 +141,7 @@ touch "$final_path/config/local-production.json"
(
cd "$final_path"
yarn install --production --pure-lockfile
yarn install --production --pure-lockfile --silent --cache-folder /var/cache/yarn/
)
#=================================================
@ -148,11 +149,11 @@ touch "$final_path/config/local-production.json"
#=================================================
# Create a dedicated nginx config
mkdir -p "/etc/nginx/conf.d/${domain}.d" # ( I don't remember why this is here, I think can be removed)
mkdir -p "/etc/nginx/conf.d/${domain}.d"
ynh_add_nginx_config
# Set right permissions for the app
# Set right permissions for curl install
chown -R "$app":"$app" "$datadir"
# Reload Nginx
@ -211,13 +212,10 @@ chown -R "$app":"$app" "$final_path" "$datadir"
systemctl reload nginx
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config
systemctl enable "$app"
@ -231,7 +229,7 @@ systemctl start "$app"
(
cd "$final_path"
sleep 30
echo $admin_pass | NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production npm run reset-password -- -u root
echo $admin_pass | NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production PATH="/opt/node_n/bin:$PATH" npm run reset-password -- -u root
)
#=================================================
@ -240,11 +238,11 @@ systemctl start "$app"
message=" $app was successfully installed :)
Please open your $app domain: https://$domain$path_url
Please open https://$domain$path_url
The admin username is: root
The admin password is: $admin_pass
Here is the admin password: $admin_pass
If you are 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 an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/peertube_ynh"
ynh_send_readme_to_admin "$message"

166
scripts/nodejs.sh Normal file
View file

@ -0,0 +1,166 @@
#!/bin/bash
# INFOS
# n (Node version management) utilise la variable PATH pour stocker le path de la version de node à utiliser.
# C'est ainsi qu'il change de version
# ynh_install_nodejs installe la version de nodejs demandée en argument, avec n
# ynh_use_nodejs active une version de nodejs dans le script courant
# 3 variables sont mises à disposition, et 2 sont stockées dans la config de l'app
# - nodejs_path: Le chemin absolu de cette version de node
# Utilisé pour des appels directs à node.
# - nodejs_version: Simplement le numéro de version de nodejs pour cette application
# - nodejs_use_version: Un alias pour charger une version de node dans le shell courant.
# Utilisé pour démarrer un service ou un script qui utilise node ou npm
# Dans ce cas, c'est $PATH qui contient le chemin de la version de node. Il doit être propagé sur les autres shell si nécessaire.
n_install_dir="/opt/node_n"
node_version_path="/opt/node_n/n/versions/node"
# N_PREFIX est le dossier de n, il doit être chargé dans les variables d'environnement pour n.
export N_PREFIX="$n_install_dir"
ynh_install_n () {
echo "Installation of N - Node.js version management" >&2
# Build an app.src for n
mkdir -p "../conf"
echo "SOURCE_URL=https://github.com/tj/n/archive/v2.1.7.tar.gz
SOURCE_SUM=2ba3c9d4dd3c7e38885b37e02337906a1ee91febe6d5c9159d89a9050f2eea8f" > "../conf/n.src"
# Download and extract n
ynh_setup_source "$n_install_dir/git" n
# Install n
(cd "$n_install_dir/git"
PREFIX=$N_PREFIX make install 2>&1)
}
ynh_use_nodejs () {
nodejs_version=$(ynh_app_setting_get $app nodejs_version)
load_n_path="[[ :$PATH: == *\":$n_install_dir/bin:\"* ]] || PATH=\"$n_install_dir/bin:$PATH\"; N_PREFIX="$n_install_dir""
nodejs_use_version="$n_install_dir/bin/n -q $nodejs_version"
# "Load" a version of node
eval $load_n_path; $nodejs_use_version
# Get the absolute path of this version of node
nodejs_path="$(n bin $nodejs_version)"
# Make an alias for node use
ynh_node_exec="eval $load_n_path; n use $nodejs_version"
}
ynh_install_nodejs () {
# Use n, https://github.com/tj/n to manage the nodejs versions
nodejs_version="$1"
local n_install_script="https://git.io/n-install"
# Create $n_install_dir
mkdir -p "$n_install_dir"
# Load n path in PATH
CLEAR_PATH="$n_install_dir/bin:$PATH"
# Remove /usr/local/bin in PATH in case of node has already setup.
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
# Move an existing node binary, to avoid to block n.
test -x /usr/bin/node && mv /usr/bin/node /usr/bin/node_n
test -x /usr/bin/npm && mv /usr/bin/npm /usr/bin/npm_n
# If n is not previously setup, install it
if ! test n --version > /dev/null 2>&1
then
ynh_install_n
fi
# Modify the default N_PREFIX in n script
ynh_replace_string "^N_PREFIX=\${N_PREFIX-.*}$" "N_PREFIX=\${N_PREFIX-$N_PREFIX}" "$n_install_dir/bin/n"
# Restore /usr/local/bin in PATH
PATH=$CLEAR_PATH
# And replace the old node binary.
test -x /usr/bin/node_n && mv /usr/bin/node_n /usr/bin/node
test -x /usr/bin/npm_n && mv /usr/bin/npm_n /usr/bin/npm
# Install the requested version of nodejs
n $nodejs_version
# Find the last "real" version for this major version of node.
real_nodejs_version=$(find $node_version_path/$nodejs_version* -maxdepth 0 | sort --version-sort | tail --lines=1)
real_nodejs_version=$(basename $real_nodejs_version)
# Create a symbolic link for this major version. If the file doesn't already exist
if [ ! -e "$node_version_path/$nodejs_version" ]
then
ln --symbolic --force --no-target-directory $node_version_path/$real_nodejs_version $node_version_path/$nodejs_version
fi
# Store the ID of this app and the version of node requested for it
echo "$YNH_APP_ID:$nodejs_version" | tee --append "$n_install_dir/ynh_app_version"
# Store nodejs_version into the config of this app
ynh_app_setting_set $app nodejs_version $nodejs_version
# Build the update script and set the cronjob
ynh_cron_upgrade_node
ynh_use_nodejs
}
ynh_remove_nodejs () {
ynh_use_nodejs
# Remove the line for this app
sed --in-place "/$YNH_APP_ID:$nodejs_version/d" "$n_install_dir/ynh_app_version"
# If none another app uses this version of nodejs, remove it.
if ! grep --quiet "$nodejs_version" "$n_install_dir/ynh_app_version"
then
n rm $nodejs_version
fi
# If none another app uses n, remove n
if [ ! -s "$n_install_dir/ynh_app_version" ]
then
ynh_secure_remove "$n_install_dir"
ynh_secure_remove "/usr/local/n"
sed --in-place "/N_PREFIX/d" /root/.bashrc
fi
}
ynh_cron_upgrade_node () {
# Build the update script
cat > "$n_install_dir/node_update.sh" << EOF
#!/bin/bash
version_path="$node_version_path"
n_install_dir="$n_install_dir"
# Log the date
date
# List all real installed version of node
all_real_version="\$(find \$version_path/* -maxdepth 0 -type d | sed "s@\$version_path/@@g")"
# Keep only the major version number of each line
all_real_version=\$(echo "\$all_real_version" | sed 's/\..*\$//')
# Remove double entries
all_real_version=\$(echo "\$all_real_version" | sort --unique)
# Read each major version
while read version
do
echo "Update of the version \$version"
sudo \$n_install_dir/bin/n \$version
# Find the last "real" version for this major version of node.
real_nodejs_version=\$(find \$version_path/\$version* -maxdepth 0 | sort --version-sort | tail --lines=1)
real_nodejs_version=\$(basename \$real_nodejs_version)
# Update the symbolic link for this version
sudo ln --symbolic --force --no-target-directory \$version_path/\$real_nodejs_version \$version_path/\$version
done <<< "\$(echo "\$all_real_version")"
EOF
chmod +x "$n_install_dir/node_update.sh"
# Build the cronjob
cat > "/etc/cron.daily/node_update" << EOF
#!/bin/bash
$n_install_dir/node_update.sh >> $n_install_dir/node_update.log
EOF
chmod +x "/etc/cron.daily/node_update"
}

View file

@ -107,10 +107,9 @@ ynh_system_user_delete "$app"
message="$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 and domain https://$domain$path_url is free for other apps now.
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.
But there is futher action needed from your side to completely remove the $app data. If you are planing to restore the app in the future don't run the command given below. If you are going to switch to othe server don't forget to copy /home/yunohost.app/$app to your new server.
You need to run this command to remove the data (warning all your videos will be removed) :
@ -118,6 +117,6 @@ You need to run this command to remove the data (warning all your videos will be
rm -R /home/yunohost.app/$app -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 an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/peertube_ynh"
ynh_send_readme_to_admin "$message"

View file

@ -62,6 +62,9 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "$final_path"
# Open this port
yunohost firewall allow Both "$port" 2>&1
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -74,9 +77,6 @@ ynh_system_user_create "$app"
#=================================================
# Set right permissions
if [ ! -d "/home/yunohost.app/$app" ]; then
mkdir -p "/home/yunohost.app/${app}/storage"
fi
chown -R "$app":"$app" "/home/yunohost.app/${app}/storage"
#=================================================
@ -99,7 +99,7 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.lis
ynh_package_update
# install postgresql, ffmpeg, redis
ynh_install_app_dependencies postgresql postgresql-contrib openssl g++ ffmpeg redis-server redis-tools mailutils yarn apt-transport-https
ynh_install_app_dependencies postgresql ffmpeg redis-server redis-tools mailutils yarn
#=================================================
# RESTORE THE PostgreSQL DATABASE
@ -133,8 +133,8 @@ ynh_restore_file "/etc/logrotate.d/$app"
yarn install --production --pure-lockfile --silent --cache-folder /var/cache/yarn/
)
# Set right permissions
chown -R "$app":"$app" "$final_path"
# Set right permissions for curl install
chown -R "$app":"$app" "$datadir"
#=================================================
# GENERIC FINALIZATION

View file

@ -54,13 +54,6 @@ ynh_abort_if_errors
# Stop Peertube for upgrade
systemctl stop "$app"
#===================================================
# Add PostgreSQL extension for v1.0.0-beta.10.pre.1
#===================================================
ynh_psql_execute_as_root "\connect $db_name
CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS pg_trgm;"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -77,15 +70,8 @@ datadir="/home/yunohost.app/${app}/storage"
# Create app folders
mkdir -p "$datadir"
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
yunohost firewall disallow Both "$port" 2>&1
fi
# Open this port
yunohost firewall allow Both "$port" 2>&1
#=================================================
# CREATE DEDICATED USER
@ -112,7 +98,7 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.lis
ynh_package_update
# install postgresql, ffmpeg, redis
ynh_install_app_dependencies postgresql postgresql-contrib openssl g++ ffmpeg redis-server redis-tools mailutils yarn apt-transport-https
ynh_install_app_dependencies postgresql ffmpeg redis-server redis-tools mailutils yarn
#=================================================
# CHECK THE PATH
@ -137,7 +123,7 @@ ynh_secure_remove "$tmpdir"
(
cd "$final_path"
yarn install --production --pure-lockfile
yarn install --production --pure-lockfile --silent --cache-folder /var/cache/yarn/
)
@ -179,7 +165,7 @@ ynh_use_logrotate --non-append
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config