mirror of
https://github.com/YunoHost-Apps/audiobookshelf_ynh.git
synced 2024-09-03 18:06:19 +02:00
commit
5e417c66c6
8 changed files with 44 additions and 184 deletions
|
@ -1,6 +1,6 @@
|
|||
NODE_ENV=production
|
||||
PORT=__PORT__
|
||||
HOST=localhost
|
||||
HOST=127.0.0.1
|
||||
CONFIG_PATH=__DATA_DIR__/config
|
||||
AUDIOBOOK_PATH=__DATA_DIR__/audiobooks
|
||||
METADATA_PATH=__DATA_DIR__/metadata
|
||||
|
|
|
@ -16,12 +16,12 @@ userdoc = "https://www.audiobookshelf.org/docs"
|
|||
code = "https://github.com/advplyr/audiobookshelf"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.1.15"
|
||||
yunohost = ">= 11.2"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
ldap = false
|
||||
sso = false
|
||||
disk = "50M"
|
||||
disk = "50M"
|
||||
ram.build = "50M"
|
||||
ram.runtime = "50M"
|
||||
|
||||
|
@ -41,8 +41,8 @@ ram.runtime = "50M"
|
|||
autoupdate.strategy = "latest_github_tag"
|
||||
|
||||
[resources.sources.tone]
|
||||
url = "https://github.com/sandreas/tone/archive/refs/tags/v0.1.6.tar.gz"
|
||||
sha256 = "da0f063dccb9a32e292fb816ec4b86e657d77251a8ffb265a3456e96b3d05a92"
|
||||
url = "https://github.com/sandreas/tone/archive/refs/tags/v0.1.7.tar.gz"
|
||||
sha256 = "9693d8aa74454607fe1d79592c9c18a6da4c73a8fa67d4a414ec9c02c6dde61a"
|
||||
autoupdate.strategy = "latest_github_release"
|
||||
autoupdate.upstream = "https://github.com/sandreas/tone"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# dependencies used by the app
|
||||
|
||||
# nodejs version
|
||||
nodejs_version=16
|
||||
nodejs_version=22
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -28,23 +28,13 @@ ynh_backup --src_path="$install_dir"
|
|||
ynh_backup --src_path="$data_dir" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -15,9 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@7.21.1
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -28,25 +26,13 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
|||
ynh_setup_source --dest_dir="$install_dir" --source_id="main"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="tone"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..." --weight=10
|
||||
|
||||
ynh_use_nodejs
|
||||
|
||||
pushd $install_dir/client
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm cache clean --force
|
||||
|
@ -57,50 +43,30 @@ pushd $install_dir
|
|||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci --only=production
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --weight=3
|
||||
|
||||
mkdir -p $data_dir
|
||||
|
||||
chmod 750 "$data_dir"
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R $app:www-data "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
||||
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
||||
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$app "$install_dir/.env"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
|
||||
|
||||
yunohost service add $app --description="Audiobook server" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -10,10 +10,9 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# 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
|
||||
|
@ -22,45 +21,18 @@ then
|
|||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=4
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
|
|
|
@ -17,18 +17,6 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=10
|
|||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@7.21.1
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -36,8 +24,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
|
@ -47,52 +33,31 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
|
||||
mkdir -p $data_dir
|
||||
|
||||
chmod 750 "$data_dir"
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R $app:www-data "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chown -R $app: "/var/log/$app"
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Audiobook server" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Listening on"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -16,14 +16,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=10
|
|||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@7.21.1
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -37,7 +30,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=3
|
||||
|
||||
# If data_dir doesn't exist, create it
|
||||
if [ -z $data_dir ]; then
|
||||
|
@ -56,28 +49,16 @@ fi
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="tone"
|
||||
fi
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="tone"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
|
@ -85,54 +66,40 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Upgrading app..." --weight=10
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_use_nodejs
|
||||
pushd $install_dir/client
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm cache clean --force
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run generate
|
||||
popd
|
||||
|
||||
pushd $install_dir/client
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm cache clean --force
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run generate
|
||||
popd
|
||||
|
||||
pushd $install_dir
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci --only=production
|
||||
popd
|
||||
fi
|
||||
pushd $install_dir
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci --only=production
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
||||
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
||||
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$app "$install_dir/.env"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Audiobook server" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue