Browse Source
Merge branch 'testing' into package_upgrade
pull/163/head
Maniack Crudelis
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
26 additions and
0 deletions
-
scripts/_common.sh
|
|
@ -343,3 +343,29 @@ ynh_multimedia_addaccess () { |
|
|
groupadd -f multimedia |
|
|
groupadd -f multimedia |
|
|
usermod -a -G multimedia $user_name |
|
|
usermod -a -G multimedia $user_name |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ynh_smart_mktemp () { |
|
|
|
|
|
local min_size="${1:-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 "$(sudo mktemp --directory --tmpdir="$tmpdir")" |
|
|
|
|
|
} |