mirror of
https://github.com/YunoHost-Apps/peertube_ynh.git
synced 2024-09-03 19:56:29 +02:00
commit
379a7b18a0
13 changed files with 781 additions and 449 deletions
57
README.md
57
README.md
|
@ -1,15 +1,14 @@
|
||||||
# PeerTube app for YunoHost
|
# PeerTube app for YunoHost
|
||||||
|
|
||||||
[![Integration level](https://dash.yunohost.org/integration/peertube.svg)](https://ci-apps.yunohost.org/jenkins/job/peertube%20%28Community%29/lastBuild/consoleFull)
|
[![Integration level](https://dash.yunohost.org/integration/peertube.svg)](https://dash.yunohost.org/appci/app/peertube)
|
||||||
[![Install Peertube with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=peertube)<br><br>
|
[![Install peertube with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=peertube)
|
||||||
=======
|
|
||||||
|
|
||||||
Shipped Version: **1.2.1**
|
## Overview
|
||||||
|
|
||||||
## What is Peertube ?
|
### 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>.
|
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>.
|
||||||
|
|
||||||
## Why Peertube ?
|
### 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.
|
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.
|
||||||
|
|
||||||
|
@ -18,17 +17,22 @@ But it's not enough because one video could become famous and overload the serve
|
||||||
It's the reason why we need to use a P2P protocol to limit the server load.
|
It's the reason why we need to use a P2P protocol to limit the server load.
|
||||||
Thanks to [WebTorrent](https://github.com/feross/webtorrent), we can make P2P (thus BitTorrent) inside the web browser, as of today.
|
Thanks to [WebTorrent](https://github.com/feross/webtorrent), we can make P2P (thus BitTorrent) inside the web browser, as of today.
|
||||||
|
|
||||||
## Why is that cool ?
|
### Why is that cool ?
|
||||||
Servers are run independently by different people and organizations. They can apply wildly different moderation policies, so you can find or make one that fits your taste perfectly.
|
Servers are run independently by different people and organizations. They can apply wildly different moderation policies, so you can find or make one that fits your taste perfectly.
|
||||||
|
|
||||||
By watching a video, you help the hosting provider to broadcast it by becoming a broadcaster of the video yourself. Each instance doesn’t need much money to broadcast the videos of its users.
|
By watching a video, you help the hosting provider to broadcast it by becoming a broadcaster of the video yourself. Each instance doesn’t need much money to broadcast the videos of its users.
|
||||||
|
|
||||||
## Demonstration
|
**Shipped version:** 1.2.1
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
![](https://framablog.org/wp-content/uploads/2018/03/Framatube-au-lancement.png)
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
Want to see in action?
|
Want to see in action?
|
||||||
|
|
||||||
* [Here](http://peertube.cpy.re) are the list of instances ran by people around the world. Be a part of it.
|
* [Here](http://peertube.cpy.re) are the list of instances ran by people around the world. Be a part of it.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -59,12 +63,41 @@ Want to see in action?
|
||||||
|
|
||||||
$ sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/peertube_ynh peertube
|
$ sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/peertube_ynh peertube
|
||||||
|
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
* NodeJS, PostgreSQL.
|
* NodeJS, PostgreSQL.
|
||||||
* On Debian Jessie,backport is added for the ffmpeg package.
|
* On Debian Jessie,backport is added for the ffmpeg package.
|
||||||
|
|
||||||
## LICENSE
|
## Documentation
|
||||||
|
|
||||||
PeerTube is licensed under the GNU Affero General Public License v3.0.
|
* Official documentation: https://docs.joinpeertube.org/
|
||||||
|
|
||||||
|
## YunoHost specific features
|
||||||
|
|
||||||
|
#### Supported architectures
|
||||||
|
|
||||||
|
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/)
|
||||||
|
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/)
|
||||||
|
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/peertube%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/peertube/)
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
* Report a bug: https://github.com/YunoHost-Apps/peertube_ynh/issues
|
||||||
|
* App website: https://joinpeertube.org/fr/
|
||||||
|
* GitHub App website: https://github.com/Chocobozzz/PeerTube/
|
||||||
|
* YunoHost website: https://yunohost.org/
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Developers info
|
||||||
|
----------------
|
||||||
|
|
||||||
|
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||||
|
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/peertube_ynh/tree/testing).
|
||||||
|
|
||||||
|
To try the testing branch, please proceed like that.
|
||||||
|
```
|
||||||
|
sudo yunohost app install https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug
|
||||||
|
or
|
||||||
|
sudo yunohost app upgrade peertube -u https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug
|
||||||
|
```
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
|
upgrade=1 from_commit=cc324108b47f3f9f862f03a82eac1370ea11e246
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
incorrect_path=0
|
incorrect_path=0
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
proxy_send_timeout 600;
|
proxy_send_timeout 600;
|
||||||
proxy_read_timeout 600;
|
proxy_read_timeout 600;
|
||||||
send_timeout 600;
|
send_timeout 600;
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bypass PeerTube for performance reasons. Could be removed
|
# Bypass PeerTube for performance reasons. Could be removed
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Video streaming platform using P2P directly in the web browser, connected to a federated network",
|
"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é"
|
"fr": "Plateforme de diffusion vidéo par P2P directement dans le navigateur, et connectée à un réseau fédéralisé"
|
||||||
},
|
},
|
||||||
"version": "1.2.1",
|
"version": "1.2.1~ynh1",
|
||||||
"url": "https://github.com/Chocobozzz/PeerTube",
|
"url": "https://github.com/Chocobozzz/PeerTube",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"email": "anmol@datamol.org"
|
"email": "anmol@datamol.org"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.7.9"
|
"yunohost": ">= 3.4"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# ============= FUTURE YUNOHOST HELPER =============
|
#=================================================
|
||||||
# Delete a file checksum from the app settings
|
# COMMON VARIABLES
|
||||||
#
|
#=================================================
|
||||||
# $app should be defined when calling this helper
|
|
||||||
#
|
# dependencies used by the app
|
||||||
# usage: ynh_remove_file_checksum file
|
pkg_dependencies="postgresql postgresql-contrib openssl g++ redis-server redis-tools mailutils apt-transport-https"
|
||||||
# | arg: file - The file for which the checksum will be deleted
|
|
||||||
ynh_delete_file_checksum () {
|
#=================================================
|
||||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
# PERSONAL HELPERS
|
||||||
ynh_app_setting_delete $app $checksum_setting_name
|
#=================================================
|
||||||
}
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
|
|
|
@ -6,27 +6,25 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
# Get the _common.sh file if it's not in the current directory
|
source ../settings/scripts/_common.sh
|
||||||
cp ../settings/scripts/_common.sh ./_common.sh
|
source ../settings/scripts/ynh_systemd_action
|
||||||
cp ../settings/scripts/psql.sh ./psql.sh
|
|
||||||
chmod a+rx _common.sh psql.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source psql.sh
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
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
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -34,50 +32,61 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
db_name=$(ynh_app_setting_get "$app" psql_db)
|
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||||
|
|
||||||
# Stop Peertube for backup
|
#=================================================
|
||||||
systemctl stop "$app"
|
# STOP PEERTUBE FOR BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Stop $app service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Backing up the main app directory..."
|
||||||
|
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Backing up nginx web server configuration..."
|
||||||
|
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE PostgreSQL DATABASE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Backing up the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_dump_db "$db_name" > db.sql
|
ynh_psql_dump_db "$db_name" > db.sql
|
||||||
ynh_backup "db.sql"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Backing up logrotate configuration..."
|
||||||
|
|
||||||
ynh_backup "/etc/logrotate.d/$app"
|
ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP SYSTEMD
|
# BACKUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Backing up systemd configuration..."
|
||||||
|
|
||||||
ynh_backup "/etc/systemd/system/$app.service"
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# START PEERTUBE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Start $app service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on localhost"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
systemctl enable "$app"
|
|
||||||
systemctl start "$app"
|
|
||||||
# App needs time to start
|
|
||||||
sleep 30
|
|
||||||
|
|
213
scripts/install
213
scripts/install
|
@ -7,13 +7,18 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_add_secure_repos__3
|
||||||
|
source ynh_systemd_action
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source psql.sh
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
read-p "key"
|
||||||
|
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
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
@ -27,34 +32,23 @@ admin_email=$YNH_APP_ARG_EMAIL
|
||||||
admin_pass=$(ynh_string_random 24)
|
admin_pass=$(ynh_string_random 24)
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
|
|
||||||
# This is a multi-instance app, meaning it can be installed several times independently
|
|
||||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
||||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
||||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
||||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
||||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
||||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
||||||
# The app instance name is probably what you are interested the most, since this is
|
|
||||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
||||||
# db names, ...
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Validating installation parameters..."
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
|
|
||||||
# Check web path availability
|
|
||||||
ynh_webpath_available "$domain" "$path_url"
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Storing installation settings..."
|
||||||
|
|
||||||
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_email "$admin_email"
|
||||||
|
@ -66,45 +60,38 @@ ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Configuring firewall..."
|
||||||
|
|
||||||
# Find a free port
|
# Find a free port
|
||||||
port=$(ynh_find_port 9000)
|
port=$(ynh_find_port 9000)
|
||||||
ynh_app_setting_set "$app" port "$port"
|
ynh_app_setting_set "$app" port "$port"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE THE DATA DIRECTORY
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Define app's data directory
|
|
||||||
datadir="/home/yunohost.app/${app}/storage"
|
|
||||||
# Create app folders
|
|
||||||
mkdir -p "$datadir"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Installing dependencies..."
|
||||||
|
|
||||||
# install nodejs
|
# Install nodejs
|
||||||
ynh_install_nodejs 8
|
ynh_install_nodejs 8
|
||||||
|
|
||||||
# Add backports for Debian Jessie (required to install ffmpeg)
|
# Install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
# Install ffmpeg from backports for Debian Jessie and from main for others
|
||||||
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
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
|
ynh_install_extra_app_dependencies --repo="deb http://httpredir.debian.org/debian jessie-backports main" --package="ffmpeg"
|
||||||
|
else
|
||||||
|
ynh_add_app_dependencies --package="ffmpeg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add yarn repo for Debian
|
# Install Yarn
|
||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DATABASE SETUP
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Creating a PostgreSQL database..."
|
||||||
|
|
||||||
# Create postgresql database
|
|
||||||
db_name="peertube_${app}"
|
db_name="peertube_${app}"
|
||||||
db_pwd=$(ynh_string_random 30)
|
db_pwd=$(ynh_string_random 30)
|
||||||
ynh_app_setting_set "$app" psql_db "$db_name"
|
ynh_app_setting_set "$app" psql_db "$db_name"
|
||||||
|
@ -116,52 +103,52 @@ ynh_psql_execute_as_root \
|
||||||
ynh_psql_execute_as_root "\connect $db_name
|
ynh_psql_execute_as_root "\connect $db_name
|
||||||
CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Setting up source files..."
|
||||||
|
|
||||||
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Configuring nginx web server..."
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Configuring system user..."
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create "$app"
|
ynh_system_user_create "$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK PEERTUBE SOURCE
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# CREATE THE DATA DIRECTORY
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
|
||||||
ynh_setup_source "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BUILD YARN DEPENDENCIES
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Create the data directory..."
|
||||||
|
|
||||||
cp ../conf/production.yaml "$final_path/config/production.yaml"
|
# Define app's data directory
|
||||||
touch "$final_path/config/local-production.json"
|
datadir="/home/yunohost.app/${app}/storage"
|
||||||
|
|
||||||
(
|
# Create app folders
|
||||||
cd "$final_path"
|
mkdir -p "$datadir"
|
||||||
yarn install --production --pure-lockfile
|
|
||||||
)
|
|
||||||
|
|
||||||
#=================================================
|
# Give permission to the datadir
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
|
|
||||||
# Set right permissions for the app
|
|
||||||
chown -R "$app":"$app" "$datadir"
|
chown -R "$app":"$app" "$datadir"
|
||||||
|
|
||||||
# Reload Nginx
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
cp ../conf/production.yaml "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__domain__" "$domain" "$final_path/config/production.yaml"
|
ynh_replace_string "__domain__" "$domain" "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__db_name__" "$app" "$final_path/config/production.yaml"
|
ynh_replace_string "__db_name__" "$app" "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__app__" "$app" "$final_path/config/production.yaml"
|
ynh_replace_string "__app__" "$app" "$final_path/config/production.yaml"
|
||||||
|
@ -169,6 +156,8 @@ ynh_replace_string "__db_pwd__" "$db_pwd" "$final_path/config/production.y
|
||||||
ynh_replace_string "__email__" "$admin_email" "$final_path/config/production.yaml"
|
ynh_replace_string "__email__" "$admin_email" "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__PORT__" "$port" "$final_path/config/production.yaml"
|
ynh_replace_string "__PORT__" "$port" "$final_path/config/production.yaml"
|
||||||
|
|
||||||
|
#Create the admin settings file
|
||||||
|
touch "$final_path/config/local-production.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||||
|
@ -178,40 +167,12 @@ ynh_replace_string "__PORT__" "$port" "$final_path/config/production.y
|
||||||
ynh_store_file_checksum "$final_path/config/production.yaml"
|
ynh_store_file_checksum "$final_path/config/production.yaml"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# BUILD YARN DEPENDENCIES
|
||||||
#=================================================
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
pushd "$final_path"
|
||||||
ynh_use_logrotate "/home/yunohost.app/${app}/storage/logs/peertube.log"
|
yarn install --production --pure-lockfile
|
||||||
|
popd
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if [ "$is_public" -eq 0 ]
|
|
||||||
then # Remove the public access
|
|
||||||
ynh_app_setting_delete "$app" skipped_uris
|
|
||||||
fi
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ "$is_public" -eq 1 ]
|
|
||||||
then
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Give permisiion to the final_path
|
|
||||||
chown -R "$app":"$app" "$final_path" "$datadir"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -220,19 +181,65 @@ systemctl reload nginx
|
||||||
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
systemctl enable "$app"
|
|
||||||
systemctl start "$app"
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R "$app":"$app" $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Configuring log rotation..."
|
||||||
|
|
||||||
|
# Use logrotate to manage application logfile(s)
|
||||||
|
ynh_use_logrotate "/home/yunohost.app/${app}/storage/logs/peertube.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
|
||||||
|
yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Configuring SSOwat..."
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
if [ $is_public -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Reloading nginx web server..."
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Start $app service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on localhost"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHANGE PEERTUBE ADMIN PASSWORD AFTER INITIAL GEN
|
# CHANGE PEERTUBE ADMIN PASSWORD AFTER INITIAL GEN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# we need to wait for the service to init peertube's database
|
# we need to wait for the service to init peertube's database
|
||||||
(
|
pushd "$final_path"
|
||||||
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 npm run reset-password -- -u root
|
||||||
)
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SEND A README FOR THE ADMIN
|
# SEND A README FOR THE ADMIN
|
||||||
|
@ -248,3 +255,9 @@ The admin password is: $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 are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/peertube_ynh"
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message"
|
ynh_send_readme_to_admin "$message"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Installation of $app completed"
|
||||||
|
|
160
scripts/psql.sh
160
scripts/psql.sh
|
@ -1,160 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
#
|
|
||||||
# POSTGRES HELPERS
|
|
||||||
#
|
|
||||||
# Point of contact : Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a master password and set up global settings
|
|
||||||
# Please always call this script in install and restore scripts
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_test_if_first_run
|
|
||||||
|
|
||||||
ynh_psql_test_if_first_run() {
|
|
||||||
if [ -f /etc/yunohost/psql ];
|
|
||||||
then
|
|
||||||
echo "PostgreSQL is already installed, no need to create master password"
|
|
||||||
else
|
|
||||||
pgsql=$(ynh_string_random)
|
|
||||||
pg_hba=""
|
|
||||||
echo "$pgsql" >> /etc/yunohost/psql
|
|
||||||
|
|
||||||
if [ -e /etc/postgresql/9.4/ ]
|
|
||||||
then
|
|
||||||
pg_hba=/etc/postgresql/9.4/main/pg_hba.conf
|
|
||||||
elif [ -e /etc/postgresql/9.6/ ]
|
|
||||||
then
|
|
||||||
pg_hba=/etc/postgresql/9.6/main/pg_hba.conf
|
|
||||||
else
|
|
||||||
ynh_die "postgresql shoud be 9.4 or 9.6"
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemctl start postgresql
|
|
||||||
sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$pgsql'" postgres
|
|
||||||
|
|
||||||
# force all user to connect to local database using passwords
|
|
||||||
# https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF
|
|
||||||
# Note: we can't use peer since YunoHost create users with nologin
|
|
||||||
# See: https://github.com/YunoHost/yunohost/blob/unstable/data/helpers.d/user
|
|
||||||
sed -i '/local\s*all\s*all\s*peer/i \
|
|
||||||
local all all password' "$pg_hba"
|
|
||||||
systemctl enable postgresql
|
|
||||||
systemctl reload postgresql
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Open a connection as a user
|
|
||||||
#
|
|
||||||
# example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;"
|
|
||||||
# example: ynh_psql_connect_as 'user' 'pass' < /path/to/file.sql
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_connect_as user pwd [db]
|
|
||||||
# | arg: user - the user name to connect as
|
|
||||||
# | arg: pwd - the user password
|
|
||||||
# | arg: db - the database to connect to
|
|
||||||
ynh_psql_connect_as() {
|
|
||||||
user="$1"
|
|
||||||
pwd="$2"
|
|
||||||
db="$3"
|
|
||||||
sudo --login --user=postgres PGUSER="$user" PGPASSWORD="$pwd" psql "$db"
|
|
||||||
}
|
|
||||||
|
|
||||||
# # Execute a command as root user
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_execute_as_root sql [db]
|
|
||||||
# | arg: sql - the SQL command to execute
|
|
||||||
# | arg: db - the database to connect to
|
|
||||||
ynh_psql_execute_as_root () {
|
|
||||||
sql="$1"
|
|
||||||
sudo --login --user=postgres psql <<< "$sql"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute a command from a file as root user
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_execute_file_as_root file [db]
|
|
||||||
# | arg: file - the file containing SQL commands
|
|
||||||
# | arg: db - the database to connect to
|
|
||||||
ynh_psql_execute_file_as_root() {
|
|
||||||
file="$1"
|
|
||||||
db="$2"
|
|
||||||
sudo --login --user=postgres psql "$db" < "$file"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a database, an user and its password. Then store the password in the app's config
|
|
||||||
#
|
|
||||||
# After executing this helper, the password of the created database will be available in $db_pwd
|
|
||||||
# It will also be stored as "psqlpwd" into the app settings.
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_setup_db user name [pwd]
|
|
||||||
# | arg: user - Owner of the database
|
|
||||||
# | arg: name - Name of the database
|
|
||||||
# | arg: pwd - Password of the database. If not given, a password will be generated
|
|
||||||
ynh_psql_setup_db () {
|
|
||||||
db_user="$1"
|
|
||||||
db_name="$2"
|
|
||||||
new_db_pwd=$(ynh_string_random) # Generate a random password
|
|
||||||
# If $3 is not given, use new_db_pwd instead for db_pwd.
|
|
||||||
db_pwd="${3:-$new_db_pwd}"
|
|
||||||
ynh_psql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database
|
|
||||||
ynh_app_setting_set "$app" psqlpwd "$db_pwd" # Store the password in the app's config
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a database and grant privilegies to a user
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_create_db db [user [pwd]]
|
|
||||||
# | arg: db - the database name to create
|
|
||||||
# | arg: user - the user to grant privilegies
|
|
||||||
# | arg: pwd - the user password
|
|
||||||
ynh_psql_create_db() {
|
|
||||||
db="$1"
|
|
||||||
user="$2"
|
|
||||||
pwd="$3"
|
|
||||||
ynh_psql_create_user "$user" "$pwd"
|
|
||||||
sudo --login --user=postgres createdb --owner="$user" "$db"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Drop a database
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_drop_db db
|
|
||||||
# | arg: db - the database name to drop
|
|
||||||
# | arg: user - the user to drop
|
|
||||||
ynh_psql_remove_db() {
|
|
||||||
db="$1"
|
|
||||||
user="$2"
|
|
||||||
sudo --login --user=postgres dropdb "$db"
|
|
||||||
ynh_psql_drop_user "$user"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Dump a database
|
|
||||||
#
|
|
||||||
# example: ynh_psql_dump_db 'roundcube' > ./dump.sql
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_dump_db db
|
|
||||||
# | arg: db - the database name to dump
|
|
||||||
# | ret: the psqldump output
|
|
||||||
ynh_psql_dump_db() {
|
|
||||||
db="$1"
|
|
||||||
sudo --login --user=postgres pg_dump "$db"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Create a user
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_create_user user pwd [host]
|
|
||||||
# | arg: user - the user name to create
|
|
||||||
ynh_psql_create_user() {
|
|
||||||
user="$1"
|
|
||||||
pwd="$2"
|
|
||||||
sudo --login --user=postgres psql -c"CREATE USER $user WITH PASSWORD '$pwd'" postgres
|
|
||||||
}
|
|
||||||
|
|
||||||
# Drop a user
|
|
||||||
#
|
|
||||||
# usage: ynh_psql_drop_user user
|
|
||||||
# | arg: user - the user name to drop
|
|
||||||
ynh_psql_drop_user() {
|
|
||||||
user="$1"
|
|
||||||
sudo --login --user=postgres dropuser "$user"
|
|
||||||
}
|
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source psql.sh
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -23,43 +23,49 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
|
if yunohost service status $app >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
ynh_print_info "Removing $app service"
|
||||||
|
yunohost service remove "$app"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP AND REMOVE SERVICE
|
# STOP AND REMOVE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Stopping and removing the systemd service"
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Removing the PostgreSQL database"
|
||||||
|
|
||||||
if yunohost service status | grep -q "$app"
|
ynh_psql_execute_as_root "\connect $db_name
|
||||||
then
|
SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';"
|
||||||
echo "Remove $app service"
|
|
||||||
yunohost service remove "$app"
|
# Remove a database if it exists, along with the associated user
|
||||||
fi
|
ynh_psql_remove_db --db_name="$db_name" --db_user="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Removing dependencies"
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
# Delete backport and yarn from source.list
|
|
||||||
ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list
|
|
||||||
ynh_secure_remove /etc/apt/sources.list.d/yarn.list
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE THE MYSQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
|
||||||
ynh_psql_remove_db "$db_name" "$app"
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Removing app main directory"
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove "$final_path"
|
||||||
|
@ -67,6 +73,7 @@ ynh_secure_remove "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Removing nginx web server configuration"
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -74,6 +81,7 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Removing logrotate configuration"
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
@ -84,8 +92,8 @@ ynh_remove_logrotate
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
then
|
then
|
||||||
echo "Close port $port"
|
ynh_print_info "Closing port $port"
|
||||||
yunohost firewall disallow Both "$port" 2>&1
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -97,6 +105,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Removing the dedicated system user"
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete "$app"
|
ynh_system_user_delete "$app"
|
||||||
|
@ -121,3 +130,9 @@ 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 any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/peertube_ynh"
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message"
|
ynh_send_readme_to_admin "$message"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Removal of $app completed"
|
||||||
|
|
|
@ -6,42 +6,39 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
source ../settings/scripts/_common.sh
|
||||||
# Get the _common.sh file if it's not in the current directory
|
source ../settings/scripts/ynh_add_secure_repos__3
|
||||||
cp ../settings/scripts/_common.sh ./_common.sh
|
source ../settings/scripts/ynh_systemd_action
|
||||||
cp ../settings/scripts/psql.sh ./psql.sh
|
|
||||||
chmod a+rx _common.sh psql.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source psql.sh
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
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
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Loading settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path_url="/"
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
port=$(ynh_app_setting_get "$app" port)
|
port=$(ynh_app_setting_get "$app" port)
|
||||||
db_name=$(ynh_app_setting_get "$app" psql_db)
|
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Validating restoration parameters..."
|
||||||
|
|
||||||
ynh_webpath_available "$domain" "$path_url" \
|
ynh_webpath_available "$domain" "$path_url" \
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||||
|
@ -59,12 +56,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Recreating the dedicated system user..."
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create "$app"
|
ynh_system_user_create "$app"
|
||||||
|
@ -84,26 +83,28 @@ chown -R "$app":"$app" "/home/yunohost.app/${app}/storage"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Reinstalling dependencies..."
|
||||||
|
|
||||||
# install nodejs
|
# Install nodejs
|
||||||
ynh_install_nodejs 8
|
ynh_install_nodejs 8
|
||||||
|
|
||||||
# add backports for Debian Jessie (required to install ffmpeg)
|
# Install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
# Install ffmpeg from backports for Debian Jessie and from main for others
|
||||||
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
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
|
ynh_install_extra_app_dependencies --repo="deb http://httpredir.debian.org/debian jessie-backports main" --package="ffmpeg"
|
||||||
|
else
|
||||||
|
ynh_add_app_dependencies --package="ffmpeg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add yarn repo for Debian
|
# Install Yarn
|
||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PostgreSQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Restoring the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_create_user "$app" "$db_pwd"
|
ynh_psql_create_user "$app" "$db_pwd"
|
||||||
|
@ -114,36 +115,41 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Restoring the systemd configuration..."
|
||||||
|
|
||||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
systemctl enable "$app.service"
|
systemctl enable "$app.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/logrotate.d/$app"
|
ynh_restore_file "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
(
|
|
||||||
cd "$final_path"
|
|
||||||
yarn install --production --pure-lockfile --silent --cache-folder /var/cache/yarn/
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set right permissions
|
|
||||||
chown -R "$app":"$app" "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PeerTube
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Reloading nginx web server..."
|
||||||
|
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
systemctl enable "$app"
|
|
||||||
systemctl start "$app"
|
#=================================================
|
||||||
# App needs time to start
|
# START SERVICE
|
||||||
sleep 30
|
#=================================================
|
||||||
|
ynh_print_info "Start $app service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on localhost"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Restoration completed for $app"
|
||||||
|
|
194
scripts/upgrade
194
scripts/upgrade
|
@ -7,17 +7,19 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_add_secure_repos__3
|
||||||
|
source ynh_systemd_action
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source psql.sh
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path_url="/"
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
admin_email=$(ynh_app_setting_get "$app" admin_email)
|
admin_email=$(ynh_app_setting_get "$app" admin_email)
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
@ -28,6 +30,7 @@ db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Ensuring downward compatibility..."
|
||||||
|
|
||||||
# Fix is_public as a boolean value
|
# Fix is_public as a boolean value
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
|
@ -38,21 +41,38 @@ elif [ "$is_public" = "No" ]; then
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Close a port
|
||||||
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
|
then
|
||||||
|
ynh_print_info "Closing port $port"
|
||||||
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove repository
|
||||||
|
ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list
|
||||||
|
ynh_secure_remove /etc/apt/sources.list.d/yarn.list
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "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
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
|
ynh_clean_check_starting
|
||||||
ynh_restore_upgradebackup
|
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
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Stop Peertube for upgrade
|
#=================================================
|
||||||
systemctl stop "$app"
|
# STOP PEERTUBE FOR UPGRADE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Stop $app service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
|
|
||||||
#===================================================
|
#===================================================
|
||||||
# Add PostgreSQL extension for v1.0.0-beta.10.pre.1
|
# Add PostgreSQL extension for v1.0.0-beta.10.pre.1
|
||||||
|
@ -78,86 +98,20 @@ datadir="/home/yunohost.app/${app}/storage"
|
||||||
mkdir -p "$datadir"
|
mkdir -p "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
|
||||||
then
|
|
||||||
echo "Close port $port"
|
|
||||||
yunohost firewall disallow Both "$port" 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create "$app"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# install nodejs
|
|
||||||
ynh_install_nodejs 8
|
|
||||||
|
|
||||||
# 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
|
|
||||||
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 postgresql, ffmpeg, redis
|
|
||||||
ynh_install_app_dependencies postgresql postgresql-contrib openssl g++ ffmpeg redis-server redis-tools mailutils yarn apt-transport-https
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK THE PATH
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
|
||||||
path_url=$(ynh_normalize_url_path "$path_url")
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DOWNLOAD, CHECK AND UNPACK PEERTUBE SOURCE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "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 "$final_path"
|
ynh_setup_source "$final_path"
|
||||||
cp ../conf/production.yaml "$final_path/config/production.yaml"
|
|
||||||
|
|
||||||
#Copy the admin saved settings from tmp directory to final path
|
|
||||||
cp -a "$tmpdir/local-production.json" "$final_path/config/local-production.json"
|
|
||||||
|
|
||||||
# Remove the tmp directory securely
|
|
||||||
ynh_secure_remove "$tmpdir"
|
|
||||||
|
|
||||||
(
|
|
||||||
cd "$final_path"
|
|
||||||
yarn install --production --pure-lockfile
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
chown -R root:root "$final_path"
|
|
||||||
chown -R "$app" "$datadir"
|
|
||||||
|
|
||||||
# Reload Nginx
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
cp ../conf/production.yaml "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__domain__" "$domain" "$final_path/config/production.yaml"
|
ynh_replace_string "__domain__" "$domain" "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__db_name__" "$app" "$final_path/config/production.yaml"
|
ynh_replace_string "__db_name__" "$app" "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__app__" "$app" "$final_path/config/production.yaml"
|
ynh_replace_string "__app__" "$app" "$final_path/config/production.yaml"
|
||||||
|
@ -165,13 +119,67 @@ ynh_replace_string "__db_pwd__" "$db_pwd" "$final_path/config/production.y
|
||||||
ynh_replace_string "__email__" "$admin_email" "$final_path/config/production.yaml"
|
ynh_replace_string "__email__" "$admin_email" "$final_path/config/production.yaml"
|
||||||
ynh_replace_string "__PORT__" "$port" "$final_path/config/production.yaml"
|
ynh_replace_string "__PORT__" "$port" "$final_path/config/production.yaml"
|
||||||
|
|
||||||
|
#Copy the admin saved settings from tmp directory to final path
|
||||||
|
cp -a "$tmpdir/local-production.json" "$final_path/config/local-production.json"
|
||||||
|
|
||||||
# Recalculate and store the config file checksum into the app settings
|
# Remove the tmp directory securely
|
||||||
|
ynh_secure_remove "$tmpdir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading nginx web server configuration..."
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading dependencies..."
|
||||||
|
|
||||||
|
# Install nodejs
|
||||||
|
ynh_install_nodejs 8
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
# Install ffmpeg from backports for Debian Jessie and from main for others
|
||||||
|
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
||||||
|
ynh_install_extra_app_dependencies --repo="deb http://httpredir.debian.org/debian jessie-backports main" --package="ffmpeg"
|
||||||
|
else
|
||||||
|
ynh_add_app_dependencies --package="ffmpeg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Yarn
|
||||||
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Making sure dedicated system user exists..."
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create "$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# BUILD YARN DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
pushd "$final_path"
|
||||||
|
yarn install --production --pure-lockfile
|
||||||
|
popd
|
||||||
|
|
||||||
|
ynh_backup_if_checksum_is_different "$final_path/config/production.yaml"
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum "$final_path/config/production.yaml"
|
ynh_store_file_checksum "$final_path/config/production.yaml"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading logrotate configuration..."
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate --non-append
|
||||||
|
@ -179,23 +187,27 @@ ynh_use_logrotate --non-append
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading systemd configuration..."
|
||||||
|
|
||||||
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Set right permissions
|
# Set permissions on app files
|
||||||
chown -R "$app":"$app" "$final_path" "$datadir"
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
chown -R "$app":"$app" "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Upgrading SSOwat configuration..."
|
||||||
|
|
||||||
if [ "$is_public" -eq 0 ]
|
|
||||||
then # Remove the public access
|
|
||||||
ynh_app_setting_delete "$app" skipped_uris
|
|
||||||
fi
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ "$is_public" -eq 1 ]
|
if [ "$is_public" -eq 1 ]
|
||||||
then
|
then
|
||||||
|
@ -206,9 +218,19 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Reloading nginx web server..."
|
||||||
|
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
systemctl enable "$app"
|
|
||||||
systemctl start "$app"
|
#=================================================
|
||||||
# App needs time to start
|
# START SERVICE
|
||||||
sleep 30
|
#=================================================
|
||||||
|
ynh_print_info "Start $app service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on localhost"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Upgrade of $app completed"
|
||||||
|
|
294
scripts/ynh_add_secure_repos__3
Normal file
294
scripts/ynh_add_secure_repos__3
Normal file
|
@ -0,0 +1,294 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Pin a repository.
|
||||||
|
#
|
||||||
|
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
|
||||||
|
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
|
||||||
|
# | arg: -i, --pin - Filter for the pin.
|
||||||
|
# | arg: -p, --priority - Priority for the pin
|
||||||
|
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||||
|
# | arg: -a, --append - Do not overwrite existing files.
|
||||||
|
#
|
||||||
|
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
|
||||||
|
#
|
||||||
|
ynh_pin_repo () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=pirna
|
||||||
|
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
|
||||||
|
local package
|
||||||
|
local pin
|
||||||
|
local priority
|
||||||
|
local name
|
||||||
|
local append
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
package="${package:-*}"
|
||||||
|
priority=${priority:-50}
|
||||||
|
name="${name:-$app}"
|
||||||
|
append=${append:-0}
|
||||||
|
|
||||||
|
if [ $append -eq 1 ]
|
||||||
|
then
|
||||||
|
append="tee -a"
|
||||||
|
else
|
||||||
|
append="tee"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "/etc/apt/preferences.d"
|
||||||
|
echo "Package: $package
|
||||||
|
Pin: $pin
|
||||||
|
Pin-Priority: $priority" \
|
||||||
|
| $append "/etc/apt/preferences.d/$name"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add a repository.
|
||||||
|
#
|
||||||
|
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
|
||||||
|
# | arg: -u, --uri - Uri of the repository.
|
||||||
|
# | arg: -s, --suite - Suite of the repository.
|
||||||
|
# | arg: -c, --component - Component of the repository.
|
||||||
|
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||||
|
# | arg: -a, --append - Do not overwrite existing files.
|
||||||
|
#
|
||||||
|
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
||||||
|
# uri suite component
|
||||||
|
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
|
||||||
|
#
|
||||||
|
ynh_add_repo () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=uscna
|
||||||
|
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
|
||||||
|
local uri
|
||||||
|
local suite
|
||||||
|
local component
|
||||||
|
local name
|
||||||
|
local append
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
name="${name:-$app}"
|
||||||
|
append=${append:-0}
|
||||||
|
|
||||||
|
if [ $append -eq 1 ]
|
||||||
|
then
|
||||||
|
append="tee -a"
|
||||||
|
else
|
||||||
|
append="tee"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "/etc/apt/sources.list.d"
|
||||||
|
# Add the new repo in sources.list.d
|
||||||
|
echo "deb $uri $suite $component" \
|
||||||
|
| $append "/etc/apt/sources.list.d/$name.list"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add an extra repository correctly, pin it and get the key.
|
||||||
|
#
|
||||||
|
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
|
||||||
|
# | arg: -r, --repo - Complete url of the extra repository.
|
||||||
|
# | arg: -k, --key - url to get the public key.
|
||||||
|
# | arg: -p, --priority - Priority for the pin
|
||||||
|
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||||
|
# | arg: -a, --append - Do not overwrite existing files.
|
||||||
|
ynh_install_extra_repo () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=rkpna
|
||||||
|
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
|
||||||
|
local repo
|
||||||
|
local key
|
||||||
|
local priority
|
||||||
|
local name
|
||||||
|
local append
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
name="${name:-$app}"
|
||||||
|
append=${append:-0}
|
||||||
|
key=${key:-0}
|
||||||
|
priority=${priority:-}
|
||||||
|
|
||||||
|
if [ $append -eq 1 ]
|
||||||
|
then
|
||||||
|
append="--append"
|
||||||
|
wget_append="tee -a"
|
||||||
|
else
|
||||||
|
append=""
|
||||||
|
wget_append="tee"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split the repository into uri, suite and components.
|
||||||
|
# Remove "deb " at the beginning of the repo.
|
||||||
|
repo="${repo#deb }"
|
||||||
|
|
||||||
|
# Get the uri
|
||||||
|
local uri="$(echo "$repo" | awk '{ print $1 }')"
|
||||||
|
|
||||||
|
# Get the suite
|
||||||
|
local suite="$(echo "$repo" | awk '{ print $2 }')"
|
||||||
|
|
||||||
|
# Get the components
|
||||||
|
local component="${repo##$uri $suite }"
|
||||||
|
|
||||||
|
# Add the repository into sources.list.d
|
||||||
|
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
|
||||||
|
|
||||||
|
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
||||||
|
# Build $pin from the uri without http and any sub path
|
||||||
|
local pin="${uri#*://}"
|
||||||
|
pin="${pin%%/*}"
|
||||||
|
# Set a priority only if asked
|
||||||
|
if [ -n "$priority" ]
|
||||||
|
then
|
||||||
|
priority="--priority=$priority"
|
||||||
|
fi
|
||||||
|
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
||||||
|
|
||||||
|
# Get the public key for the repo
|
||||||
|
if [ -n "$key" ]
|
||||||
|
then
|
||||||
|
mkdir -p "/etc/apt/trusted.gpg.d"
|
||||||
|
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update the list of package with the new repo
|
||||||
|
ynh_package_update
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove an extra repository and the assiociated configuration.
|
||||||
|
#
|
||||||
|
# usage: ynh_remove_extra_repo [--name=name]
|
||||||
|
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||||
|
ynh_remove_extra_repo () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=n
|
||||||
|
declare -Ar args_array=( [n]=name= )
|
||||||
|
local name
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
name="${name:-$app}"
|
||||||
|
|
||||||
|
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
|
||||||
|
ynh_secure_remove "/etc/apt/preferences.d/$name"
|
||||||
|
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
|
||||||
|
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
|
||||||
|
|
||||||
|
# Update the list of package to exclude the old repo
|
||||||
|
ynh_package_update
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install packages from an extra repository properly.
|
||||||
|
#
|
||||||
|
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
|
||||||
|
# | arg: -r, --repo - Complete url of the extra repository.
|
||||||
|
# | arg: -p, --package - The packages to install from this extra repository
|
||||||
|
# | arg: -k, --key - url to get the public key.
|
||||||
|
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||||
|
ynh_install_extra_app_dependencies () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=rpkn
|
||||||
|
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
|
||||||
|
local repo
|
||||||
|
local package
|
||||||
|
local key
|
||||||
|
local name
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
name="${name:-$app}"
|
||||||
|
key=${key:-0}
|
||||||
|
|
||||||
|
# Set a key only if asked
|
||||||
|
if [ -n "$key" ]
|
||||||
|
then
|
||||||
|
key="--key=$key"
|
||||||
|
fi
|
||||||
|
# Add an extra repository for those packages
|
||||||
|
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
|
||||||
|
|
||||||
|
# Install requested dependencies from this extra repository.
|
||||||
|
ynh_add_app_dependencies --package="$package"
|
||||||
|
|
||||||
|
# Remove this extra repository after packages are installed
|
||||||
|
ynh_remove_extra_repo --name=$app
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
|
||||||
|
|
||||||
|
# Define and install dependencies with a equivs control file
|
||||||
|
# This helper can/should only be called once per app
|
||||||
|
#
|
||||||
|
# usage: ynh_install_app_dependencies dep [dep [...]]
|
||||||
|
# | arg: dep - the package name to install in dependence
|
||||||
|
# You can give a choice between some package with this syntax : "dep1|dep2"
|
||||||
|
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
||||||
|
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
|
ynh_install_app_dependencies () {
|
||||||
|
local dependencies=$@
|
||||||
|
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
||||||
|
dependencies=${dependencies//|/ | }
|
||||||
|
local manifest_path="../manifest.json"
|
||||||
|
if [ ! -e "$manifest_path" ]; then
|
||||||
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||||
|
fi
|
||||||
|
|
||||||
|
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
||||||
|
if [ ${#version} -eq 0 ]; then
|
||||||
|
version="1.0"
|
||||||
|
fi
|
||||||
|
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||||
|
|
||||||
|
# Handle specific versions
|
||||||
|
if [[ "$dependencies" =~ [\<=\>] ]]
|
||||||
|
then
|
||||||
|
# Replace version specifications by relationships syntax
|
||||||
|
# https://www.debian.org/doc/debian-policy/ch-relationships.html
|
||||||
|
# Sed clarification
|
||||||
|
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
|
||||||
|
# [\<=\>] matches < = or >
|
||||||
|
# \+ matches one or more occurence of the previous characters, for >= or >>.
|
||||||
|
# [^,]\+ matches all characters except ','
|
||||||
|
# Ex: package>=1.0 will be replaced by package (>= 1.0)
|
||||||
|
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
||||||
|
Section: misc
|
||||||
|
Priority: optional
|
||||||
|
Package: ${dep_app}-ynh-deps
|
||||||
|
Version: ${version}
|
||||||
|
Depends: ${dependencies}
|
||||||
|
Architecture: all
|
||||||
|
Description: Fake package for $app (YunoHost app) dependencies
|
||||||
|
This meta-package is only responsible of installing its dependencies.
|
||||||
|
EOF
|
||||||
|
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
||||||
|
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
|
||||||
|
rm /tmp/${dep_app}-ynh-deps.control
|
||||||
|
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_add_app_dependencies () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=pr
|
||||||
|
declare -Ar args_array=( [p]=package= [r]=replace)
|
||||||
|
local package
|
||||||
|
local replace
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
replace=${replace:-0}
|
||||||
|
|
||||||
|
local current_dependencies=""
|
||||||
|
if [ $replace -eq 0 ]
|
||||||
|
then
|
||||||
|
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||||
|
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
||||||
|
then
|
||||||
|
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
||||||
|
fi
|
||||||
|
|
||||||
|
current_dependencies=${current_dependencies// | /|}
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_install_app_dependencies "${current_dependencies}${package}"
|
||||||
|
}
|
89
scripts/ynh_systemd_action
Normal file
89
scripts/ynh_systemd_action
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||||
|
#
|
||||||
|
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||||
|
# | arg: -n, --service_name= - Name of the service to reload. Default : $app
|
||||||
|
# | arg: -a, --action= - Action to perform with systemctl. Default: start
|
||||||
|
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
|
||||||
|
# If not defined it don't wait until the service is completely started.
|
||||||
|
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
|
||||||
|
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||||
|
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||||
|
ynh_systemd_action() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||||
|
local service_name
|
||||||
|
local action
|
||||||
|
local line_match
|
||||||
|
local length
|
||||||
|
local log_path
|
||||||
|
local timeout
|
||||||
|
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
local service_name="${service_name:-$app}"
|
||||||
|
local action=${action:-start}
|
||||||
|
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||||
|
local length=${length:-20}
|
||||||
|
local timeout=${timeout:-300}
|
||||||
|
|
||||||
|
# Start to read the log
|
||||||
|
if [[ -n "${line_match:-}" ]]
|
||||||
|
then
|
||||||
|
local templog="$(mktemp)"
|
||||||
|
# Following the starting of the app in its log
|
||||||
|
if [ "$log_path" == "systemd" ] ; then
|
||||||
|
# Read the systemd journal
|
||||||
|
journalctl -u $service_name -f --since=-45 > "$templog" &
|
||||||
|
else
|
||||||
|
# Read the specified log file
|
||||||
|
tail -F -n0 "$log_path" > "$templog" &
|
||||||
|
fi
|
||||||
|
# Get the PID of the tail command
|
||||||
|
local pid_tail=$!
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${action^} the service $service_name" >&2
|
||||||
|
systemctl $action $service_name \
|
||||||
|
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||||
|
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||||
|
; false )
|
||||||
|
|
||||||
|
# Start the timeout and try to find line_match
|
||||||
|
if [[ -n "${line_match:-}" ]]
|
||||||
|
then
|
||||||
|
local i=0
|
||||||
|
for i in $(seq 1 $timeout)
|
||||||
|
do
|
||||||
|
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||||
|
if grep --quiet "$line_match" "$templog"
|
||||||
|
then
|
||||||
|
echo "The service $service_name has correctly started." >&2
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo -n "." >&2
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
if [ $i -eq $timeout ]
|
||||||
|
then
|
||||||
|
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||||
|
journalctl --lines=$length -u $service_name >&2
|
||||||
|
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
ynh_clean_check_starting
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean temporary process and file used by ynh_check_starting
|
||||||
|
# (usually used in ynh_clean_setup scripts)
|
||||||
|
#
|
||||||
|
# usage: ynh_clean_check_starting
|
||||||
|
ynh_clean_check_starting () {
|
||||||
|
# Stop the execution of tail.
|
||||||
|
kill -s 15 $pid_tail 2>&1
|
||||||
|
ynh_secure_remove "$templog" 2>&1
|
||||||
|
}
|
Loading…
Reference in a new issue