1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/streama_ynh.git synced 2024-09-03 20:26:30 +02:00

Merge pull request #38 from YunoHost-Apps/testing

Apply example_ynh
This commit is contained in:
yalh76 2022-07-03 17:59:19 +02:00 committed by GitHub
commit 4f3fb6ab05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 217 additions and 129 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Streama for YunoHost # Streama for YunoHost
[![Integration level](https://dash.yunohost.org/integration/streama.svg)](https://dash.yunohost.org/appci/app/streama) ![](https://ci-apps.yunohost.org/ci/badges/streama.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/streama.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/streama.svg)](https://dash.yunohost.org/appci/app/streama) ![Working status](https://ci-apps.yunohost.org/ci/badges/streama.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/streama.maintain.svg)
[![Install Streama with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=streama) [![Install Streama with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=streama)
*[Lire ce readme en français.](./README_fr.md)* *[Lire ce readme en français.](./README_fr.md)*
@ -17,14 +17,14 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Self hosted streaming media server Self hosted streaming media server
**Shipped version:** 1.10.4~ynh1 **Shipped version:** 1.10.4~ynh2
**Demo:** https://streama.demo-version.net **Demo:** https://streama.demo-version.net
## Screenshots ## Screenshots
![](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg) ![Screenshot of Streama](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg)
![](./doc/screenshots/screenshot.jpg) ![Screenshot of Streama](./doc/screenshots/screenshot.jpg)
## Disclaimers / important information ## Disclaimers / important information
@ -72,21 +72,22 @@ This can be changed in settings.
## Documentation and resources ## Documentation and resources
* Official app website: https://streamaserver.org/ * Official app website: <https://streamaserver.org/>
* Official admin documentation: https://docs.streama-project.com/ * Official admin documentation: <https://docs.streama-project.com/>
* Upstream app code repository: https://github.com/streamaserver/streama * Upstream app code repository: <https://github.com/streamaserver/streama>
* YunoHost documentation for this app: https://yunohost.org/app_streama * YunoHost documentation for this app: <https://yunohost.org/app_streama>
* Report a bug: https://github.com/YunoHost-Apps/streama_ynh/issues * Report a bug: <https://github.com/YunoHost-Apps/streama_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/streama_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/streama_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug
or or
sudo yunohost app upgrade streama -u https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug sudo yunohost app upgrade streama -u https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps **More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Streama pour YunoHost # Streama pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/streama.svg)](https://dash.yunohost.org/appci/app/streama) ![](https://ci-apps.yunohost.org/ci/badges/streama.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/streama.maintain.svg) [![Niveau d'intégration](https://dash.yunohost.org/integration/streama.svg)](https://dash.yunohost.org/appci/app/streama) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/streama.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/streama.maintain.svg)
[![Installer Streama avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=streama) [![Installer Streama avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=streama)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Streama rapidement et simplement sur un serveur YunoHost. > *Ce package vous permet d'installer Streama rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -13,14 +17,14 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Serveur de streaming auto-hébergé Serveur de streaming auto-hébergé
**Version incluse :** 1.10.4~ynh1 **Version incluse :** 1.10.4~ynh2
**Démo :** https://streama.demo-version.net **Démo :** https://streama.demo-version.net
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg) ![Capture d'écran de Streama](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg)
![](./doc/screenshots/screenshot.jpg) ![Capture d'écran de Streama](./doc/screenshots/screenshot.jpg)
## Avertissements / informations importantes ## Avertissements / informations importantes
@ -66,21 +70,22 @@ Ceci pourra être changé dans les paramètres.
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : https://streamaserver.org/ * Site officiel de l'app : <https://streamaserver.org/>
* Documentation officielle de l'admin : https://docs.streama-project.com/ * Documentation officielle de l'admin : <https://docs.streama-project.com/>
* Dépôt de code officiel de l'app : https://github.com/streamaserver/streama * Dépôt de code officiel de l'app : <https://github.com/streamaserver/streama>
* Documentation YunoHost pour cette app : https://yunohost.org/app_streama * Documentation YunoHost pour cette app : <https://yunohost.org/app_streama>
* Signaler un bug : https://github.com/YunoHost-Apps/streama_ynh/issues * Signaler un bug : <https://github.com/YunoHost-Apps/streama_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/streama_ynh/tree/testing). Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/streama_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade streama -u https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug sudo yunohost app upgrade streama -u https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps **Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,24 +1,23 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/"
is_public=1 is_public=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=0
setup_root=1 setup_root=1
setup_nourl=0 setup_nourl=0
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 1.9.3~ynh1
upgrade=1 from_commit=3a02114f50e785722bc592cbcc33f92bf070b1c1 upgrade=1 from_commit=3a02114f50e785722bc592cbcc33f92bf070b1c1
# 1.10.4~ynh1
upgrade=1 from_commit=4184ecd823b50bdf1a306d24a0ad9b5ccd18c103
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0
change_url=0 change_url=0
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
; commit=3a02114f50e785722bc592cbcc33f92bf070b1c1
name=Upgrade to 1.9.3 (#28)
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -34,8 +34,8 @@ while IFS= read -r -d '' file
do do
ffmpeg -nostdin -i "$file" -c:v libx264 -c:a aac "${file%.*}.mp4" ffmpeg -nostdin -i "$file" -c:v libx264 -c:a aac "${file%.*}.mp4"
rm -f "$file" rm -f "$file"
done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0)
chown -R streama:users /home/yunohost.app/streama/upload/ chown -R streama:users __DATADIR__/upload/
} }
avidemux_convert(){ avidemux_convert(){
@ -46,8 +46,8 @@ while IFS= read -r -d '' file
do do
avidemux3_cli --load "$file" --output-format "$output_format" --video-codec "$video_codec" --audio-codec "$audio_codec" --save "${file%.*}.mp4" --quit avidemux3_cli --load "$file" --output-format "$output_format" --video-codec "$video_codec" --audio-codec "$audio_codec" --save "${file%.*}.mp4" --quit
rm -f "$file" rm -f "$file"
done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0)
chown -R streama:users /home/yunohost.app/streama/upload/ chown -R streama:users __DATADIR__/upload/
} }
mencoder_convert(){ mencoder_convert(){
@ -55,8 +55,8 @@ while IFS= read -r -d '' file
do do
mencoder "$file" -o "${file%.*}.mp4" -ovc lavc -oac lavc mencoder "$file" -o "${file%.*}.mp4" -ovc lavc -oac lavc
rm -f "$file" rm -f "$file"
done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0)
chown -R streama:users /home/yunohost.app/streama/upload/ chown -R streama:users __DATADIR__/upload/
} }
avconv_convert(){ avconv_convert(){
@ -64,8 +64,8 @@ while IFS= read -r -d '' file
do do
avconv -i "$file" -c:v h264 -c:a aac "${file%.*}.mp4" avconv -i "$file" -c:v h264 -c:a aac "${file%.*}.mp4"
rm -f "$file" rm -f "$file"
done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0)
chown -R streama:users /home/yunohost.app/streama/upload/ chown -R streama:users __DATADIR__/upload/
} }
parse_args () parse_args ()

View file

@ -1,3 +1,4 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__; proxy_pass http://127.0.0.1:__PORT__;

View file

@ -7,7 +7,7 @@ Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
UMask=000 UMask=000
WorkingDirectory=__FINALPATH__ WorkingDirectory=__FINALPATH__/
ExecStart=/usr/bin/java -Djava.awt.headless=true -Dserver.port=__PORT__ -jar streama.jar ExecStart=/usr/bin/java -Djava.awt.headless=true -Dserver.port=__PORT__ -jar streama.jar
RestartSec=30 RestartSec=30
Restart=always Restart=always

View file

@ -6,7 +6,7 @@
"en": "Self hosted streaming media server", "en": "Self hosted streaming media server",
"fr": "Serveur de streaming auto-hébergé" "fr": "Serveur de streaming auto-hébergé"
}, },
"version": "1.10.4~ynh1", "version": "1.10.4~ynh2",
"url": "https://streamaserver.org/", "url": "https://streamaserver.org/",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",
@ -29,7 +29,8 @@
"mysql" "mysql"
], ],
"arguments": { "arguments": {
"install": [{ "install": [
{
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
}, },

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -22,8 +23,9 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app="$app" --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -36,6 +38,12 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
@ -52,4 +60,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for Streama. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -23,7 +23,6 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
@ -44,23 +43,26 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=3 ynh_script_progression --message="Finding an available port..." --weight=3
# Find a free port # Find an available port
port=$(ynh_find_port --port=8095) port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -94,25 +96,43 @@ ynh_script_progression --message="Configuring NGNX web server..." --weight=3
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
# Set permissions to app files
mkdir -p $final_path/data
ln -s $datadir $final_path/data/streama
ynh_add_config --template="../conf/convert.sh" --destination="/usr/bin/convert_movies"
chmod +x "/usr/bin/convert_movies"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
mkdir -p $final_path/data/streama
ln -s $final_path/data/streama /home/yunohost.app/streama
ynh_add_config --template="../conf/convert.sh" --destination="/usr/bin/convert_movies"
chmod +x "/usr/bin/convert_movies"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -126,16 +146,18 @@ yunohost service add $app --description="Streama media system" --log="/var/log/$
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Grails application running at" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Grails application running at"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
fi fi
@ -150,4 +172,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of Streama completed" --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -19,17 +19,18 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing Streama service integration..." --weight=1 ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app yunohost service remove $app
fi fi
@ -41,22 +42,25 @@ ynh_script_progression --message="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 DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=11
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing Streama main directory..." --weight=1 ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -65,6 +69,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=11
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -79,4 +91,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of Streama completed" --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -22,29 +23,25 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=3 ynh_script_progression --message="Validating restoration parameters..." --weight=3
test ! -d "$final_path" || ynh_die --message="There is already a directory: $final_path " test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
@ -56,7 +53,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring Streama main directory..." --weight=2 ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -65,14 +62,46 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#================================================= #=================================================
# INSTALL DEPENDENCIES # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_script_progression --message="Restoring the data directory..."
ynh_install_app_dependencies $pkg_dependencies ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
# Set permissions to app files
mkdir -p $final_path/data
ln -s $datadir $final_path/data/streama
ynh_add_config --template="../conf/convert.sh" --destination="/usr/bin/convert_movies"
chmod +x "/usr/bin/convert_movies"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -93,7 +122,7 @@ yunohost service add $app --description="Streama media system" --log="/var/log/$
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Grails application running at" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Grails application running at"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -108,4 +137,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for Streama" --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -14,34 +14,45 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
# See comments in install script
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up Streama before upgrading (may take a while)..." --weight=2 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2
# 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 ynh_clean_check_starting
# Restore it if the upgrade fails
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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=20
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -54,15 +65,11 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
#================================================= # If db_name doesn't exist, create it
# STANDARD UPGRADE STEPS if [ -z "$datadir" ]; then
#================================================= datadir=/home/yunohost.app/$app
# STOP SYSTEMD SERVICE ynh_app_setting_set --app=$app --key=datadir --value=$datadir
#================================================= fi
ynh_script_progression --message="Stopping a systemd service..." --weight=20
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -88,6 +95,13 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
chmod +x $final_path/streama.jar chmod +x $final_path/streama.jar
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -97,30 +111,27 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # SPECIFIC UPGRADE
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5 # UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_install_app_dependencies $pkg_dependencies # Set permissions to app files
mkdir -p $final_path/data
ynh_add_config --template="../conf/convert.sh" --destination="/usr/bin/convert_movies"
chmod +x "/usr/bin/convert_movies"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3 ynh_script_progression --message="Upgrading systemd configuration..." --weight=3
# Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
mkdir -p $final_path/data/streama
ynh_add_config --template="../conf/convert.sh" --destination="/usr/bin/convert_movies"
chmod +x "/usr/bin/convert_movies"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -133,8 +144,7 @@ yunohost service add $app --description="Streama media system" --log="/var/log/$
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=5 ynh_script_progression --message="Starting a systemd service..." --weight=5
# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Grails application running at"
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Grails application running at"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
@ -147,4 +157,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of Streama completed" --last ynh_script_progression --message="Upgrade of $app completed" --last