2020-01-18 10:28:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
2022-08-31 02:25:01 +02:00
|
|
|
|
|
|
|
nodejs_version=16.13.1
|
2020-01-18 10:28:47 +01:00
|
|
|
|
2022-08-10 16:49:52 +02:00
|
|
|
swap_needed=4096
|
2022-09-14 19:45:05 +02:00
|
|
|
node_max_old_space_size=6144
|
2021-08-29 00:17:52 +02:00
|
|
|
|
2022-08-31 02:25:01 +02:00
|
|
|
# dependencies used by the app (must be on a single line)
|
2021-07-04 21:45:43 +02:00
|
|
|
pkg_dependencies=""
|
|
|
|
|
2020-01-18 10:28:47 +01:00
|
|
|
#=================================================
|
|
|
|
# PERSONAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2022-08-12 16:53:32 +02:00
|
|
|
# Reset failed systemd services.
|
|
|
|
ynh_reset_systemd(){
|
2022-08-31 02:25:01 +02:00
|
|
|
systemctl reset-failed
|
2022-08-12 16:53:32 +02:00
|
|
|
}
|
|
|
|
|
2022-08-12 23:17:56 +02:00
|
|
|
# Substitute/replace a string (or expression) by another in a file on a line
|
2022-08-11 13:20:52 +02:00
|
|
|
#
|
2022-08-12 23:17:56 +02:00
|
|
|
# usage: ynh_replace_string_on_line --line=line --match_string=match_string --replace_string=replace_string --target_file=target_file
|
2022-08-31 02:25:01 +02:00
|
|
|
# | arg: -l, --line= - Replace match on nth line in the file
|
|
|
|
# | arg: -m, --match_string= - String to be searched and replaced in the file
|
2022-08-11 13:20:52 +02:00
|
|
|
# | arg: -r, --replace_string= - String that will replace matches
|
2022-08-31 02:25:01 +02:00
|
|
|
# | arg: -f, --target_file= - File in which the string will be replaced.
|
2022-08-11 13:20:52 +02:00
|
|
|
#
|
|
|
|
# As this helper is based on sed command, regular expressions and references to
|
|
|
|
# sub-expressions can be used (see sed manual page for more information)
|
|
|
|
#
|
2022-08-12 23:17:56 +02:00
|
|
|
ynh_replace_string_on_line() {
|
2022-08-31 02:25:01 +02:00
|
|
|
# Declare an array to define the options of this helper.
|
|
|
|
local legacy_args=lmrf
|
|
|
|
local -A args_array=([l]=line= [m]=match_string= [r]=replace_string= [f]=target_file=)
|
|
|
|
local line
|
|
|
|
local match_string
|
|
|
|
local replace_string
|
|
|
|
local target_file
|
|
|
|
# Manage arguments with getopts
|
|
|
|
ynh_handle_getopts_args "$@"
|
|
|
|
set +o xtrace # set +x
|
|
|
|
|
|
|
|
local delimit=@
|
|
|
|
# Escape the delimiter if it's in the string.
|
|
|
|
match_string=${match_string//${delimit}/"\\${delimit}"}
|
|
|
|
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
|
|
|
|
|
|
|
set -o xtrace # set -x
|
|
|
|
sed --in-place "${line} s${delimit}${match_string}${delimit}${replace_string}${delimit}" "$target_file"
|
2022-08-11 13:20:52 +02:00
|
|
|
}
|
2021-01-25 13:08:34 +01:00
|
|
|
|
2022-08-31 02:25:01 +02:00
|
|
|
#=================================================
|
2020-01-18 10:28:47 +01:00
|
|
|
# EXPERIMENTAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|