1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minchat_ynh.git synced 2024-09-03 19:36:29 +02:00

[fix] add generic function to test install environnement

This commit is contained in:
magikcypress 2017-05-08 18:49:11 +02:00
parent edfffbf2be
commit d4c46fa38d
2 changed files with 37 additions and 10 deletions

View file

@ -10,6 +10,34 @@ ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
$@ > /dev/null 2>&1
}
CHECK_VAR () { # Check variable is not empty
# $1 = Checking variable
# $2 = Text to display on error
test -n "$1" || (echo "$2" >&2 && false)
}
CHECK_PATH () { # Checks / at the beginning of the path. And his absence at the end.
if [ "${path:0:1}" != "/" ]; then # If the first character is not /
path="/$path" # Add / at the beginning of path
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # If the last character is a / and it is not the only character.
path="${path:0:${#path}-1}" # Delete last character
fi
}
CHECK_DOMAINPATH () { # Checks the availability of the path and domain.
sudo yunohost app checkurl $domain$path -a $app
}
CHECK_FINALPATH () { # Checks that the destination folder is not already in use.
final_path=/var/www/$app
if [ -e "$final_path" ]
then
echo "This path already contains a folder" >&2
false
fi
}
# Substitute a string by another in a file
#
# usage: ynh_substitute_char string_to_find replace_string file_to_analyse

View file

@ -14,23 +14,22 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
CHECK_VAR "$app" "app name not set"
# Remove trailing "/" for next commands
if [[ ! "$path" == "/" ]]; then
path=${path%/}
fi
CHECK_PATH
CHECK_DOMAINPATH
CHECK_FINALPATH
# Create system user dedicace for this app
ynh_system_user_create $app
# Copy files to the right place
final_path=/var/www/$app
sudo mkdir -p $final_path
extract_source $final_path
# Create system user dedicace for this app
ynh_system_user_create $app
# Copy files to the right place with the right permissions
final_path=/var/www/$app
sudo mkdir -p $final_path