1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/joomla_ynh.git synced 2024-09-03 19:26:34 +02:00
joomla_ynh/scripts/_common.sh

62 lines
2.2 KiB
Bash
Raw Permalink Normal View History

2017-07-12 01:45:37 +02:00
#!/bin/bash
2022-01-22 20:55:44 +01:00
#=================================================
# COMMON VARIABLES
#=================================================
2017-07-12 01:45:37 +02:00
2022-01-22 20:55:44 +01:00
# dependencies used by the app
2023-08-17 01:48:03 +02:00
YNH_PHP_VERSION="7.4"
2022-03-22 00:34:56 +01:00
2022-03-23 01:00:30 +01:00
pkg_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-posix php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-memcache php${YNH_PHP_VERSION}-memcached php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-sockets php${YNH_PHP_VERSION}-mcrypt php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-fileinfo php${YNH_PHP_VERSION}-mbstring"
2017-07-12 01:45:37 +02:00
# from nextcloud common script
# Check available space before creating a temp directory.
#
# usage: ynh_smart_mktemp --min_size="Min size"
#
# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb
ynh_smart_mktemp () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=min_size= )
local min_size
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
min_size="${min_size:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(mktemp --directory --tmpdir="$tmpdir")"
}
2022-01-22 20:55:44 +01:00
#=================================================
# PERSONAL HELPERS
#=================================================
2017-07-12 01:45:37 +02:00
2022-01-22 20:55:44 +01:00
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
2017-07-12 01:45:37 +02:00
2022-01-22 20:55:44 +01:00
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================