diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..301672c --- /dev/null +++ b/scripts/install @@ -0,0 +1,82 @@ +#!/bin/bash + +source ./_common +source .fonctions +set -eu +source /usr/share/yunohost/helpers + +# Retrieve app id +app=$YNH_APP_INSTANCE_NAME + +# Retrieve arguments +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC +admin_name=$YNH_APP_ARG_ADMIN_NAME +admin_pass=$YNH_APP_ARG_ADMIN_PASS +admin_email=$YNH_APP_ARG_ADMIN_EMAIL + +# Vérifie que les variables ne sont pas vides. +CHECK_VAR "$app" "app name not set" + +CHECK_PATH # Vérifie et corrige la syntaxe du path. +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é. + +# Install dependency to convert tracks to a readable format for the browser +# sudo apt-get update +# sudo apt-get -y -qq install php5-mysql + +# Install dependencies using Helpers +ynh_package_install_from_equivs ../conf/abantecart-deps.control \ +|| ynh_die "Unable to install dependencies" + +# 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" +ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set "$app" admin_pass "$admin_pass" +ynh_app_setting_set "$app" admin_name "$admin_name" +ynh_app_setting_set "$app" admin_email "$admin_email" + +# Initialize database as needed + +db_name=$app +db_user=$app +db_pass=$(ynh_string_random) +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_pass "$db_pass" + +# Remove trailing "/" for next commands +if [[ ! "$path" == "/" ]]; then + path=${path%/} +fi + +# Copy files to the right place +final_path=/var/www/$app +ynh_app_setting_set "$app" final_path "$final_path" + +# We download the sources and check the md5sum +SFILE=`sudo cat ../sources/source_file`; +sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz +sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) +sudo tar xvf ${SFILE}.tar.gz -C ../sources/ +sudo cp -a ../sources/roadiz-src-master/. $final_path + +# Installation +# Get Composer: + + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf +sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf +nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf +sudo cp ../conf/nginx.conf $nginxconf +sudo chown root: $nginxconf +sudo chmod 644 $nginxconf