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

restore usage of systemd-sysconfig

This commit is contained in:
Kay0u 2019-05-24 21:10:58 +02:00
parent a8fcc3f55c
commit aa6387f9c3
No known key found for this signature in database
GPG key ID: ABC3F52576D011D3
8 changed files with 85 additions and 20 deletions

34
conf/systemd-sysconfig Normal file
View file

@ -0,0 +1,34 @@
# source file https://raw.githubusercontent.com/airsonic/airsonic/master/contrib/airsonic-systemd-env
# install documentation : https://airsonic.github.io/docs/install/war-standalone/
# Set the location of the standalone war to use
JAVA_JAR=__FINALPATH__/airsonic.war
# Set any java opts separated by spaces
#JAVA_OPTS=-Xmx700m
# Set a different location for airsonic home.
# If this path is /var/libresonic or even contains "libresonic",
# the data from a previous libresonic can be used as is (i.e. without
# renaming libresonic.properties,db/libresonic*,etc
AIRSONIC_HOME=__FINALPATH__
# Change the port to listen on
PORT=__PORT__
# Change the path that is listened on
CONTEXT_PATH=__PATH__
# Add any java args. These are different than JAVA_OPTS in that
# they are passed directly to the program. The default is empty:
#JAVA_ARGS=
# Note that there are several settings for spring boot, not explicitly listed
# here, but can be used in either JAVA_OPTS or JAVA_ARGS. The full list
# can be found here:
# https://docs.spring.io/spring-boot/docs/1.4.5.RELEASE/reference/htmlsingle/#common-application-properties
# For example to set debug across the board:
#JAVA_ARGS=--debug
# Or to change the ip address that is listened on:
#JAVA_ARGS=--server.address=127.0.0.1

View file

@ -8,13 +8,9 @@ AssertPathExists=__FINALPATH__
[Service]
Type=simple
Environment="JAVA_JAR=__FINALPATH__/airsonic.war"
Environment="JAVA_OPTS=-Xmx700m"
Environment="AIRSONIC_HOME=__FINALPATH__"
Environment="PORT=__PORT__"
Environment="CONTEXT_PATH=__PATH__"
Environment="JAVA_ARGS="
EnvironmentFile=-/etc/default/airsonic
EnvironmentFile=-/etc/default/__APP__
ExecStart=/usr/bin/java \
$JAVA_OPTS \
-Dairsonic.home=${AIRSONIC_HOME} \
@ -24,8 +20,5 @@ ExecStart=/usr/bin/java \
User=__APP__
Group=__APP__
# Force systemd to wait XX sec for the process to start before killing it
# TimeoutStopSec= 180
[Install]
WantedBy=multi-user.target

View file

@ -29,6 +29,7 @@ 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)
#=================================================
# STANDARD BACKUP STEPS
@ -68,6 +69,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_script_progression --message="Backing up systemd configuration..." --weight=1
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="$service_config"
#=================================================
# START SYSTEMD SERVICE

View file

@ -28,6 +28,7 @@ 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)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
@ -91,12 +92,18 @@ fi
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3
ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="../conf/systemd.service"
# 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"
#=================================================
# GENERIC FINALISATION
#=================================================

View file

@ -123,24 +123,35 @@ chown $app: $final_path/transcode
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3
ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
# 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"
# Copy configuration file of airsonic
cp ../conf/airsonic.properties $final_path/airsonic.properties
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# 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

View file

@ -19,6 +19,7 @@ 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
@ -86,12 +87,14 @@ fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
# REMOVE FILES
#=================================================
# Remove the log files
ynh_secure_remove --file="/var/log/$app/"
ynh_secure_remove --file="$service_config"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -30,6 +30,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)
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
@ -107,6 +108,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"
systemctl enable $app.service
#=================================================

View file

@ -22,6 +22,7 @@ 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
@ -49,6 +50,12 @@ if [ -z "$final_path" ]; then
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
final_path="/etc/default/$app"
ynh_app_setting_set --app=$app --key=service_config --value=$service_config
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -155,12 +162,18 @@ ynh_use_logrotate --non-append --logfile="$final_path/airsonic.log"
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="../conf/systemd.service"
# 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"
#=================================================
# GENERIC FINALIZATION
#=================================================