aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2019-05-10 11:30:13 +0200
committeryalh76 <yalh@yahoo.com>2019-05-10 11:30:13 +0200
commitc027590f7ebcba3f89c1fdd8b8ac12516e1959e8 (patch)
tree6b9d3a2664a313875ddff03ab5565f8a025650e0
parentc44558416168d26eef92c03c88f65669c4a73668 (diff)
downloadmastodon_ynh-c027590f7ebcba3f89c1fdd8b8ac12516e1959e8.tar.gz
mastodon_ynh-c027590f7ebcba3f89c1fdd8b8ac12516e1959e8.tar.bz2
mastodon_ynh-c027590f7ebcba3f89c1fdd8b8ac12516e1959e8.zip
Remove ynh_systemd_action experimental helper
-rw-r--r--scripts/backup1
-rw-r--r--scripts/change_url1
-rw-r--r--scripts/install1
-rw-r--r--scripts/restore1
-rw-r--r--scripts/upgrade1
-rw-r--r--scripts/ynh_systemd_action89
6 files changed, 0 insertions, 94 deletions
diff --git a/scripts/backup b/scripts/backup
index 58b29a7..ca9212d 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -8,7 +8,6 @@
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
-source ../settings/scripts/ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
diff --git a/scripts/change_url b/scripts/change_url
index 525ecc9..e87b369 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -7,7 +7,6 @@
#=================================================
source _common.sh
-source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
diff --git a/scripts/install b/scripts/install
index 337f7be..1366e80 100644
--- a/scripts/install
+++ b/scripts/install
@@ -9,7 +9,6 @@
source _common.sh
source ynh_install_ruby
source ynh_add_secure_repos__3
-source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
diff --git a/scripts/restore b/scripts/restore
index 6e39fb5..97b77cf 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -10,7 +10,6 @@
source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_install_ruby
source ../settings/scripts/ynh_add_secure_repos__3
-source ../settings/scripts/ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index b90dddd..0bfe6c8 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -9,7 +9,6 @@
source _common.sh
source ynh_install_ruby
source ynh_add_secure_repos__3
-source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
diff --git a/scripts/ynh_systemd_action b/scripts/ynh_systemd_action
deleted file mode 100644
index 6bed6be..0000000
--- a/scripts/ynh_systemd_action
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/bash
-
-# 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] ]
-# | arg: -n, --service_name= - Name of the service to reload. Default : $app
-# | arg: -a, --action= - Action to perform with systemctl. 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.
-# | 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: -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
-
- # 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}
-
- # 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" &
- else
- # Read the specified log file
- tail -F -n0 "$log_path" > "$templog" &
- 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 )
-
- # 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
-
- echo ""
- ynh_clean_check_starting
- fi
-}
-
-# Clean temporary process and file used by ynh_check_starting
-# (usually used in ynh_clean_setup scripts)
-#
-# usage: ynh_clean_check_starting
-ynh_clean_check_starting () {
- # Stop the execution of tail.
- kill -s 15 $pid_tail 2>&1
- ynh_secure_remove "$templog" 2>&1
-}