diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..25328ed --- /dev/null +++ b/conf/app.src @@ -0,0 +1,4 @@ +SOURCE_URL=https://github.com/movim/movim/archive/v0.13.tar.gz +SOURCE_SUM=7aa5b2b6cd97e87a440981cfb6788a6f04ffd5eb4545026c49e1c61771593d11 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 803c6a8..b4c690b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,12 +3,6 @@ # Common variables # -# Git repository of Movim -GIT_REPO="https://github.com/movim/movim" - -# Commit to checkout -HEAD_COMMIT="ee249f1e37b548c71b9a339dd358fbd2136e3291" - # App package root directory should be the parent folder PKGDIR=$(cd ../; pwd) @@ -23,11 +17,11 @@ exec_cmd() { && sudo sudo -u movim "$@") } -# Apply the SSO patch to Movim source code -# usage: apply_sso_patch -apply_sso_patch() { - local patch_path="/tmp/sso-logout.patch" - cp -f "${PKGDIR}/patches/sso-logout.patch" "$patch_path" - exec_cmd git apply "$patch_path" - ynh_secure_remove "$patch_path" +# Undo the SSO patch to Movim source code (applied by default with ynh_setup_source) +# usage: undo_sso_patch +undo_sso_patch() { + ( + cd $final_path + patch -p1 -R < $YNH_CWD/../sources/patches/app-00-sso-logout.patch + ) } diff --git a/scripts/install b/scripts/install index 9a013f0..9e95ba5 100644 --- a/scripts/install +++ b/scripts/install @@ -106,12 +106,7 @@ ynh_install_app_dependencies php5-gd php5-curl php5-imagick php5-cli php5-zmq ynh_app_setting_set "$app" final_path "$final_path" -# Download Movim source code -tmp_path=/tmp/movim-git -ynh_secure_remove "$tmp_path" -(git clone "$GIT_REPO" "$tmp_path" \ - && cd "$tmp_path" && git checkout "$HEAD_COMMIT") \ - || ynh_die "Unable to download Movim source code." +ynh_setup_source "$final_path" #================================================= # SET CONFIGURATION FILE @@ -119,17 +114,14 @@ ynh_secure_remove "$tmp_path" # TODO: add checksum # Set database configuration -cp "${tmp_path}/config/"{db.example.inc.php,db.inc.php} +cp "$final_path/config/"{db.example.inc.php,db.inc.php} ynh_replace_string "'username' => 'username'" "'username' => '$db_user'" \ - "${tmp_path}/config/db.inc.php" + "$final_path/config/db.inc.php" ynh_replace_string "'password' => 'password'" "'password' => '$db_pwd'" \ - "${tmp_path}/config/db.inc.php" + "$final_path/config/db.inc.php" ## TODO: consider installation in a subpath ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ - "${tmp_path}/app/assets/js/movim_websocket.js" - -# Move Movim source code -mv "$tmp_path" "$final_path" + "$final_path/app/assets/js/movim_websocket.js" #================================================= # CREATE DEDICATED USER @@ -147,6 +139,10 @@ find "${final_path}/" -type f -print0 | xargs -0 chmod 0644 find "${final_path}/" -type d -print0 | xargs -0 chmod 0755 chmod 400 "${final_path}/config/db.inc.php" +#================================================= +# Install PHP dependencies using composer +#================================================= + # Install PHP dependencies using composer (curl -sS https://getcomposer.org/installer \ | exec_cmd php -- --install-dir="$final_path" \ @@ -212,9 +208,9 @@ cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf if [[ "$ssoenabled" = "No" ]]; then ynh_app_setting_set "$app" skipped_uris "/" exec_cmd php mud.php config --xmppwhitelist="$domain" + undo_sso_patch else ynh_app_setting_set "$app" unprotected_uris "/" - apply_sso_patch fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b81ae19..4f13db0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,33 +71,12 @@ ynh_install_app_dependencies php5-zmq # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# Init git repository as needed -if [ ! -d "${final_path}/.git" ]; then - tmp_path=/tmp/movim-git - ynh_secure_remove "$tmp_path" +ynh_setup_source "$final_path" - # Download Movim source code - (git clone "$GIT_REPO" "$tmp_path" \ - && cd "$tmp_path" && git checkout "$HEAD_COMMIT") \ - || ynh_die "Unable to download Movim source code." - cp "${final_path}/config/db.inc.php" "${tmp_path}/config/db.inc.php" +chown -R movim:www-data "$final_path" - # Replace current source code - ynh_secure_remove "$final_path" - mv "$tmp_path" "$final_path" - chown -R movim:www-data "$final_path" - - # Install composer for PHP dependencies - curl -sS https://getcomposer.org/installer \ - | exec_cmd php -- --install-dir="$final_path" -fi - -# Update Movim source code -(exec_cmd git fetch origin \ - && exec_cmd git reset --hard "$HEAD_COMMIT") \ - || ynh_die "Unable to download Movim source code." ## TODO: consider installation in a subpath -exec_cmd ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ +ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ "${final_path}/app/assets/js/movim_websocket.js" #================================================= @@ -121,6 +100,9 @@ chmod 400 "${final_path}/config/db.inc.php" # install PHP dependencies #================================================= +curl -sS https://getcomposer.org/installer \ +| exec_cmd php -- --install-dir="$final_path" + # Update PHP dependencies using composer (exec_cmd php composer.phar config --global discard-changes true \ && exec_cmd php composer.phar install --no-interaction) \ @@ -160,9 +142,9 @@ if [[ "$ssoenabled" = "No" ]]; then ynh_app_setting_set "$app" skipped_uris "/" exec_cmd php mud.php config --xmppwhitelist=$domain yunohost app ssowatconf + undo_sso_patch else ynh_app_setting_set "$app" unprotected_uris "/" - apply_sso_patch fi diff --git a/patches/sso-logout.patch b/sources/patches/app-00-sso-logout.patch similarity index 100% rename from patches/sso-logout.patch rename to sources/patches/app-00-sso-logout.patch