mirror of
https://github.com/YunoHost-Apps/biboumi_ynh.git
synced 2024-09-03 18:15:58 +02:00
Complete refactoring
This commit is contained in:
parent
14f03bf698
commit
dc8cdcb00b
15 changed files with 401 additions and 522 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.swp
|
||||
*~
|
25
README.md
25
README.md
|
@ -1,12 +1,9 @@
|
|||
# Biboumi app for Yunohost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/biboumi)
|
||||
[](https://install-app.yunohost.org/?app=biboumi)
|
||||
|
||||
<!--
|
||||
[](https://ci-apps.yunohost.org/jenkins/job/REPLACEBYYOURAPP%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP)
|
||||
-->
|
||||
|
||||
> *This package allows you to install biboumi quickly and simply on a YunoHost server.
|
||||
> *This package allows you to install Biboumi quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
|
@ -22,15 +19,21 @@ For example, if you have a yunohost server hosting domain *example.net*
|
|||
and you want to join the channel *#yunohost* on *irc.freenode.net* you
|
||||
simply need to join the MUC `#yunohost%irc.freenode.net@biboumi.example.net`.
|
||||
|
||||
**Shipped version:** 8.0
|
||||
**Shipped version:** 8.3
|
||||
|
||||
## Configuration
|
||||
|
||||
How to configure this app: by an admin panel, a plain file with SSH, or any other way.
|
||||
You can configure this app by the file `/etc/biboumi/biboumi.cfg`.
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: https://lab.louiz.org/louiz/biboumi/blob/8.0/doc/biboumi.1.rst
|
||||
* Official documentation: https://lab.louiz.org/louiz/biboumi/blob/8.3/doc/biboumi.1.rst
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/biboumi/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/biboumi/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/biboumi/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
@ -38,6 +41,6 @@ How to configure this app: by an admin panel, a plain file with SSH, or any othe
|
|||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/biboumi_ynh/issues
|
||||
* App website: Link to the official website of this app
|
||||
* Report a bug: https://github.com/pitchum/biboumi_ynh
|
||||
* App website: https://biboumi.louiz.org/
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
|
|
@ -9,19 +9,17 @@
|
|||
setup_nourl=1
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=0
|
||||
backup_restore=0
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=0
|
||||
port_already_use=0 # TODO check that port 113 needed by biboumi is not already in use
|
||||
port_already_use=1 (113)
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
|
||||
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
|
||||
Level 4=1 # biboumi is kinda "plugin" for metronome and metronome itself supports LDAP (and SSOWat?)
|
||||
Level 4=1 # biboumi is kinda "plugin" for metronome and metronome itself supports LDAP
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
|
|
|
@ -4,6 +4,7 @@ password=__SECRET__
|
|||
#port=5347
|
||||
|
||||
db_name=/var/lib/biboumi/biboumi.sqlite
|
||||
identd_port=__PORT__
|
||||
|
||||
admin=__ADMIN_JID__
|
||||
realname_customization=true
|
||||
|
|
2
conf/biboumi.cfg.lua
Normal file
2
conf/biboumi.cfg.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
Component "biboumi.__DOMAIN__"
|
||||
component_secret = "__SECRET__"
|
|
@ -6,15 +6,15 @@
|
|||
"en": "XMPP gateway for the IRC network.",
|
||||
"fr": "Passerelle XMPP pour le réseau IRC."
|
||||
},
|
||||
"version": "8.0~ynh1",
|
||||
"version": "8~ynh2",
|
||||
"url": "https://biboumi.louiz.org/",
|
||||
"license": "free",
|
||||
"license": "Zlib",
|
||||
"maintainer": {
|
||||
"name": "pitchum",
|
||||
"email": "pitchum@yunohost.org"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.0.0"
|
||||
"yunohost": ">= 3.3.3"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# ============= FUTURE YUNOHOST HELPER =============
|
||||
# Delete a file checksum from the app settings
|
||||
#
|
||||
# $app should be defined when calling this helper
|
||||
#
|
||||
# usage: ynh_remove_file_checksum file
|
||||
# | arg: file - The file for which the checksum will be deleted
|
||||
ynh_delete_file_checksum () {
|
||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
ynh_app_setting_delete $app $checksum_setting_name
|
||||
}
|
||||
#=================================================
|
||||
# FUTUR OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Internal helper design to allow helpers to use getopts to manage their arguments
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# example: function my_helper()
|
||||
# {
|
||||
# declare -Ar args_array=( [a]=arg1= [b]=arg2= [c]=arg3 )
|
||||
|
@ -63,33 +57,33 @@ ynh_handle_getopts_args () {
|
|||
|
||||
# For each option in the array, reduce to short options for getopts (e.g. for [u]=user, --user will be -u)
|
||||
# And built parameters string for getopts
|
||||
# ${!args_array[@]} is the list of all keys in the array (A key is 'u' in [u]=user, user is a value)
|
||||
# ${!args_array[@]} is the list of all option_flags in the array (An option_flag is 'u' in [u]=user, user is a value)
|
||||
local getopts_parameters=""
|
||||
local key=""
|
||||
for key in "${!args_array[@]}"
|
||||
local option_flag=""
|
||||
for option_flag in "${!args_array[@]}"
|
||||
do
|
||||
# Concatenate each keys of the array to build the string of arguments for getopts
|
||||
# Concatenate each option_flags of the array to build the string of arguments for getopts
|
||||
# Will looks like 'abcd' for -a -b -c -d
|
||||
# If the value of a key finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob)
|
||||
# Check the last character of the value associate to the key
|
||||
if [ "${args_array[$key]: -1}" = "=" ]
|
||||
# If the value of an option_flag finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob)
|
||||
# Check the last character of the value associate to the option_flag
|
||||
if [ "${args_array[$option_flag]: -1}" = "=" ]
|
||||
then
|
||||
# For an option with additionnal values, add a ':' after the letter for getopts.
|
||||
getopts_parameters="${getopts_parameters}${key}:"
|
||||
getopts_parameters="${getopts_parameters}${option_flag}:"
|
||||
else
|
||||
getopts_parameters="${getopts_parameters}${key}"
|
||||
getopts_parameters="${getopts_parameters}${option_flag}"
|
||||
fi
|
||||
# Check each argument given to the function
|
||||
local arg=""
|
||||
# ${#arguments[@]} is the size of the array
|
||||
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
||||
do
|
||||
# And replace long option (value of the key) by the short option, the key itself
|
||||
# And replace long option (value of the option_flag) by the short option, the option_flag itself
|
||||
# (e.g. for [u]=user, --user will be -u)
|
||||
# Replace long option with =
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$key]}/-${key} }"
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]}/-${option_flag} }"
|
||||
# And long option without =
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$key]%=}/-${key}}"
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]%=}/-${option_flag}}"
|
||||
done
|
||||
done
|
||||
|
||||
|
@ -108,10 +102,10 @@ ynh_handle_getopts_args () {
|
|||
|
||||
if [ "$parameter" = "?" ]
|
||||
then
|
||||
ynh_die "Invalid argument: -${OPTARG:-}"
|
||||
ynh_die --message="Invalid argument: -${OPTARG:-}"
|
||||
elif [ "$parameter" = ":" ]
|
||||
then
|
||||
ynh_die "-$OPTARG parameter requires an argument."
|
||||
ynh_die --message="-$OPTARG parameter requires an argument."
|
||||
else
|
||||
local shift_value=1
|
||||
# Use the long option, corresponding to the short option read by getopts, as a variable
|
||||
|
@ -139,19 +133,20 @@ ynh_handle_getopts_args () {
|
|||
shift_value=$(( shift_value - 1 ))
|
||||
fi
|
||||
|
||||
# Declare the content of option_var as a variable.
|
||||
eval ${option_var}=""
|
||||
# Then read the array value per value
|
||||
local i
|
||||
for i in `seq 0 $(( ${#all_args[@]} - 1 ))`
|
||||
do
|
||||
# If this argument is an option, end here.
|
||||
if [ "${all_args[$i]:0:1}" == "-" ] || [ -z "${all_args[$i]}" ]
|
||||
if [ "${all_args[$i]:0:1}" == "-" ]
|
||||
then
|
||||
# Ignore the first value of the array, which is the option itself
|
||||
if [ "$i" -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
# Declare the content of option_var as a variable.
|
||||
eval ${option_var}=""
|
||||
# Else, add this value to this option
|
||||
# Each value will be separated by ';'
|
||||
if [ -n "${!option_var}" ]
|
||||
|
@ -175,25 +170,33 @@ ynh_handle_getopts_args () {
|
|||
# Check if there's getopts arguments
|
||||
if [ "${arguments[0]:0:1}" != "-" ]
|
||||
then
|
||||
# If not, enter in legacy mode and manage the arguments as positionnal ones.
|
||||
echo "! Helper used in legacy mode !"
|
||||
# If not, enter in legacy mode and manage the arguments as positionnal ones..
|
||||
# Dot not echo, to prevent to go through a helper output. But print only in the log.
|
||||
set -x; echo "! Helper used in legacy mode !" > /dev/null; set +x
|
||||
local i
|
||||
for i in `seq 0 $(( ${#arguments[@]} -1 ))`
|
||||
do
|
||||
# Use getopts_parameters as a list of key of the array args_array
|
||||
# Try to use legacy_args as a list of option_flag of the array args_array
|
||||
# Otherwise, fallback to getopts_parameters to get the option_flag. But an associative arrays isn't always sorted in the correct order...
|
||||
# Remove all ':' in getopts_parameters
|
||||
getopts_parameters=${getopts_parameters//:}
|
||||
# Get the key from getopts_parameters, by using the key according to the position of the argument.
|
||||
key=${getopts_parameters:$i:1}
|
||||
# Use the long option, corresponding to the key, as a variable
|
||||
getopts_parameters=${legacy_args:-${getopts_parameters//:}}
|
||||
# Get the option_flag from getopts_parameters, by using the option_flag according to the position of the argument.
|
||||
option_flag=${getopts_parameters:$i:1}
|
||||
if [ -z "$option_flag" ]; then
|
||||
ynh_print_warn --message="Too many arguments ! \"${arguments[$i]}\" will be ignored."
|
||||
continue
|
||||
fi
|
||||
# Use the long option, corresponding to the option_flag, as a variable
|
||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||
# Also, remove '=' at the end of the long option
|
||||
# The variable name will be stored in 'option_var'
|
||||
local option_var="${args_array[$key]%=}"
|
||||
local option_var="${args_array[$option_flag]%=}"
|
||||
|
||||
# Store each value given as argument in the corresponding variable
|
||||
# The values will be stored in the same order than $args_array
|
||||
eval ${option_var}+=\"${arguments[$i]}\"
|
||||
done
|
||||
unset legacy_args
|
||||
else
|
||||
# END LEGACY MODE
|
||||
# Call parse_arg and pass the modified list of args as an array of arguments.
|
||||
|
@ -203,6 +206,136 @@ ynh_handle_getopts_args () {
|
|||
set -x
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
# | arg: -k, --key= - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
|
||||
local manifest
|
||||
local manifest_key
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])"
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version [-m manifest]
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
ynh_app_upstream_version () {
|
||||
declare -Ar args_array=( [m]=manifest= )
|
||||
local manifest
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
manifest="${manifest:-../manifest.json}"
|
||||
if [ ! -e "$manifest" ]; then
|
||||
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Read package version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number after ~ynh
|
||||
# In the last example it return 3
|
||||
#
|
||||
# usage: ynh_app_package_version [-m manifest]
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
ynh_app_package_version () {
|
||||
declare -Ar args_array=( [m]=manifest= )
|
||||
local manifest
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
manifest="${manifest:-../manifest.json}"
|
||||
if [ ! -e "$manifest" ]; then
|
||||
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||
echo "${version_key/*~ynh/}"
|
||||
}
|
||||
|
||||
# Checks the app version to upgrade with the existing app version and returns:
|
||||
# - UPGRADE_APP if the upstream app version has changed
|
||||
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
#
|
||||
## It stops the current script without error if the package is up-to-date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||
# of it, when it's not needed
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
#
|
||||
# usage: ynh_check_app_version_changed
|
||||
ynh_check_app_version_changed () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
# By default, upstream app version has changed
|
||||
local return_value="UPGRADE_APP"
|
||||
|
||||
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)
|
||||
local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")"
|
||||
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0)
|
||||
local update_upstream_version="$(ynh_app_upstream_version)"
|
||||
|
||||
if [ "$current_version" == "$update_version" ] ; then
|
||||
# Complete versions are the same
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||
# Upstream versions are the same, only YunoHost package versions differ
|
||||
return_value="UPGRADE_PACKAGE"
|
||||
fi
|
||||
echo $return_value
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Delete a file checksum from the app settings
|
||||
#
|
||||
# $app should be defined when calling this helper
|
||||
#
|
||||
# usage: ynh_remove_file_checksum file
|
||||
# | arg: -f, --file= - The file for which the checksum will be deleted
|
||||
ynh_delete_file_checksum () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [f]=file= )
|
||||
local file
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
ynh_app_setting_delete $app $checksum_setting_name
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||
#
|
||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||
|
@ -214,71 +347,72 @@ ynh_handle_getopts_args () {
|
|||
# | 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
|
||||
ynh_systemd_action() {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local templog="$(mktemp)"
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
if [ "$log_path" == "systemd" ] ; then
|
||||
# Read the systemd journal
|
||||
journalctl -u $service_name -f --since=-45 > "$templog" &
|
||||
# Read the systemd journal
|
||||
journalctl -u $service_name -f --since=-45 > "$templog" &
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" > "$templog" &
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" > "$templog" &
|
||||
fi
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
|
||||
echo "${action^} the service $service_name" >&2
|
||||
systemctl $action $service_name \
|
||||
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||
; false )
|
||||
echo "${action^} the service $service_name" >&2
|
||||
systemctl $action $service_name \
|
||||
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||
; false )
|
||||
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local i=0
|
||||
for i in `seq 1 $timeout`
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
journalctl --lines=$length -u $service_name >&2
|
||||
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local i=0
|
||||
for i in $(seq 1 $timeout)
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
echo "Please find here an extract of the end of the log of the service $service_name:"
|
||||
journalctl --lines=$length -u $service_name >&2
|
||||
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean temporary process and file used by ynh_check_starting
|
||||
|
|
|
@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -26,9 +22,7 @@ ynh_abort_if_errors
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
@ -36,26 +30,8 @@ db_name=$(ynh_app_setting_get $app db_name)
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
ynh_backup "/etc/biboumi"
|
||||
ynh_backup "/var/lib/biboumi"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
@ -66,13 +42,7 @@ ynh_mysql_dump_db "$db_name" > db.sql
|
|||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
# BACKUP METRONOME CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP A CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/cron.d/$app"
|
||||
ynh_backup "/etc/metronome/conf.d/biboumi.cfg.lua"
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
#db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
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 "$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
135
scripts/install
135
scripts/install
|
@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -24,29 +20,26 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
|
||||
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
||||
then
|
||||
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
|
||||
fi
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
|
||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
||||
#final_path=/var/lib/biboumi
|
||||
#test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
||||
then
|
||||
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Nothing special here.
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app admin $admin
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -54,28 +47,14 @@ fi
|
|||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
|
||||
### Use these lines if you have to open a port for the application
|
||||
### `ynh_find_port` will find the first available port starting from the given port.
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "CLOSE A PORT" in the remove script
|
||||
|
||||
## Find a free port
|
||||
#port=$(ynh_find_port 8095)
|
||||
## Open this port
|
||||
#yunohost firewall allow --no-upnp TCP $port 2>&1
|
||||
#ynh_app_setting_set $app port $port
|
||||
# Find a free port
|
||||
port=$(ynh_find_port 113)
|
||||
ynh_app_setting_set $app port $port
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||
### Those deb packages will be installed as dependencies of this package.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||
|
||||
# Make sure that stretch-backports is enabled
|
||||
if ! apt-cache policy | grep 'stretch-backports/main'
|
||||
then
|
||||
|
@ -88,7 +67,7 @@ ynh_install_app_dependencies biboumi
|
|||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ...
|
||||
# CONFIGURE BIBOUMI
|
||||
#=================================================
|
||||
|
||||
# Create a secret password that will be shared by metronome and biboumi.
|
||||
|
@ -97,84 +76,52 @@ shared_secret="$(ynh_string_random 25)"
|
|||
# Biboumi needs at least one admin JID.
|
||||
admin_jid="${admin}@biboumi.${domain}"
|
||||
|
||||
biboumi_config_file="/etc/biboumi/biboumi.cfg"
|
||||
|
||||
# Create the biboumi config file.
|
||||
cp ../conf/biboumi.cfg /etc/biboumi/
|
||||
ynh_replace_string __DOMAIN__ "${domain}" /etc/biboumi/biboumi.cfg
|
||||
ynh_replace_string __SECRET__ "${shared_secret}" /etc/biboumi/biboumi.cfg
|
||||
ynh_replace_string __ADMIN_JID__ "${admin_jid}" /etc/biboumi/biboumi.cfg
|
||||
|
||||
MARKER_START="-- START Patch from biboumi_ynh"
|
||||
MARKER_END="-- END Patch from biboumi_ynh"
|
||||
|
||||
# Patch metronome's main config file.
|
||||
metronome_component="\
|
||||
${MARKER_START}\\n\
|
||||
Component \"biboumi.${domain}\"\\n\
|
||||
component_secret = \"${shared_secret}\"\\n\
|
||||
${MARKER_END}\\n"
|
||||
|
||||
# Try to detect if metronome's main config file was not patched yet.
|
||||
if grep -q -- "${MARKER_START}" /etc/metronome/metronome.cfg.lua
|
||||
then
|
||||
echo "Metronome's configuration file is already patched. This is unexpected. Cowardly aborting installation..."
|
||||
ynh_die 42
|
||||
fi
|
||||
|
||||
#sed -i "s/----------- Virtual hosts/${metronome_component}----------- Virtual hosts/" /etc/metronome/metronome.cfg.lua
|
||||
ynh_replace_string "^----------- Virtual hosts" "${metronome_component}&" /etc/metronome/metronome.cfg.lua
|
||||
|
||||
|
||||
mkdir -p /var/log/biboumi /var/lib/biboumi
|
||||
chown _biboumi /var/log/biboumi /var/lib/biboumi
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
### `ynh_store_file_checksum` is used to store the checksum of a file.
|
||||
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
|
||||
### you can make a backup of this file before modifying it again if the admin had modified it.
|
||||
cp ../conf/biboumi.cfg "$biboumi_config_file"
|
||||
ynh_replace_string __DOMAIN__ "${domain}" "$biboumi_config_file"
|
||||
ynh_replace_string __SECRET__ "${shared_secret}" "$biboumi_config_file"
|
||||
ynh_replace_string __PORT__ "${port}" "$biboumi_config_file"
|
||||
ynh_replace_string __ADMIN_JID__ "${admin_jid}" "$biboumi_config_file"
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
#ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
||||
ynh_store_file_checksum "$biboumi_config_file"
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE METRONOME
|
||||
#=================================================
|
||||
|
||||
# Add metronome component
|
||||
cp ../conf/biboumi.cfg.lua /etc/metronome/conf.d/
|
||||
ynh_replace_string __DOMAIN__ "${domain}" /etc/metronome/conf.d/biboumi.cfg.lua
|
||||
ynh_replace_string __SECRET__ "${shared_secret}" /etc/metronome/conf.d/biboumi.cfg.lua
|
||||
|
||||
#=================================================
|
||||
# CREATE DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
mkdir -p /var/log/biboumi /var/lib/biboumi
|
||||
|
||||
# Set permissions to app files
|
||||
chown _biboumi /var/log/biboumi /var/lib/biboumi
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
||||
### Use this helper only if there is effectively a log file for this app.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
||||
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
|
||||
### - And the section "SETUP LOGROTATE" in the upgrade script
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
#ynh_use_logrotate
|
||||
# TODO setup logrotate
|
||||
ynh_use_logrotate /var/log/biboumi/
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
|
||||
### You'll find the service in the 'services' section of YunoHost admin panel.
|
||||
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
|
||||
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
|
||||
|
||||
yunohost service add biboumi
|
||||
|
||||
# TODO Try to make "yunohost service" able to display logs from journalctl
|
||||
# yunohost service add biboumi --log "/var/log/FILE.log"
|
||||
|
||||
yunohost service add biboumi --log "/var/log/biboumi/biboumi.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD SERVICES
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action -a restart -n metronome
|
||||
ynh_systemd_action -a restart -n biboumi -p /var/log/biboumi/biboumi.log
|
||||
ynh_systemd_action --action=restart --service_name=metronome
|
||||
ynh_systemd_action --action=restart --service_name=biboumi
|
||||
|
|
|
@ -15,8 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
@ -34,27 +32,40 @@ fi
|
|||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
rm -f /etc/biboumi/biboumi.cfg
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
rm -rf /var/lib/biboumi
|
||||
rm -rf /var/log/biboumi
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "/etc/biboumi"
|
||||
ynh_secure_remove "/var/lib/biboumi"
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
#ynh_remove_logrotate
|
||||
# TODO ynh_remove_logrotate
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE LOGS
|
||||
#=================================================
|
||||
|
||||
## XXX these 2 variables are also defined in install. Dear maintainer, please merge these somewhere else. In _common?
|
||||
MARKER_START="-- START Patch from biboumi_ynh"
|
||||
MARKER_END="-- END Patch from biboumi_ynh"
|
||||
ynh_secure_remove "/var/log/biboumi"
|
||||
|
||||
sed -i "/${MARKER_START}/,/${MARKER_END}/d" /etc/metronome/metronome.cfg.lua
|
||||
#=================================================
|
||||
# REMOVE BACKPORTS LIST
|
||||
#=================================================
|
||||
|
||||
# Remove stretch-backports config file if exists
|
||||
rm -f /etc/apt/sources.list.d/${app}_needs_stretch-backports.list
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/${app}_needs_stretch-backports.list"
|
||||
|
||||
#=================================================
|
||||
# REMOVE METRONOME COMPONENT
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/etc/metronome/conf.d/biboumi.cfg.lua"
|
||||
|
|
110
scripts/restore
110
scripts/restore
|
@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -27,61 +23,15 @@ ynh_abort_if_errors
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R root: $final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
||||
then
|
||||
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -89,39 +39,53 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
|||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies deb1 deb2
|
||||
# Make sure that stretch-backports is enabled
|
||||
if ! apt-cache policy | grep 'stretch-backports/main'
|
||||
then
|
||||
echo "deb http://ftp.fr.debian.org/debian/ stretch-backports main" | sudo tee /etc/apt/sources.list.d/${app}_needs_stretch-backports.list
|
||||
echo "Adding stretch-backports repository..."
|
||||
fi
|
||||
|
||||
ynh_install_app_dependencies biboumi
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/biboumi"
|
||||
ynh_restore_file "/var/lib/biboumi"
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
yunohost service add $app --log "/var/log/$app/APP.log"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/cron.d/$app"
|
||||
yunohost service add biboumi --log "/var/log/biboumi/biboumi.log"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
mkdir -p /var/log/biboumi
|
||||
ynh_restore_file "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown _biboumi /var/log/biboumi /var/lib/biboumi
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE METRONOME CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/metronome/conf.d/biboumi.cfg.lua"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
# RELOAD SERVICES
|
||||
#=================================================
|
||||
|
||||
systemctl reload php5-fpm
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --action=restart --service_name=metronome
|
||||
ynh_systemd_action --action=restart --service_name=biboumi
|
||||
|
|
133
scripts/upgrade
133
scripts/upgrade
|
@ -16,38 +16,19 @@ source /usr/share/yunohost/helpers
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
language=$(ynh_app_setting_get $app language)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z $db_name ]; then
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z $final_path ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -55,80 +36,62 @@ fi
|
|||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
# 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 THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies deb1 deb2
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
ynh_install_app_dependencies biboumi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
# CONFIGURE BIBOUMI
|
||||
#=================================================
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
|
||||
biboumi_config_file="/etc/biboumi/biboumi.cfg"
|
||||
|
||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
ynh_backup_if_checksum_is_different "$biboumi_config_file"
|
||||
|
||||
# Get shared_secret from the config file
|
||||
shared_secret="$(grep password "$biboumi_config_file" | cut -d= -f2)"
|
||||
|
||||
# Biboumi needs at least one admin JID.
|
||||
admin_jid="${admin}@biboumi.${domain}"
|
||||
|
||||
# Create the biboumi config file.
|
||||
cp ../conf/biboumi.cfg /etc/biboumi/
|
||||
ynh_replace_string __DOMAIN__ "${domain}" "$biboumi_config_file"
|
||||
ynh_replace_string __SECRET__ "${shared_secret}" "$biboumi_config_file"
|
||||
ynh_replace_string __PORT__ "${port}" "$biboumi_config_file"
|
||||
ynh_replace_string __ADMIN_JID__ "${admin_jid}" "$biboumi_config_file"
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
||||
ynh_store_file_checksum "$biboumi_config_file"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE METRONOME COMPONENT
|
||||
#=================================================
|
||||
|
||||
# Upgrade metronome component
|
||||
cp ../conf/biboumi.cfg.lua /etc/metronome/conf.d/
|
||||
ynh_replace_string __DOMAIN__ "${domain}" /etc/metronome/conf.d/biboumi.cfg.lua
|
||||
ynh_replace_string __SECRET__ "${shared_secret}" /etc/metronome/conf.d/biboumi.cfg.lua
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_use_logrotate /var/log/biboumi/ --non-append
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -137,21 +100,11 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R root: $final_path
|
||||
chown _biboumi /var/log/biboumi /var/lib/biboumi
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
# RELOAD SERVICES
|
||||
#=================================================
|
||||
|
||||
# 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 unprotected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --action=restart --service_name=metronome
|
||||
ynh_systemd_action --action=restart --service_name=biboumi
|
||||
|
|
2
sources/extra_files/app/.gitignore
vendored
2
sources/extra_files/app/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
Loading…
Add table
Reference in a new issue