1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/concrete5_ynh.git synced 2024-09-03 18:25:54 +02:00

Update install

This commit is contained in:
frju365 2017-03-01 20:04:01 +01:00 committed by GitHub
parent 0fa7e37412
commit 64d7e4c67d

View file

@ -1,13 +1,44 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source .fonctions source .fonctions
set -eu
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve app id #=================================================
app=$YNH_APP_INSTANCE_NAME # MANAGE FAILURE OF THE SCRIPT
#=================================================
ynh_check_error # Active trap pour arrêter le script si une erreur est détectée.
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source .fonctions
source /usr/share/yunohost/helpers
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
ynh_check_error # Active trap pour arrêter le script si une erreur est détectée.
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
@ -15,32 +46,39 @@ admin_name=$YNH_APP_ARG_ADMIN_NAME
admin_pass=$YNH_APP_ARG_ADMIN_PASS admin_pass=$YNH_APP_ARG_ADMIN_PASS
admin_email=$YNH_APP_ARG_ADMIN_EMAIL admin_email=$YNH_APP_ARG_ADMIN_EMAIL
# Vérifie que les variables ne sont pas vides. app=$YNH_APP_INSTANCE_NAME
CHECK_VAR "$app" "app name not set"
CHECK_PATH # Vérifie et corrige la syntaxe du path. #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
CHECK_USER "$admin" # Vérifie la validité de l'user admin
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine. CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé. CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
# Install dependency to convert tracks to a readable format for the browser #=================================================
# sudo apt-get update # STORE SETTINGS FROM MANIFEST
# sudo apt-get -y -qq install php5-mysql #=================================================
# Install dependencies using Helpers
# Check password strength
[[ ${#admin_pass} -gt 5 ]] || ynh_die \
"The password is too weak, it must be longer than 5 characters"
# Save app settings
user="$app" user="$app"
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" admin_pass "$admin_pass" ynh_app_setting_set "$app" admin_pass "$admin_pass"
ynh_app_setting_set "$app" admin_name "$admin_name" ynh_app_setting_set "$app" admin_name "$admin_name"
ynh_app_setting_set "$app" admin_email "$admin_email" ynh_app_setting_set "$app" admin_email "$admin_email"
# Initialize database as needed #=================================================
# Check password strength
#=================================================
[[ ${#admin_pass} -gt 5 ]] || ynh_die \
"The password is too weak, it must be longer than 5 characters"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# CREATE A SQL BDD
#=================================================
db_name=$app db_name=$app
db_user=$app db_user=$app
@ -49,6 +87,14 @@ ynh_mysql_create_db "$db_name" "$db_user" "$db_pass"
ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set "$app" db_name "$db_name"
ynh_app_setting_set "$app" db_pass "$db_pass" ynh_app_setting_set "$app" db_pass "$db_pass"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path
SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path
# Remove trailing "/" for next commands # Remove trailing "/" for next commands
if [[ ! "$path" == "/" ]]; then if [[ ! "$path" == "/" ]]; then
path=${path%/} path=${path%/}
@ -56,9 +102,11 @@ fi
# Copy files to the right place # Copy files to the right place
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set "$app" final_path "$final_path"
# PHP-FPM and && Conf #=================================================
# PHP-FPM CONFIGURATION
#=================================================
POOL_FPM POOL_FPM
# We download the sources and check the md5sum # We download the sources and check the md5sum
@ -68,6 +116,10 @@ sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && f
sudo tar xvf ${SFILE}.tar.gz -C ../sources/ sudo tar xvf ${SFILE}.tar.gz -C ../sources/
sudo cp -r -a ../sources/roadiz-0.17.0/. $final_path sudo cp -r -a ../sources/roadiz-0.17.0/. $final_path
#=================================================
# SPECIFIC SETUP
#=================================================
# Modify the config.yml # Modify the config.yml
sed -i "s@db_user@$db_user@g" ../conf/config.yml sed -i "s@db_user@$db_user@g" ../conf/config.yml
sed -i "s@db_pass@$db_pass@g" ../conf/config.yml sed -i "s@db_pass@$db_pass@g" ../conf/config.yml
@ -95,7 +147,10 @@ sudo rm $final_path/install.php
# Modify Nginx configuration file and copy it to Nginx conf directory #=================================================
# NGINX CONFIGURATION
#=================================================
sed -i "s@ROOT_PATH@$final_path@g" ../conf/nginx.conf sed -i "s@ROOT_PATH@$final_path@g" ../conf/nginx.conf
sed -i "s@APP_URL@$domain$path/@g" ../conf/nginx.conf sed -i "s@APP_URL@$domain$path/@g" ../conf/nginx.conf
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf