1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/airsonic_ynh.git synced 2024-09-03 18:06:14 +02:00

Merge pull request #45 from YunoHost-Apps/fix-linter

Fix linter warnings
This commit is contained in:
Éric Gaspar 2021-04-17 22:46:28 +02:00 committed by GitHub
commit c72c733bbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 70 additions and 131 deletions

View file

@ -43,8 +43,8 @@ How to configure this app: by an admin panel.
## Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/airsonic%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/airsonic/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/airsonic%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/airsonic/)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/airsonic.svg)](https://ci-apps.yunohost.org/ci/apps/airsonic/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/airsonic.svg)](https://ci-apps-arm.yunohost.org/ci/apps/airsonic/)
## Links

View file

@ -4,6 +4,7 @@
path="/path" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
port="666" (PORT)
; Checks
pkg_linter=1
setup_sub_dir=1
@ -20,3 +21,7 @@
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -14,7 +14,7 @@
"email": "gofannon@riseup.net"
},
"requirements": {
"yunohost": ">= 3.8.1"
"yunohost": ">= 4.1.7"
},
"multi_instance": true,
"services": [
@ -25,29 +25,17 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Airsonic",
"fr": "Choisissez un nom de domaine pour Airsonic"
},
"example": "example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Airsonic",
"fr": "Choisissez un chemin pour Airsonic"
},
"example": "/airsonic",
"default": "/airsonic"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez ladministrateur"
},
"help": {
"en": "This user will have full control on this application and will be able to configure it.",
"fr": "Cet utilisateur aura le controle total de l'application et pourra la configurer."
@ -57,10 +45,6 @@
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
}
]

View file

@ -11,12 +11,6 @@
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Validation
## Package_check results
---
- [ ] **Code review**
- [ ] **Approval (LGTM)**
*Code review and approval have to be from a member of @YunoHost/apps group*
- **CI succeeded** :
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/airsonic_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/airsonic_ynh%20PR-NUM-/)
*Please replace '-NUM-' in this link by the PR number.*
When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*

View file

@ -28,7 +28,6 @@ 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)
service_config=$(ynh_app_setting_get --app=$app --key=service_config)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -60,13 +59,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="$service_config"
ynh_backup --src_path="/etc/default/$app"
#=================================================
# BACKUP DATA
#=================================================
ynh_backup --src_path="/home/yunohost.$app" --is_big
ynh_backup --src_path="/home/yunohost.app/$app" --is_big
#=================================================
# END OF SCRIPT

View file

@ -28,9 +28,26 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
service_config=$(ynh_app_setting_get --app=$app --key=service_config)
# service_config=$(ynh_app_setting_get --app=$app --key=service_config)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
@ -95,14 +112,7 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=3
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_backup_if_checksum_is_different --file="$service_config"
# Copy config. template to right location
cp ../conf/systemd-sysconfig $service_config
ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config"
ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config"
ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config"
ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app"
#=================================================
# GENERIC FINALISATION
@ -111,7 +121,7 @@ ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=12
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/airsonic.log" --line_match="Started Application in"
ynh_systemd_action --service_name=$app --action=start --log_path="$final_path/airsonic.log" --line_match="Started Application in"
#=================================================
# RELOAD NGINX

View file

@ -6,6 +6,10 @@
# IMPORT GENERIC HELPERS
#=================================================
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
sleep 60
fi
source _common.sh
source /usr/share/yunohost/helpers
@ -49,7 +53,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=2
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=admin --value=$admin
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
# STANDARD MODIFICATIONS
@ -100,14 +103,14 @@ ynh_system_user_create --username=$app
# CREATE DIRECTORIES
#=================================================
mkdir -p /home/yunohost.$app/{Podcasts,Playlists}
mkdir -p /home/yunohost.app/$app/{Podcasts,Playlists}
#=================================================
# SECURING FILES AND DIRECTORIES
#=================================================
chown -R $app:www-data /home/yunohost.$app/
chmod -R 764 /home/yunohost.$app
chown -R $app:www-data /home/yunohost.app/$app
chmod 764 /home/yunohost.app/$app
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
@ -115,8 +118,8 @@ chmod -R 764 /home/yunohost.$app
ynh_script_progression --message="Adding multimedia directories..." --weight=3
ynh_multimedia_build_main_dir
ynh_multimedia_addfolder --source_dir="/home/yunohost.$app/Podcasts" --dest_dir="share/Podcasts"
ynh_multimedia_addfolder --source_dir="/home/yunohost.$app/Playlists" --dest_dir="share/Playlists"
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Podcasts" --dest_dir="share/Podcasts"
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Playlists" --dest_dir="share/Playlists"
# Allow airsonic to write into these directories
ynh_multimedia_addaccess $app
@ -155,28 +158,12 @@ ynh_add_systemd_config
# MODIFY CONFIG FILES
#=================================================
# Path of the systemd service configuration
service_config="/etc/default/$app"
ynh_app_setting_set --app=$app --key=service_config --value=$service_config
# Copy config. template to right location
cp ../conf/systemd-sysconfig $service_config
ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config"
ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config"
ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config"
ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app"
# Copy configuration file of airsonic
cp ../conf/airsonic.properties $final_path/airsonic.properties
#=================================================
# STORE THE CONFIG FILES CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/airsonic.properties"
ynh_store_file_checksum --file="$service_config"
#=================================================
# GENERIC FINALIZATION
@ -207,21 +194,20 @@ yunohost service add $app --description="Airsonic daemon" --log="$final_path/$ap
ynh_script_progression --message="Starting a systemd service..." --weight=12
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/$app.log" --line_match="Started Application in"
ynh_systemd_action --service_name=$app --action=start --log_path="$final_path/$app.log" --line_match="Started Application in"
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Set the app as temporarily public for curl call
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
# Reload SSOwat config
yunohost app ssowatconf
# Set the app as temporarily public for cURL call
ynh_permission_update --permission="main" --add="visitors"
# Reload Nginx
ynh_systemd_action --service_name=nginx --action=reload
ynh_script_progression --message="Finalizing installation..." --weight=10
mailadmin=$(ynh_user_get_info --username=$admin --key=mail)
#http://www.subsonic.org/pages/api.jsp
@ -250,12 +236,6 @@ token=$(echo -n $passwordAdmin$salt | md5sum | awk '{print $1}')
ynh_local_curl "/rest/createUser.view" "u=admin" "t=$token" "s=$salt" "username=$admin" "password=a" "v=$VERSION" "c=myapp" "email=$mailadmin" "adminRole=Yes" "ldapAuthenticated=Yes" "settingsRole=Yes" "streamRole=Yes" "jukeboxRole=Yes" "downloadRole=Yes" "uploadRole=Yes" "playlistRole=Yes" "coverArtRole=Yes" "commentRole=Yes" "podcastRole=Yes" "shareRole=Yes" "videoConversionRole=Yes"
# Remove the public access
if [ $is_public -eq 0 ]
then
ynh_app_setting_delete --app=$app --key=skipped_uris
fi
#=================================================
# USE MULTIMEDIA
#=================================================
@ -272,13 +252,12 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=2
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
# Make app public if necessary or protect it
if [ $is_public -eq 0 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
ynh_permission_update --permission="main" --remove="visitors"
fi
#=================================================

View file

@ -19,7 +19,6 @@ 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)
service_config=$(ynh_app_setting_get --app=$app --key=service_config)
#=================================================
# STANDARD REMOVE
@ -80,7 +79,7 @@ ynh_remove_logrotate
# REMOVE FILES
#=================================================
ynh_secure_remove --file="$service_config"
ynh_secure_remove --file="/etc/default/$app"
#=================================================
# GENERIC FINALIZATION

