From a57bd732d1ad3052fb95a6bb3027c35974758d11 Mon Sep 17 00:00:00 2001 From: massyas Date: Fri, 27 Apr 2018 10:30:15 +0200 Subject: [PATCH] Working on install --- scripts/_common.sh | 36 +++++++++++++++++++++++++++++++++++- scripts/install | 5 +++-- scripts/remove | 8 -------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bb04a03..3aa3ac6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,4 +10,38 @@ ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name -} \ No newline at end of file +} + +# Package dependencies +pkg_dependencies="php5-cli php5-common php5-intl php5-json git" + +# composer from roundcube_ynh +# Execute a composer command from a given directory +# usage: composer_exec workdir COMMAND [ARG ...] +exec_composer() { + local workdir=$1 + shift 1 + + COMPOSER_HOME="${workdir}/.composer" \ + php "${workdir}/composer.phar" $@ \ + -d "${workdir}" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# usage: init_composer destdir +init_composer() { + local destdir=$1 + + # install composer + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="${destdir}/.composer" \ + php -- --quiet --install-dir="$destdir" \ + || ynh_die "Unable to install Composer" + + # install composer.json + cp "${destdir}/composer.json-dist" "${destdir}/composer.json" + + # update dependencies to create composer.lock + exec_composer "$destdir" install --no-dev \ + || ynh_die "Unable to install app using composer" +} diff --git a/scripts/install b/scripts/install index 923b076..e861186 100755 --- a/scripts/install +++ b/scripts/install @@ -77,7 +77,7 @@ ynh_app_setting_set $app port $port # INSTALL DEPENDENCIES #================================================= -ynh_install_app_dependencies git +ynh_install_app_dependencies "$pkg_dependencies" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -88,7 +88,8 @@ ynh_app_setting_set $app final_path $final_path #ynh_setup_source "$final_path" git clone "https://framagit.org/framasoft/PrettyNoemieCMS" "$final_path" cd "$final_path" -composer install + +init_composer "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/remove b/scripts/remove index 9f6aa8e..a3b859e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) port=$(ynh_app_setting_get $app port) db_name=$(ynh_app_setting_get $app db_name) -db_user=$db_name final_path=$(ynh_app_setting_get $app final_path) #================================================= @@ -47,13 +46,6 @@ fi # Remove metapackage and its dependencies ynh_remove_app_dependencies -#================================================= -# REMOVE THE MYSQL DATABASE -#================================================= - -# Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_user $db_name - #================================================= # REMOVE APP MAIN DIR #=================================================