diff --git a/README.md b/README.md index fc017de..afba1fc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # 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) *[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 -**Shipped version:** 1.10.4~ynh1 +**Shipped version:** 1.10.4~ynh2 **Demo:** https://streama.demo-version.net ## Screenshots -![](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg) -![](./doc/screenshots/screenshot.jpg) +![Screenshot of Streama](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg) +![Screenshot of Streama](./doc/screenshots/screenshot.jpg) ## Disclaimers / important information @@ -72,21 +72,22 @@ This can be changed in settings. ## Documentation and resources -* Official app website: https://streamaserver.org/ -* Official admin documentation: https://docs.streama-project.com/ -* Upstream app code repository: https://github.com/streamaserver/streama -* YunoHost documentation for this app: https://yunohost.org/app_streama -* Report a bug: https://github.com/YunoHost-Apps/streama_ynh/issues +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info 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. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug or 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 \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index b423b78..bd91b80 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # 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) *[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. 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é -**Version incluse :** 1.10.4~ynh1 +**Version incluse :** 1.10.4~ynh2 **Démo :** https://streama.demo-version.net ## Captures d'écran -![](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg) -![](./doc/screenshots/screenshot.jpg) +![Capture d'écran de Streama](./doc/screenshots/96721577-9f216280-13ac-11eb-935c-d083f4b010a2.jpg) +![Capture d'écran de Streama](./doc/screenshots/screenshot.jpg) ## Avertissements / informations importantes @@ -66,21 +70,22 @@ Ceci pourra être changé dans les paramètres. ## Documentations et ressources -* Site officiel de l'app : https://streamaserver.org/ -* Documentation officielle de l'admin : https://docs.streama-project.com/ -* Dépôt de code officiel de l'app : https://github.com/streamaserver/streama -* Documentation YunoHost pour cette app : https://yunohost.org/app_streama -* Signaler un bug : https://github.com/YunoHost-Apps/streama_ynh/issues +* Site officiel de l'app : +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs 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. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/streama_ynh/tree/testing --debug ou 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 \ No newline at end of file +**Plus d'infos sur le packaging d'applications :** diff --git a/check_process b/check_process index 241ec0c..006161a 100644 --- a/check_process +++ b/check_process @@ -1,24 +1,23 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/" is_public=1 ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 setup_root=1 setup_nourl=0 setup_private=1 setup_public=1 upgrade=1 + # 1.9.3~ynh1 upgrade=1 from_commit=3a02114f50e785722bc592cbcc33f92bf070b1c1 + # 1.10.4~ynh1 + upgrade=1 from_commit=4184ecd823b50bdf1a306d24a0ad9b5ccd18c103 backup_restore=1 multi_instance=0 + port_already_use=0 change_url=0 ;;; Options Email= 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& diff --git a/conf/convert.sh b/conf/convert.sh index 3afeb22..f4ac63b 100644 --- a/conf/convert.sh +++ b/conf/convert.sh @@ -34,8 +34,8 @@ while IFS= read -r -d '' file do ffmpeg -nostdin -i "$file" -c:v libx264 -c:a aac "${file%.*}.mp4" rm -f "$file" -done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) -chown -R streama:users /home/yunohost.app/streama/upload/ +done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) +chown -R streama:users __DATADIR__/upload/ } avidemux_convert(){ @@ -46,8 +46,8 @@ while IFS= read -r -d '' file do avidemux3_cli --load "$file" --output-format "$output_format" --video-codec "$video_codec" --audio-codec "$audio_codec" --save "${file%.*}.mp4" --quit rm -f "$file" -done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) -chown -R streama:users /home/yunohost.app/streama/upload/ +done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) +chown -R streama:users __DATADIR__/upload/ } mencoder_convert(){ @@ -55,8 +55,8 @@ while IFS= read -r -d '' file do mencoder "$file" -o "${file%.*}.mp4" -ovc lavc -oac lavc rm -f "$file" -done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) -chown -R streama:users /home/yunohost.app/streama/upload/ +done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) +chown -R streama:users __DATADIR__/upload/ } avconv_convert(){ @@ -64,8 +64,8 @@ while IFS= read -r -d '' file do avconv -i "$file" -c:v h264 -c:a aac "${file%.*}.mp4" rm -f "$file" -done < <(find /home/yunohost.app/streama/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) -chown -R streama:users /home/yunohost.app/streama/upload/ +done < <(find __DATADIR__/upload/ -name '*.mkv' -print0 -o -name '*.avi' -print0) +chown -R streama:users __DATADIR__/upload/ } parse_args () diff --git a/conf/nginx.conf b/conf/nginx.conf index ed31f01..5c71cc9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,19 +1,20 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; - - #WebSocket Support - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $http_connection; - - # Upload Size. - client_max_body_size 128g; + proxy_pass http://127.0.0.1:__PORT__; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + + #WebSocket Support + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; + + # Upload Size. + client_max_body_size 128g; } diff --git a/conf/systemd.service b/conf/systemd.service index e797155..5ececcb 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ UMask=000 -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__FINALPATH__/ ExecStart=/usr/bin/java -Djava.awt.headless=true -Dserver.port=__PORT__ -jar streama.jar RestartSec=30 Restart=always diff --git a/manifest.json b/manifest.json index a616613..2d66e91 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self hosted streaming media server", "fr": "Serveur de streaming auto-hébergé" }, - "version": "1.10.4~ynh1", + "version": "1.10.4~ynh2", "url": "https://streamaserver.org/", "upstream": { "license": "MIT", @@ -29,7 +29,8 @@ "mysql" ], "arguments": { - "install": [{ + "install": [ + { "name": "domain", "type": "domain" }, diff --git a/scripts/backup b/scripts/backup index d8502a3..fe4a02b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # 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 /usr/share/yunohost/helpers @@ -22,8 +23,9 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app="$app" --key=final_path) -domain=$(ynh_app_setting_get --app="$app" --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +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 @@ -36,6 +38,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -52,4 +60,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # 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)." diff --git a/scripts/install b/scripts/install index 7ad3a38..5d39c48 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,6 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -# Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url="/" 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 #================================================= +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url +#================================================= +# STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= ynh_script_progression --message="Finding an available port..." --weight=3 -# Find a free port +# Find an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." +ynh_script_progression --message="Installing 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 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 #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 +# Create a dedicated systemd config ynh_add_systemd_config #================================================= # 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 #================================================= @@ -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 # 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 #================================================= 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 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi @@ -150,4 +172,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Streama completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index bf512bb..2ae527c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,17 +19,18 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # 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`) if ynh_exec_warn_less yunohost service status $app >/dev/null 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 fi @@ -41,22 +42,25 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated 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 #================================================= -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 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 #================================================= @@ -65,6 +69,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated 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 #================================================= @@ -79,4 +91,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of Streama completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index ccc3212..06a97ee 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # 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 /usr/share/yunohost/helpers @@ -22,29 +23,25 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=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 #================================================= 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 -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -56,7 +53,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # 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" @@ -65,14 +62,46 @@ chmod -R o-rwx "$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 +#================================================= +# 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 #================================================= @@ -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_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 @@ -108,4 +137,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Streama" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 9987213..42c28b4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,34 +14,45 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading installation settings..." --weight=1 -# See comments in install script app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) #================================================= # 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 ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + ynh_clean_check_starting + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script 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 #================================================= @@ -54,15 +65,11 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# 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" - +# If db_name doesn't exist, create it +if [ -z "$datadir" ]; then + datadir=/home/yunohost.app/$app + ynh_app_setting_set --app=$app --key=datadir --value=$datadir +fi #================================================= # CREATE DEDICATED USER #================================================= @@ -88,6 +95,13 @@ chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" chmod +x $final_path/streama.jar +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=5 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -97,30 +111,27 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - 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 #================================================= -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 #================================================= # 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 #================================================= @@ -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 -# 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 @@ -147,4 +157,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of Streama completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last