mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Various insignificant corrections
This commit is contained in:
parent
fdc0ecf6e5
commit
0b17aece2e
1 changed files with 20 additions and 20 deletions
|
@ -56,7 +56,7 @@ ynh_get_ram () {
|
||||||
ram=$total_swap
|
ram=$total_swap
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Uhoh, you should choose --free or --total when using ynh_get_ram" >&2
|
ynh_print_warn --message="You have to choose --free or --total when using ynh_get_ram"
|
||||||
ram=0
|
ram=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -65,25 +65,25 @@ ynh_get_ram () {
|
||||||
|
|
||||||
# Return 0 or 1 depending if the system has a given amount of RAM+swap free or total
|
# Return 0 or 1 depending if the system has a given amount of RAM+swap free or total
|
||||||
#
|
#
|
||||||
# usage: ynh_require_ram [--amount=RAM required in Mb] [--free|--total] [--ignore_swap|--only_swap]
|
# usage: ynh_require_ram --required=RAM required in Mb [--free|--total] [--ignore_swap|--only_swap]
|
||||||
# | arg: -a, --amount - The amount to require, in Mb
|
# | arg: -r, --required - The amount to require, in Mb
|
||||||
# | arg: -f, --free - Count free RAM+swap
|
# | arg: -f, --free - Count free RAM+swap
|
||||||
# | arg: -t, --total - Count total RAM+swap
|
# | arg: -t, --total - Count total RAM+swap
|
||||||
# | arg: -s, --ignore_swap - Ignore swap, consider only real RAM
|
# | arg: -s, --ignore_swap - Ignore swap, consider only real RAM
|
||||||
# | arg: -o, --only_swap - Ignore real RAM, consider only swap
|
# | arg: -o, --only_swap - Ignore real RAM, consider only swap
|
||||||
ynh_require_ram () {
|
ynh_require_ram () {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
declare -Ar args_array=( [a]=amount= [f]=free [t]=total [s]=ignore_swap [o]=only_swap )
|
declare -Ar args_array=( [r]=required= [f]=free [t]=total [s]=ignore_swap [o]=only_swap )
|
||||||
local amount
|
local required
|
||||||
local free
|
local free
|
||||||
local total
|
local total
|
||||||
local ignore_swap
|
local ignore_swap
|
||||||
local only_swap
|
local only_swap
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
amount=${amount:-0}
|
|
||||||
# Dunno if that's the right way to do, but that's some black magic to be able to
|
# Dunno if that's the right way to do, but that's some black magic to be able to
|
||||||
# forward the bool args to ynh_get_ram easily?
|
# forward the bool args to ynh_get_ram easily?
|
||||||
|
# If the variable $free is not empty, set it to '--free'
|
||||||
free=${free:+--free}
|
free=${free:+--free}
|
||||||
total=${total:+--total}
|
total=${total:+--total}
|
||||||
ignore_swap=${ignore_swap:+--ignore_swap}
|
ignore_swap=${ignore_swap:+--ignore_swap}
|
||||||
|
@ -91,7 +91,7 @@ ynh_require_ram () {
|
||||||
|
|
||||||
local ram=$(ynh_get_ram $free $total $ignore_swap $only_swap)
|
local ram=$(ynh_get_ram $free $total $ignore_swap $only_swap)
|
||||||
|
|
||||||
if [ $ram -lt $amount ]
|
if [ $ram -lt $required ]
|
||||||
then
|
then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue