mirror of
https://github.com/YunoHost-Apps/mopidy_ynh.git
synced 2024-09-03 19:46:21 +02:00
Apply last example_ynh
This commit is contained in:
parent
2455004403
commit
5826b7df74
12 changed files with 209 additions and 213 deletions
|
@ -1,9 +1,9 @@
|
|||
|
||||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
is_public=1
|
||||
mpd_ext=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -15,11 +15,8 @@
|
|||
upgrade=1 from_commit=bc421d01d57a273a59287cf7500e94a89de0abed
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&is_public=1
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# http://docs.mopidy.com/
|
||||
|
||||
[core]
|
||||
cache_dir = __CACHE_DIR__
|
||||
$datadir/cache = __DATADIR__/cache
|
||||
#config_dir =
|
||||
data_dir = __DATA_DIR__
|
||||
$datadir/data = __DATADIR__/data
|
||||
#max_tracklist_length = 10000
|
||||
#restore_state = false
|
||||
|
||||
|
@ -168,7 +168,7 @@ retries = 3
|
|||
|
||||
[podcast]
|
||||
enabled = true
|
||||
browse_root = __DATA_DIR__/podcast/bbc.opml
|
||||
browse_root = __DATADIR__/data/podcast/bbc.opml
|
||||
#browse_order = desc
|
||||
#lookup_order = asc
|
||||
#cache_size = 64
|
||||
|
|
|
@ -12,11 +12,6 @@ location /mopidy/ws {
|
|||
|
||||
location __PATH__/ {
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
proxy_pass http://localhost:__PORT__/musicbox_webclient/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
|
@ -27,11 +22,6 @@ location __PATH__/ {
|
|||
|
||||
location /musicbox_webclient/ {
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
proxy_pass http://localhost:__PORT__;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
|
@ -42,11 +32,6 @@ location /musicbox_webclient/ {
|
|||
|
||||
location /local/ {
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
proxy_pass http://localhost:__PORT__;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
|
|
|
@ -5,3 +5,4 @@ bcm5 = play_pause,active_low,250
|
|||
bcm6 = volume_down,active_low,250
|
||||
bcm16 = next,active_low,250
|
||||
bcm20 = volume_up,active_low,250
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="acl build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib \
|
||||
gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly lsb-base \
|
||||
|
|
|
@ -26,11 +26,10 @@ 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)
|
||||
work_dir=$(ynh_app_setting_get --app=$app --key=work_dir)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
# other variables
|
||||
media_dir="/home/yunohost.multimedia/share/Music"
|
||||
work_dir="/home/yunohost.app/$app"
|
||||
cmd_file="/usr/local/bin/mopidyctl"
|
||||
|
||||
#=================================================
|
||||
|
@ -44,6 +43,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"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -62,8 +67,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path=$work_dir
|
||||
|
||||
ynh_backup --src_path="$cmd_file"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -28,6 +28,9 @@ 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=path)
|
||||
y=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
|
@ -94,7 +97,6 @@ fi
|
|||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
|
@ -107,12 +109,6 @@ then
|
|||
ynh_permission_url --permission="main" --add_url="$new_domain/musicbox_webclient" --remove_url="$old_domain/musicbox_webclient"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
|
@ -121,6 +117,7 @@ fi
|
|||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
131
scripts/install
131
scripts/install
|
@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -27,18 +30,12 @@ mpd_port=$YNH_APP_ARG_MPD_EXT
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# other variables
|
||||
final_path="/opt/yunohost/$app"
|
||||
media_dir="/home/yunohost.multimedia/share/Music"
|
||||
work_dir="/home/yunohost.app/$app"
|
||||
conf_file="$final_path/$app.conf"
|
||||
cmd_file="/usr/local/bin/mopidyctl"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/opt/yunohost/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
|
@ -86,17 +83,20 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --groups="audio"
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell --groups="audio"
|
||||
|
||||
#=================================================
|
||||
# INSTALL MOPIDY IN PYTHON ENVIRONMENT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Install in Python environment..." --weight=30
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
myynh_install
|
||||
patch -u $final_path/env/lib/python$python_version/site-packages/mopidy/__main__.py -i ../sources/patches/__main__.patch --forward
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -107,15 +107,38 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
|||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE YUNOHOST DIRECTORIES
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating YunoHost directories..."
|
||||
|
||||
ynh_multimedia_build_main_dir # /home/yunohost.multimedia
|
||||
|
||||
mkdir -p "$work_dir/data" # /home/yunohost.app/mopidy/data
|
||||
mkdir -p "$work_dir/cache" # /home/yunohost.app/mopidy/cache
|
||||
chown -R $app: "$work_dir"
|
||||
#=================================================
|
||||
# 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
|
||||
mkdir -p "$datadir/data" # /home/yunohost.app/mopidy/data
|
||||
mkdir -p "$datadir/cache" # /home/yunohost.app/mopidy/cache
|
||||
|
||||
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..."
|
||||
|
||||
ynh_add_config --template="../conf/app.conf" --destination="$final_path/$app.conf"
|
||||
|
||||
chmod 400 "$final_path/$app.conf"
|
||||
chown $app:$app "$final_path/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -123,34 +146,46 @@ chown -R $app: "$work_dir"
|
|||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
# PROVIDE ADDITIONAL SHELL COMAND
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setup config file..."
|
||||
ynh_script_progression --message="Provide additional shell command..."
|
||||
|
||||
cache_dir=$work_dir/cache
|
||||
data_dir=$work_dir/data
|
||||
cmd_file="/usr/local/bin/mopidyctl"
|
||||
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
|
||||
|
||||
ynh_add_config --template="../conf/app.conf" --destination="$conf_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# PROVIDE EXAMPLES
|
||||
#=================================================
|
||||
|
||||
ynh_store_file_checksum --file="$conf_file"
|
||||
media_dir="/home/yunohost.multimedia/share/Music"
|
||||
|
||||
# provide example m3u-playlist
|
||||
mkdir -p "$datadir/data/m3u/"
|
||||
cp -a ../sources/extra_files/radio_international.m3u "$datadir/data/m3u/radio_international.m3u"
|
||||
|
||||
#provide example podcasts
|
||||
mkdir -p "$datadir/data/podcast"
|
||||
cp -a ../sources/extra_files/bbc.opml "$datadir/data/podcast/bbc.opml"
|
||||
|
||||
#provide example local music file
|
||||
if [ "$(ls -A "$media_dir" 2> /dev/null)" == "" ]; then # copy example.mp3 to mediadir if empty (for test purpose)
|
||||
cp -a ../sources/extra_files/Tryad_Beauty.mp3 "$media_dir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SCAN LOCAL MEDIA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Scan local media directory..."
|
||||
|
||||
"$cmd_file" local scan 2>&1
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -176,7 +211,10 @@ ynh_systemd_action --service_name=$app --action="start"
|
|||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]; then
|
||||
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
|
||||
|
||||
|
@ -191,39 +229,6 @@ ynh_script_progression --message="Reloading NGINX web server..."
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# PROVIDE ADDITIONAL SHELL COMAND
|
||||
#=================================================
|
||||
ynh_script_progression --message="Provide additional shell command..."
|
||||
|
||||
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
|
||||
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
#=================================================
|
||||
# PROVIDE EXAMPLES
|
||||
#=================================================
|
||||
|
||||
# provide example m3u-playlist
|
||||
mkdir -p "$work_dir/data/m3u/"
|
||||
cp -a ../sources/extra_files/radio_international.m3u "$work_dir/data/m3u/radio_international.m3u"
|
||||
|
||||
#provide example podcasts
|
||||
mkdir -p "$work_dir/data/podcast"
|
||||
cp -a ../sources/extra_files/bbc.opml "$work_dir/data/podcast/bbc.opml"
|
||||
|
||||
#provide example local music file
|
||||
if [ "$(ls -A "$media_dir" 2> /dev/null)" == "" ]; then # copy example.mp3 to mediadir if empty (for test purpose)
|
||||
cp -a ../sources/extra_files/Tryad_Beauty.mp3 "$media_dir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SCAN LOCAL MEDIA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Scan local media directory..."
|
||||
|
||||
"$cmd_file" local scan 2>&1
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -17,12 +17,13 @@ ynh_script_progression --message="Loading installation settings..." --weight=4
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
|
||||
|
||||
# other variables
|
||||
cmd_file="/usr/local/bin/mopidyctl"
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
@ -44,14 +45,6 @@ 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=42
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -68,6 +61,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=42
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
@ -82,8 +83,8 @@ fi
|
|||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove a cron file
|
||||
ynh_secure_remove --file="$cmd_file"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -31,7 +31,6 @@ mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
|
|||
|
||||
# other variables
|
||||
media_dir="/home/yunohost.multimedia/share/Music"
|
||||
work_dir="/home/yunohost.app/$app"
|
||||
cmd_file="/usr/local/bin/mopidyctl"
|
||||
|
||||
#=================================================
|
||||
|
@ -39,23 +38,18 @@ cmd_file="/usr/local/bin/mopidyctl"
|
|||
#=================================================
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --groups="audio"
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell --groups="audio"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
|
@ -64,18 +58,40 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..."
|
||||
|
||||
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..." --weight=50
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less 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"
|
||||
|
||||
#=================================================
|
||||
# OPEN PORT
|
||||
#=================================================
|
||||
|
@ -86,12 +102,11 @@ if [ $mpd_port -ne 0 ]; then
|
|||
fi
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=50
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_restore_file --origin_path="$cmd_file" # /usr/local/bin/mopidyctl
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
@ -112,14 +127,6 @@ else
|
|||
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="$work_dir" # /home/yunohost.app/mopidy
|
||||
|
||||
ynh_restore_file --origin_path="$cmd_file" # /usr/local/bin/mopidyctl
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -20,42 +21,19 @@ 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)
|
||||
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
# other variables
|
||||
media_dir="/home/yunohost.multimedia/share/Music"
|
||||
work_dir="/home/yunohost.app/$app"
|
||||
conf_file="$final_path/$app.conf"
|
||||
cmd_file="/usr/local/bin/mopidyctl"
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
#
|
||||
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
|
||||
# of what you may want to do in some cases (e.g. a setting was not defined on
|
||||
# some legacy installs and you therefore want to initiaze stuff during upgrade)
|
||||
#
|
||||
|
||||
# If mpd_port doesn't exist, create it
|
||||
if [ -z "$mpd_port" ]; then
|
||||
mpd_port=0
|
||||
ynh_app_setting_set --app=$app --key=mpd_port --value=$mpd_port
|
||||
fi
|
||||
|
||||
if [ $mpd_port -eq 0 ]; then
|
||||
mpd_state="false"
|
||||
else
|
||||
mpd_state="true"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -79,13 +57,30 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# If mpd_port doesn't exist, create it
|
||||
if [ -z "$mpd_port" ]; then
|
||||
mpd_port=0
|
||||
ynh_app_setting_set --app=$app --key=mpd_port --value=$mpd_port
|
||||
fi
|
||||
|
||||
if [ $mpd_port -eq 0 ]; then
|
||||
mpd_state="false"
|
||||
else
|
||||
mpd_state="true"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --groups="audio"
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell --groups="audio"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -93,6 +88,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
myynh_install
|
||||
fi
|
||||
|
||||
|
@ -100,6 +96,13 @@ chmod 750 "$final_path"
|
|||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=11
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -108,15 +111,27 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=11
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
ynh_add_config --template="../conf/app.conf" --destination="$final_path/$app.conf"
|
||||
|
||||
chmod 400 "$final_path/some_config_file"
|
||||
chown $app:$app "$final_path/some_config_file"
|
||||
|
||||
#=================================================
|
||||
# PROVIDE ADDITIONAL SHELL COMAND
|
||||
#=================================================
|
||||
ynh_script_progression --message="Provide additional shell comand..."
|
||||
|
||||
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
|
||||
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
@ -126,14 +141,7 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=3
|
|||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
cache_dir=$work_dir/cache
|
||||
data_dir=$work_dir/data
|
||||
|
||||
ynh_add_config --template="../conf/app.conf" --destination="$conf_file"
|
||||
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -159,15 +167,6 @@ ynh_script_progression --message="Reloading NGINX web server..."
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# PROVIDE ADDITIONAL SHELL COMAND
|
||||
#=================================================
|
||||
ynh_script_progression --message="Provide additional shell comand..."
|
||||
|
||||
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
|
||||
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue