From 57d33982b6c7da8fb70edbc28d7c6470765505b5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 11 Jan 2022 11:00:27 +0100 Subject: [PATCH] Fix --- scripts/_common.sh | 64 ---------------------------------------------- scripts/upgrade | 3 +++ 2 files changed, 3 insertions(+), 64 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9779f45..38d9424 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -106,67 +106,3 @@ set_access_settings() { ynh_app_setting_set $app skipped_regex "$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/git%-receive%-pack,$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/git%-upload%-pack,$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/info/refs" fi } - -#================================================= - -# 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 -} - -# Start or restart a service and follow its booting -# -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] -# -# | arg: Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: Log file - The log file to watch -# | arg: Service name -# /var/log/$app/$app.log will be used if no other log is defined. -# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. -ynh_check_starting () { - local line_to_match="$1" - local service_name="${4:-$app}" - local app_log="${2:-/var/log/$service_name/$service_name.log}" - local timeout=${3:-300} - - ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 - } - - echo "Starting of $service_name" >&2 - systemctl stop $service_name - local templog="$(mktemp)" - # Following the starting of the app in its log - tail -F -n0 "$app_log" > "$templog" & - # Get the PID of the tail command - local pid_tail=$! - systemctl start $service_name - - 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_to_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 - fi - - echo "" - ynh_clean_check_starting -} \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index b182c53..6dc43bf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,5 +115,8 @@ set_access_settings # Set permissions set_permission +# Add Gogs to YunoHost's monitored services +yunohost service add "$app" --log /var/log/"$app"/"$app".log + # Reload services ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"