Browse Source
Merge pull request #127 from YunoHost-Apps/donotusetmp
Don't use /tmp anymore
pull/152/head
JimboJoe
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
28 additions and
1 deletions
-
scripts/_common.sh
-
scripts/upgrade
|
|
@ -356,3 +356,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")" |
|
|
|
|
|
} |
|
|
@ -191,7 +191,7 @@ do |
|
|
ynh_replace_string "__SHA256_SUM__" "$nextcloud_source_sha256" "../conf/app.src" |
|
|
ynh_replace_string "__SHA256_SUM__" "$nextcloud_source_sha256" "../conf/app.src" |
|
|
|
|
|
|
|
|
# Create a temporary directory |
|
|
# Create a temporary directory |
|
|
tmpdir=$(mktemp -d) |
|
|
|
|
|
|
|
|
tmpdir="$(ynh_smart_mktemp 300)" |
|
|
|
|
|
|
|
|
# Install the next nextcloud version in $tmpdir |
|
|
# Install the next nextcloud version in $tmpdir |
|
|
ynh_setup_source "$tmpdir" |
|
|
ynh_setup_source "$tmpdir" |
|
|
@ -210,6 +210,7 @@ do |
|
|
# Replace the old nextcloud by the new one |
|
|
# Replace the old nextcloud by the new one |
|
|
ynh_secure_remove "$final_path" |
|
|
ynh_secure_remove "$final_path" |
|
|
mv "$tmpdir" "$final_path" |
|
|
mv "$tmpdir" "$final_path" |
|
|
|
|
|
ynh_secure_remove "$tmpdir" |
|
|
|
|
|
|
|
|
# Set write access for the following commands |
|
|
# Set write access for the following commands |
|
|
chown -R $app: "$final_path" "$datadir" |
|
|
chown -R $app: "$final_path" "$datadir" |
|
|
|