mirror of
https://github.com/YunoHost-Apps/pixelfed_ynh.git
synced 2024-09-03 20:06:04 +02:00
remove others_var
This commit is contained in:
parent
cda2a2c469
commit
e9fdad3413
3 changed files with 26 additions and 49 deletions
|
@ -149,7 +149,7 @@ chown $app:$app "$final_path/.env"
|
||||||
ynh_script_progression --message="Configuring a supervisor service..."
|
ynh_script_progression --message="Configuring a supervisor service..."
|
||||||
|
|
||||||
# Create a dedicated supervisor config
|
# Create a dedicated supervisor config
|
||||||
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion"
|
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEPLOY
|
# DEPLOY
|
||||||
|
|
|
@ -96,7 +96,7 @@ if dpkg --compare-versions "0.10.9~ynh2" gt "$(ynh_read_manifest --manifest="/et
|
||||||
|
|
||||||
ynh_script_progression --message="Configuring a supervisor service..."
|
ynh_script_progression --message="Configuring a supervisor service..."
|
||||||
phpversion=$YNH_PHP_VERSION
|
phpversion=$YNH_PHP_VERSION
|
||||||
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion"
|
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf
|
||||||
|
|
||||||
ynh_script_progression --message="Starting a supervisor service..."
|
ynh_script_progression --message="Starting a supervisor service..."
|
||||||
ynh_supervisor_action --service_name="${app}-horizon" --action="start" --log_path="systemd" --line_match="success: ${app}-horizon"
|
ynh_supervisor_action --service_name="${app}-horizon" --action="start" --log_path="systemd" --line_match="success: ${app}-horizon"
|
||||||
|
@ -235,7 +235,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
ynh_script_progression --message="Upgrading supervisor configuration..."
|
ynh_script_progression --message="Upgrading supervisor configuration..."
|
||||||
|
|
||||||
# Create a dedicated supervisor config
|
# Create a dedicated supervisor config
|
||||||
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion"
|
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -2,27 +2,20 @@
|
||||||
|
|
||||||
# Create a dedicated supervisor config
|
# Create a dedicated supervisor config
|
||||||
#
|
#
|
||||||
# usage: ynh_add_supervisor_config [--service=service] [--template=template] [--others_var="list of others variables to replace"]
|
# usage: ynh_add_supervisor_config [--service=service] [--template=template]
|
||||||
# | arg: -s, --service= - Service name (optionnal, $app by default)
|
# | arg: -s, --service= - Service name (optionnal, `$app` by default)
|
||||||
# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template)
|
# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template)
|
||||||
# | arg: -v, --others_var= - List of others variables to replace separated by a space. For example: 'var_1 var_2 ...'
|
|
||||||
#
|
#
|
||||||
# This will use the template ../conf/<templatename>.service
|
# This will use the template `../conf/<templatename>.service`.
|
||||||
# to generate a supervisor config, by replacing the following keywords
|
|
||||||
# with global variables that should be defined before calling
|
|
||||||
# this helper :
|
|
||||||
#
|
#
|
||||||
# __APP__ by $app
|
# See the documentation of `ynh_add_config` for a description of the template
|
||||||
# __FINALPATH__ by $final_path
|
# format and how placeholders are replaced with actual variables.
|
||||||
#
|
|
||||||
# And dynamic variables (from the last example) :
|
|
||||||
# __VAR_1__ by $var_1
|
|
||||||
# __VAR_2__ by $var_2
|
|
||||||
#
|
#
|
||||||
|
# Requires YunoHost version 2.7.11 or higher.
|
||||||
ynh_add_supervisor_config () {
|
ynh_add_supervisor_config () {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=stv
|
local legacy_args=stv
|
||||||
local -A args_array=( [s]=service= [t]=template= [v]=others_var= )
|
local -A args_array=( [s]=service= [t]=template= [v]=others_var=)
|
||||||
local service
|
local service
|
||||||
local template
|
local template
|
||||||
local others_var
|
local others_var
|
||||||
|
@ -32,30 +25,10 @@ ynh_add_supervisor_config () {
|
||||||
local template="${template:-supervisor.service}"
|
local template="${template:-supervisor.service}"
|
||||||
others_var="${others_var:-}"
|
others_var="${others_var:-}"
|
||||||
|
|
||||||
finalsupervisorconf="/etc/supervisor/conf.d/$service.conf"
|
[[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using --others_var is unecessary since Yunohost 4.2"
|
||||||
ynh_backup_if_checksum_is_different --file="$finalsupervisorconf"
|
|
||||||
cp ../conf/$template "$finalsupervisorconf"
|
|
||||||
|
|
||||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf"
|
||||||
# Substitute in a nginx config file only if the variable is not empty
|
|
||||||
if [ -n "${final_path:-}" ]; then
|
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalsupervisorconf"
|
|
||||||
fi
|
|
||||||
if [ -n "${app:-}" ]; then
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finalsupervisorconf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Replace all other variables given as arguments
|
|
||||||
for var_to_replace in $others_var
|
|
||||||
do
|
|
||||||
# ${var_to_replace^^} make the content of the variable on upper-cases
|
|
||||||
# ${!var_to_replace} get the content of the variable named $var_to_replace
|
|
||||||
ynh_replace_string --match_string="__${var_to_replace^^}__" --replace_string="${!var_to_replace}" --target_file="$finalsupervisorconf"
|
|
||||||
done
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$finalsupervisorconf"
|
|
||||||
|
|
||||||
chown root: "$finalsupervisorconf"
|
|
||||||
supervisorctl reread
|
supervisorctl reread
|
||||||
supervisorctl update
|
supervisorctl update
|
||||||
}
|
}
|
||||||
|
@ -65,6 +38,7 @@ ynh_add_supervisor_config () {
|
||||||
# usage: ynh_remove_supervisor_config [--service=service]
|
# usage: ynh_remove_supervisor_config [--service=service]
|
||||||
# | arg: -s, --service= - Service name (optionnal, $app by default)
|
# | arg: -s, --service= - Service name (optionnal, $app by default)
|
||||||
#
|
#
|
||||||
|
# Requires YunoHost version 2.7.2 or higher.
|
||||||
ynh_remove_supervisor_config () {
|
ynh_remove_supervisor_config () {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=s
|
local legacy_args=s
|
||||||
|
@ -86,14 +60,15 @@ ynh_remove_supervisor_config () {
|
||||||
|
|
||||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||||
#
|
#
|
||||||
# usage: ynh_supervisor_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
# usage: ynh_supervisor_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ]
|
||||||
# | arg: -n, --service_name= - Name of the service to start. Default : $app
|
# | arg: -n, --service_name= - Name of the service to start. Default : `$app`
|
||||||
# | arg: -a, --action= - Action to perform with supervisorctl. Default: start
|
# | arg: -a, --action= - Action to perform with supervisorctl. Default: start
|
||||||
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started. WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure of the script. The script will then hang forever.
|
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started.
|
||||||
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
|
# | arg: -p, --log_path= - Log file - Path to the log file. Default : `/var/log/$app/$app.log`
|
||||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||||
# | arg: -e, --length= - Length of the error log : Default : 20
|
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||||
#
|
#
|
||||||
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_supervisor_action() {
|
ynh_supervisor_action() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=nalpte
|
local legacy_args=nalpte
|
||||||
|
@ -118,7 +93,8 @@ ynh_supervisor_action() {
|
||||||
then
|
then
|
||||||
local templog="$(mktemp)"
|
local templog="$(mktemp)"
|
||||||
# Following the starting of the app in its log
|
# Following the starting of the app in its log
|
||||||
if [ "$log_path" == "systemd" ] ; then
|
if [ "$log_path" == "systemd" ]
|
||||||
|
then
|
||||||
# Read the supervisor journal
|
# Read the supervisor journal
|
||||||
journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" &
|
journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" &
|
||||||
# Get the PID of the journalctl command
|
# Get the PID of the journalctl command
|
||||||
|
@ -144,16 +120,16 @@ ynh_supervisor_action() {
|
||||||
# If a log is specified for this service, show also the content of this log
|
# If a log is specified for this service, show also the content of this log
|
||||||
if [ -e "$log_path" ]
|
if [ -e "$log_path" ]
|
||||||
then
|
then
|
||||||
ynh_print_err --message="--"
|
|
||||||
ynh_exec_err tail --lines=$length "$log_path"
|
ynh_exec_err tail --lines=$length "$log_path"
|
||||||
fi
|
fi
|
||||||
# Fail the app script, since the service failed.
|
ynh_clean_check_starting
|
||||||
ynh_die
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the timeout and try to find line_match
|
# Start the timeout and try to find line_match
|
||||||
if [[ -n "${line_match:-}" ]]
|
if [[ -n "${line_match:-}" ]]
|
||||||
then
|
then
|
||||||
|
set +x
|
||||||
local i=0
|
local i=0
|
||||||
for i in $(seq 1 $timeout)
|
for i in $(seq 1 $timeout)
|
||||||
do
|
do
|
||||||
|
@ -171,6 +147,7 @@ ynh_supervisor_action() {
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
set -x
|
||||||
if [ $i -ge 3 ]; then
|
if [ $i -ge 3 ]; then
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue