From ce9f074327d7a55af3a70ec0a0c4a49a25110e29 Mon Sep 17 00:00:00 2001 From: ewilly Date: Mon, 18 Sep 2017 20:05:03 +0200 Subject: [PATCH 1/6] Update upstream version --- conf/upstream_version | 2 +- scripts/install | 16 +++++++++++++--- scripts/upgrade | 12 ++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/conf/upstream_version b/conf/upstream_version index 22cafd0..17e774d 100644 --- a/conf/upstream_version +++ b/conf/upstream_version @@ -1 +1 @@ -1bc078ddfcbdfebb301b49fe87fd805b6cb89a5a +670d3fa88f2e3c0f5cee1de14e7a1d5c113b106d diff --git a/scripts/install b/scripts/install index 61fe699..fe75546 100644 --- a/scripts/install +++ b/scripts/install @@ -65,11 +65,21 @@ fi sudo mv "$TMPDIR" "$final_path" # configure config file + # language ynh_replace_string "default_language='en'" "default_language='$language'" "$bozon_conf" -ynh_store_file_checksum "$bozon_conf" + + # max upload file size +case ${filesize: -1} in + g|G) + max_length=$((${filesize%?}*1024)) + ;; + *) + max_length=${filesize%?} + ;; + esac +ynh_replace_string "max_length=2048" "max_length=$max_length" "$bozon_conf" -# update auto_dropzone.php -myynh_update_bozon_auto_dropzone +ynh_store_file_checksum "$bozon_conf" # create private & data folders myynh_create_dir "$final_path/private" diff --git a/scripts/upgrade b/scripts/upgrade index f87bc8c..636c5ed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -75,8 +75,16 @@ fi sudo cp -a "$TMPDIR/." "$final_path" sudo rm -R "$TMPDIR" -# update auto_dropzone.php -myynh_update_bozon_auto_dropzone +# update config.php with 'max_length' line +case ${filesize: -1} in + g|G) + max_length=$((${filesize%?}*1024)) + ;; + *) + max_length=${filesize%?} + ;; + esac +sed -i "54i\$max_length=$max_length;" "$bozon_conf" # set permissions myynh_set_permissions From a5661f86e9bfb2235fe95254f10d11b90f34481a Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 22 Sep 2017 19:33:28 +0200 Subject: [PATCH 2/6] Clean & refractoring --- conf/app.src | 4 +-- conf/upstream_version | 1 - manifest.json | 2 +- scripts/_common.sh | 74 ++++--------------------------------------- scripts/install | 18 ++++------- scripts/remove | 4 +-- scripts/upgrade | 36 +++------------------ 7 files changed, 22 insertions(+), 117 deletions(-) delete mode 100644 conf/upstream_version diff --git a/conf/app.src b/conf/app.src index 3712b4d..362d432 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/06f2a665f45e3e8f4c4bf71bf4146e8accb27776.zip -SOURCE_SUM=d82dddd968a8cb31e21d1fb3e0518f4b88d92ec95948d652c0c378fce4dc8e65 +SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/670d3fa88f2e3c0f5cee1de14e7a1d5c113b106d.zip +SOURCE_SUM=93030a6e4ac9910e849228ddefb81bba1b78520c1e7407b78a331ccc5aa01f5c SOURCE_FORMAT=zip #sha256sum obtain with shasum -a 256 $SOURCE_URL diff --git a/conf/upstream_version b/conf/upstream_version deleted file mode 100644 index 17e774d..0000000 --- a/conf/upstream_version +++ /dev/null @@ -1 +0,0 @@ -670d3fa88f2e3c0f5cee1de14e7a1d5c113b106d diff --git a/manifest.json b/manifest.json index 6594363..5719e2a 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "ewilly@neuf.fr" }, "requirements": { - "yunohost": ">= 2.6.3" + "yunohost": ">= 2.7.2" }, "multi_instance": false, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 83aa435..82cfe10 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -30,6 +30,12 @@ myynh_check_disk_space () { fi } +# Clean & copy files needed to final folder +myynh_clean_source () { + find "$TMPDIR" -type f -name ".htaccess" | xargs rm + [ -e "$TMPDIR/.gitignore" ] && rm -r "$TMPDIR/.gitignore" +} + # Create a dedicated nginx config myynh_add_nginx_config () { ynh_backup_if_checksum_is_different "$nginx_conf" 1 @@ -52,12 +58,6 @@ myynh_add_nginx_config () { sudo systemctl reload nginx } -# Remove the dedicated nginx config -myynh_remove_nginx_config () { - ynh_secure_remove "$nginx_conf" - sudo systemctl reload nginx -} - # Create a dedicated php-fpm config myynh_add_fpm_config () { ynh_backup_if_checksum_is_different "$phpfpm_conf" 1 @@ -82,65 +82,3 @@ myynh_set_permissions () { sudo chown -R "$app": "$data_path" sudo chown root: "$data_path" } - -# Remove the dedicated php-fpm config -myynh_remove_fpm_config () { - ynh_secure_remove "$phpfpm_conf" - sudo systemctl restart php5-fpm -} - -# Update the according fo filesize -myynh_update_bozon_auto_dropzone () { - case ${filesize: -1} in - g|G) - max_length=$((${filesize%?}*1024)) - ;; - *) - max_length=${filesize%?} - ;; - esac - if [ -e "$bozon_auto_dropzone_php" ];then - ynh_replace_string "'max_length'=>2048" "'max_length'=>$max_length" "$bozon_auto_dropzone_php" - fi -} - -#================================================= -# FUTURE YUNOHOST HELPERS - TO BE REMOVED LATER -#================================================= -# Restore a previous backup if the upgrade process failed -ynh_backup_after_failed_upgrade () { - echo "Upgrade failed." >&2 - app_bck=${app//_/-} # Replace all '_' by '-' - # Check if a existing backup can be found before remove and restore the application. - if sudo yunohost backup list | grep -q $app_bck-upg$backup_number; then - # Remove the application then restore it - sudo yunohost app remove $app - # Restore the backup if the upgrade failed - sudo yunohost backup restore --ignore-system $app_bck-upg$backup_number --apps $app --force - ynh_die "The app was restored to the way it was before the failed upgrade." - fi -} - -# Make a backup in case of failed upgrade -ynh_backup_before_upgrade () { - backup_number=1 - old_backup_number=2 - app_bck=${app//_/-} # Replace all '_' by '-' - # Check if a backup already exist with the prefix 1. - if sudo yunohost backup list | grep -q $app_bck-upg1; then - # Prefix become 2 to preserve the previous backup - backup_number=2 - old_backup_number=1 - fi - # Create another backup - sudo yunohost backup create --ignore-system --apps $app --name $app_bck-upg$backup_number - if [ "$?" -eq 0 ]; then - # If the backup succedded, remove the previous backup - if sudo yunohost backup list | grep -q $app_bck-upg$old_backup_number; then - # Remove the previous backup only if it exists - sudo yunohost backup delete $app_bck-upg$old_backup_number > /dev/null - fi - else - ynh_die "Backup failed, the upgrade process was aborted." - fi -} diff --git a/scripts/install b/scripts/install index fe75546..e3bc4bf 100644 --- a/scripts/install +++ b/scripts/install @@ -55,14 +55,8 @@ TMPDIR=$(mktemp -d) ynh_setup_source "$TMPDIR" # clean & copy files needed to final folder -sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm -if [ -e "$TMPDIR/.gitignore" ]; then - for f in $(sudo cat "$TMPDIR/.gitignore") ; do - [ -e "$TMPDIR$f" ] && sudo rm -R "$TMPDIR$f" - done - sudo rm "$TMPDIR/.gitignore" -fi -sudo mv "$TMPDIR" "$final_path" +myynh_clean_source +mv "$TMPDIR" "$final_path" # configure config file # language @@ -85,8 +79,8 @@ ynh_store_file_checksum "$bozon_conf" myynh_create_dir "$final_path/private" myynh_create_dir "$data_path/uploads" myynh_create_dir "$data_path/thumbs" -sudo ln -s "$data_path/uploads" "$final_path/uploads" -sudo ln -s "$data_path/thumbs" "$final_path/thumbs" +ln -s "$data_path/uploads" "$final_path/uploads" +ln -s "$data_path/thumbs" "$final_path/thumbs" # set permissions myynh_set_permissions @@ -99,7 +93,7 @@ myynh_add_fpm_config # set temporary public access for curl call ynh_app_setting_set "$app" unprotected_uris "/" -sudo yunohost app ssowatconf +yunohost app ssowatconf # fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?) curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 https://localhost"$path_url"/ > /dev/null 2>&1 @@ -119,5 +113,5 @@ then pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$" ynh_app_setting_set "$app" protected_regex "$regexList" - sudo yunohost app ssowatconf + yunohost app ssowatconf fi diff --git a/scripts/remove b/scripts/remove index dde330e..97d0de9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,10 +39,10 @@ ynh_remove_app_dependencies ynh_secure_remove "$final_path" # remove the dedicated nginx config -myynh_remove_nginx_config +ynh_remove_nginx_config # remove the dedicated php-fpm config -myynh_remove_fpm_config +ynh_remove_fpm_config # remove a directory securely ynh_secure_remove "$data_path" diff --git a/scripts/upgrade b/scripts/upgrade index 636c5ed..ab93ebb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,26 +33,6 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then } fi -# retrieve & save real/right value if argument was not saved as a app setting in a previous realease -if [ -z "$filesize" ]; then # in old script filesize was not saved as a setting - filesize=$(cat "$nginx_conf" | grep -Po "client_max_body_size \K.*?(?=;)") - ynh_app_setting_set "$app" filesize "$filesize" -fi -if [ -z "$language" ]; then # in old script language was not saved as a setting - language=$(cat "$bozon_conf" | grep -Po "default_language='\K.*?(?=')") - ynh_app_setting_set "$app" language "$language" -fi -if [ "$is_public" = "Yes" ]; then # in old script is_public was not a boolean - ynh_app_setting_set "$app" is_public 1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set "$app" is_public 0 - is_public=0 -fi -if [ -z "$backup_core_only" ]; then # in old script backup_core_only was not a setting - ynh_app_setting_set "$app" backup_core_only 1 -fi - # add required packages ynh_install_app_dependencies "$PKG_DEPENDENCIES" @@ -64,16 +44,10 @@ TMPDIR=$(mktemp -d) ynh_setup_source "$TMPDIR" # clean & copy files needed to final folder -sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm -if [ -e "$TMPDIR/.gitignore" ]; then - for f in $(sudo cat "$TMPDIR/.gitignore") ; do - [ -e "$TMPDIR$f" ] && sudo rm -R "$TMPDIR$f" - done - sudo rm "$TMPDIR/.gitignore" -fi -[ -e "$TMPDIR/config.php" ] && sudo rm "$TMPDIR/config.php" -sudo cp -a "$TMPDIR/." "$final_path" -sudo rm -R "$TMPDIR" +myynh_clean_source +[ -e "$TMPDIR/config.php" ] && rm "$TMPDIR/config.php" +cp -a "$TMPDIR/." "$final_path" +rm -R "$TMPDIR" # update config.php with 'max_length' line case ${filesize: -1} in @@ -107,7 +81,7 @@ then else ynh_app_setting_set "$app" unprotected_uris "/" fi -sudo yunohost app ssowatconf +yunohost app ssowatconf # Purge php sessions stored in /var/lib/php5/sessions [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean From 057daa700abc16bb5583bdee703a92d10990aead Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 22 Sep 2017 19:55:09 +0200 Subject: [PATCH 3/6] Clean & refractoring --- scripts/backup | 4 ++-- scripts/install | 2 -- scripts/remove | 8 ++++---- scripts/restore | 8 ++++---- scripts/upgrade | 1 - 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/scripts/backup b/scripts/backup index bcb2b3a..142b445 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,8 +6,8 @@ set -eu if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers diff --git a/scripts/install b/scripts/install index e3bc4bf..9ffd6ba 100644 --- a/scripts/install +++ b/scripts/install @@ -93,7 +93,6 @@ myynh_add_fpm_config # set temporary public access for curl call ynh_app_setting_set "$app" unprotected_uris "/" -yunohost app ssowatconf # fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?) curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 https://localhost"$path_url"/ > /dev/null 2>&1 @@ -113,5 +112,4 @@ then pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$" ynh_app_setting_set "$app" protected_regex "$regexList" - yunohost app ssowatconf fi diff --git a/scripts/remove b/scripts/remove index 97d0de9..db99523 100644 --- a/scripts/remove +++ b/scripts/remove @@ -5,8 +5,8 @@ set -u if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers @@ -25,10 +25,10 @@ nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf" phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf" # create a full backup (core+datas) if app installed -if [ $(sudo yunohost app list -i -f "$app" | wc -l) -gt 1 ]; then +if [ $(yunohost app list -i -f "$app" | wc -l) -gt 1 ]; then ynh_app_setting_set "$app" backup_core_only 0 app_bck=${app//_/-} - sudo yunohost backup create --ignore-system --apps "$app" --name "${app_bck}_$(date '+%Y%m%d-%H%M%S')" + yunohost backup create --ignore-system --apps "$app" --name "${app_bck}_$(date '+%Y%m%d-%H%M%S')" echo "BoZon fully backuped." >&2 fi diff --git a/scripts/restore b/scripts/restore index f51791e..fd155eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,8 +7,8 @@ set -eu if [ ! -e _common.sh ]; then # Fetch helpers file if not in current directory - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers @@ -61,5 +61,5 @@ fi myynh_set_permissions # restart services -sudo systemctl reload php5-fpm -sudo systemctl reload nginx +systemctl reload php5-fpm +systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index ab93ebb..3ea07e7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,6 @@ then else ynh_app_setting_set "$app" unprotected_uris "/" fi -yunohost app ssowatconf # Purge php sessions stored in /var/lib/php5/sessions [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean From 812ed49fd9304dbdab58fc162b3916fbd8636b39 Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 22 Sep 2017 20:13:59 +0200 Subject: [PATCH 4/6] Update Readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 79b2e79..865655b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ Minimalist Drag & drop file sharing app [![Install BoZoN with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=bozon) +[![Integration level](https://dash.yunohost.org/integration/bozon.svg)](https://ci-apps.yunohost.org/jenkins/job/bozon%20%28Community%29/lastBuild/consoleFull) + +## Links * [BoZoN website](http://bozon.pw) * [BoZoN git repository](https://github.com/broncowdd/BoZoN) * [YunoHost website](https://yunohost.org/) From d3eb51a6c7c19d2d70f37854dc06b3b5d516b285 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sat, 23 Sep 2017 09:32:18 +0200 Subject: [PATCH 5/6] Only add max_length line in config.php if does not exist yet --- scripts/upgrade | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3ea07e7..4898b81 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,8 +49,9 @@ myynh_clean_source cp -a "$TMPDIR/." "$final_path" rm -R "$TMPDIR" -# update config.php with 'max_length' line -case ${filesize: -1} in +# Only add 'max_length' line in config.php if does not exist yet +if [ $(grep "max_length=" "$bozon_conf" | wc -l) -eq 0 ]; then + case ${filesize: -1} in g|G) max_length=$((${filesize%?}*1024)) ;; @@ -58,7 +59,8 @@ case ${filesize: -1} in max_length=${filesize%?} ;; esac -sed -i "54i\$max_length=$max_length;" "$bozon_conf" + sed -i "54i\$max_length=$max_length;" "$bozon_conf" +fi # set permissions myynh_set_permissions From df902c08df13dc6a6334c80af3f24cd6fc5cfbcd Mon Sep 17 00:00:00 2001 From: ewilly Date: Sat, 23 Sep 2017 19:01:29 +0200 Subject: [PATCH 6/6] Fix admin account registration --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 9ffd6ba..f014c52 100644 --- a/scripts/install +++ b/scripts/install @@ -93,6 +93,7 @@ myynh_add_fpm_config # set temporary public access for curl call ynh_app_setting_set "$app" unprotected_uris "/" +yunohost app ssowatconf # fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?) curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 https://localhost"$path_url"/ > /dev/null 2>&1