View file

@ -30,7 +30,6 @@ 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)
service_config=$(ynh_app_setting_get --app=$app --key=service_config)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -108,7 +107,7 @@ chown $app: $final_path/transcode
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore_file --origin_path="$service_config"
ynh_restore_file --origin_path="/etc/default/$app"
systemctl enable $app.service --quiet
#=================================================
@ -135,15 +134,15 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
ynh_restore_file --origin_path="/home/yunohost.$app" --not_mandatory
ynh_restore_file --origin_path="/home/yunohost.app/$app" --not_mandatory
#=================================================
# RESTORE USER RIGHTS
#=================================================
mkdir -p /home/yunohost.$app/{Podcasts,Playlists}
chown -R $app:www-data /home/yunohost.$app/
chmod -R 764 /home/yunohost.$app
mkdir -p /home/yunohost.app/$app/{Podcasts,Playlists}
chown -R $app:www-data /home/yunohost.app/$app
chmod -R 764 /home/yunohost.app/$app
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
@ -151,8 +150,8 @@ chmod -R 764 /home/yunohost.$app
ynh_script_progression --message="Adding multimedia directories..." --weight=3
ynh_multimedia_build_main_dir
ynh_multimedia_addfolder --source_dir="/home/yunohost.$app/Podcasts" --dest_dir="share/Podcasts"
ynh_multimedia_addfolder --source_dir="/home/yunohost.$app/Playlists" --dest_dir="share/Playlists"
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Podcasts" --dest_dir="share/Podcasts"
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Playlists" --dest_dir="share/Playlists"
# Allow airsonic to write into these directories
ynh_multimedia_addaccess $app

View file

@ -19,10 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
service_config=$(ynh_app_setting_get --app=$app --key=service_config)
#=================================================
# CHECK VERSION
@ -35,25 +32,17 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/opt/yunohost/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# If service_config doesn't exist, create it
if [ -z "$service_config" ]; then
service_config="/etc/default/$app"
ynh_app_setting_set --app=$app --key=service_config --value=$service_config
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
@ -122,14 +111,14 @@ ynh_system_user_create --username=$app
# CREATE DIRECTORIES
#=================================================
mkdir -p /home/yunohost.$app/{Podcasts,Playlists}
mkdir -p /home/yunohost.app/$app/{Podcasts,Playlists}
#=================================================
# SECURING FILES AND DIRECTORIES
#=================================================
chown -R $app:www-data /home/yunohost.$app/
chmod -R 764 /home/yunohost.$app
chown -R $app:www-data /home/yunohost.app/$app
chmod 764 /home/yunohost.app/$app
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
@ -137,8 +126,8 @@ chmod -R 764 /home/yunohost.$app
ynh_script_progression --message="Adding multimedia directories..." --weight=3
ynh_multimedia_build_main_dir
ynh_multimedia_addfolder --source_dir="/home/yunohost.$app/Podcasts" --dest_dir="share/Podcasts"
ynh_multimedia_addfolder --source_dir="/home/yunohost.$app/Playlists" --dest_dir="share/Playlists"
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Podcasts" --dest_dir="share/Podcasts"
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Playlists" --dest_dir="share/Playlists"
# Allow airsonic to write into these directories
ynh_multimedia_addaccess $app
@ -200,14 +189,7 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_backup_if_checksum_is_different --file="$service_config"
# Copy config. template to right location
cp ../conf/systemd-sysconfig $service_config
ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config"
ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config"
ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config"
ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app"
#=================================================
# GENERIC FINALIZATION
@ -224,18 +206,6 @@ chown -R $app: $final_path
yunohost service add $app --description="Airsonic daemon" --log="$final_path/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
# 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=$app --key=unprotected_uris --value="/"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================