mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2024-11-21 18:41:35 +01:00
Fix package linter
This commit is contained in:
parent
565e380b48
commit
b67fafcf08
@ -19,18 +19,6 @@
|
|||||||
incorrect_path=0
|
incorrect_path=0
|
||||||
port_already_use=1 (6000)
|
port_already_use=1 (6000)
|
||||||
change_url=1
|
change_url=1
|
||||||
;;; Levels
|
|
||||||
Level 1=auto
|
|
||||||
Level 2=auto
|
|
||||||
Level 3=auto
|
|
||||||
# https://github.com/YunoHost-Apps/gitea_ynh/blob/master/conf/login_source.sql
|
|
||||||
Level 4=1
|
|
||||||
Level 5=auto
|
|
||||||
Level 6=auto
|
|
||||||
Level 7=auto
|
|
||||||
Level 8=0
|
|
||||||
Level 9=0
|
|
||||||
Level 10=0
|
|
||||||
;;; Upgrade options
|
;;; Upgrade options
|
||||||
; commit=349992d4f3921e4e1adb37a0cace4a5a9eb67099
|
; commit=349992d4f3921e4e1adb37a0cace4a5a9eb67099
|
||||||
name=First package version
|
name=First package version
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Load common variables and helpers
|
||||||
|
source ../settings/scripts/experimental_helper.sh
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Load common variables and helpers
|
|
||||||
source ../settings/scripts/experimental_helper.sh
|
|
||||||
source ../settings/scripts/_common.sh
|
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Import common cmd
|
||||||
|
source ./experimental_helper.sh
|
||||||
|
source ./_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
|
||||||
source ./experimental_helper.sh
|
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
|
@ -1,82 +1,3 @@
|
|||||||
# 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 --unit=$service_name --follow --since=-0 --quiet > "$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 -e "$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
|
|
||||||
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 -e "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
ynh_clean_check_starting
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute a command as another user
|
# Execute a command as another user
|
||||||
# usage: exec_as USER COMMAND [ARG ...]
|
# usage: exec_as USER COMMAND [ARG ...]
|
||||||
exec_as() {
|
exec_as() {
|
||||||
@ -334,39 +255,3 @@ ynh_handle_app_migration () {
|
|||||||
migration_process=1
|
migration_process=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Verify the checksum and backup the file if it's different
|
|
||||||
# This helper is primarily meant to allow to easily backup personalised/manually
|
|
||||||
# modified config files.
|
|
||||||
#
|
|
||||||
# $app should be defined when calling this helper
|
|
||||||
#
|
|
||||||
# usage: ynh_backup_if_checksum_is_different --file=file
|
|
||||||
# | arg: -f, --file - The file on which the checksum test will be perfomed.
|
|
||||||
# | ret: the name of a backup file, or nothing
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
|
||||||
ynh_backup_if_checksum_is_different () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=f
|
|
||||||
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 '_'
|
|
||||||
local checksum_value=$(ynh_app_setting_get --app=$app --key=$checksum_setting_name)
|
|
||||||
# backup_file_checksum isn't declare as local, so it can be reuse by ynh_store_file_checksum
|
|
||||||
backup_file_checksum=""
|
|
||||||
if [ -n "$checksum_value" ]
|
|
||||||
then # Proceed only if a value was stored into the app settings
|
|
||||||
if [ -e $file ] && ! echo "$checksum_value $file" | sudo md5sum -c --status
|
|
||||||
then # If the checksum is now different
|
|
||||||
backup_file_checksum="/home/yunohost.conf/backup/$file.backup.$(date '+%Y%m%d.%H%M%S')"
|
|
||||||
sudo mkdir -p "$(dirname "$backup_file_checksum")"
|
|
||||||
sudo cp -a "$file" "$backup_file_checksum" # Backup the current file
|
|
||||||
ynh_print_warn "File $file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_file_checksum"
|
|
||||||
echo "$backup_file_checksum" # Return the name of the backup file
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Load common variables and helpers
|
||||||
|
source ./experimental_helper.sh
|
||||||
|
source ./_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Load common variables and helpers
|
|
||||||
source ./experimental_helper.sh
|
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
ynh_script_progression --message="Validating installation parameters..."
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
# Load common variables and helpers
|
# Load common variables and helpers
|
||||||
source ./experimental_helper.sh
|
source ./experimental_helper.sh
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
# Retrieve domain from app settings
|
# Retrieve domain from app settings
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Load common variables and helpers
|
||||||
|
source ../settings/scripts/experimental_helper.sh
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Load common variables and helpers
|
|
||||||
source ../settings/scripts/experimental_helper.sh
|
|
||||||
source ../settings/scripts/_common.sh
|
|
||||||
|
|
||||||
ynh_script_progression --message="Loading settings..."
|
ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
# Retrieve old app settings
|
# Retrieve old app settings
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Load common variables and helpers
|
||||||
|
source ./experimental_helper.sh
|
||||||
|
source ./_common.sh
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Load common variables and helpers
|
|
||||||
source ./experimental_helper.sh
|
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||||
@ -43,7 +43,7 @@ systemctl stop "$app".service
|
|||||||
[[ $YNH_APP_ID == "gogs" ]] \
|
[[ $YNH_APP_ID == "gogs" ]] \
|
||||||
&& [[ "$(cat "/opt/$app/templates/.VERSION")" != 0.11.79.1211 ]] \
|
&& [[ "$(cat "/opt/$app/templates/.VERSION")" != 0.11.79.1211 ]] \
|
||||||
&& ynh_die --message "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea."
|
&& ynh_die --message "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea."
|
||||||
ynh_handle_app_migration gogs gogs_migrations
|
ynh_handle_app_migration --migration_id=gogs --migration_list=gogs_migrations
|
||||||
|
|
||||||
if [[ $migration_process -eq 1 ]]; then
|
if [[ $migration_process -eq 1 ]]; then
|
||||||
# Reload variables
|
# Reload variables
|
||||||
@ -206,6 +206,10 @@ then
|
|||||||
ynh_permission_update --permission "main" --add "visitors"
|
ynh_permission_update --permission "main" --add "visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Add gitea to YunoHost's monitored services
|
||||||
|
ynh_script_progression --message="Register gitea service..."
|
||||||
|
yunohost service add "$app" --log "/var/log/$app/gitea.log"
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
ynh_script_progression --message="Protecting directory"
|
ynh_script_progression --message="Protecting directory"
|
||||||
set_permission
|
set_permission
|
||||||
|
Loading…
Reference in New Issue
Block a user