From 6dd08e539ce48fd80dd0c4fa636e32f8cd51e621 Mon Sep 17 00:00:00 2001 From: ewilly Date: Tue, 26 Apr 2016 20:17:27 +0200 Subject: [PATCH 1/2] Fix #8 --- manifest.json | 9 --------- scripts/install | 25 ++++++++++++------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/manifest.json b/manifest.json index 364146b..dcd234f 100644 --- a/manifest.json +++ b/manifest.json @@ -63,15 +63,6 @@ }, "default": "2G" }, - { - "name": "version", - "ask": { - "en": "Select the version of BoZoN you want to install", - "fr": "Sélectionnez la version de BoZoN que vous souhaitez installer" - }, - "choices": ["Stable","Latest"], - "default": "Stable" - }, { "name": "admin", "type": "user", diff --git a/scripts/install b/scripts/install index fefc269..dfecf96 100644 --- a/scripts/install +++ b/scripts/install @@ -2,6 +2,8 @@ # causes the shell to exit if any subcommand or pipeline returns a non-zero status set -e +# causes the shell to exit if you try to use an uninitialised variable +set -u # retrieve arguments domain=$1 @@ -9,9 +11,8 @@ path=$2 is_public=$3 default_lang=$4 filesize=$5 -version=$6 -admin=$7 -password=$8 +admin=$6 +password=$7 # definie useful vars app=bozon @@ -35,22 +36,20 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi +# retrieve stable version of bozon +stable=$(cat ../BoZoN-stable) + # save app settings sudo yunohost app setting $app admin_user -v "$admin" sudo yunohost app setting $app is_public -v "$is_public" sudo yunohost app setting $app domain -v "$domain" sudo yunohost app setting $app path -v "$path" +sudo yunohost app setting $app version -v "$stable" -# download bozon -if [ "$version" = "Latest" ]; -then - sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip -O $parent_path/master.zip -else - stable=$(curl https://raw.githubusercontent.com/ewilly/bozon_ynh/master/BoZoN-stable) - sudo wget https://github.com/broncowdd/BoZoN/archive/$stable.zip -O $parent_path/master.zip -fi -sudo unzip $parent_path/master.zip -d $parent_path/ -sudo rm $parent_path/master.zip +# download stable version of bozon +sudo wget https://github.com/broncowdd/BoZoN/archive/$stable.zip -O $parent_path/bozon-$stable.zip +sudo unzip $parent_path/bozon-$stable.zip -d $parent_path/ +sudo rm $parent_path/bozon-$stable.zip sudo mv $parent_path/BoZoN-* $parent_path/$app # add required packages From dcbd049842a6e87494e081e6659a83790ba9f292 Mon Sep 17 00:00:00 2001 From: ewilly Date: Tue, 26 Apr 2016 20:17:50 +0200 Subject: [PATCH 2/2] Fix upgrade --- scripts/upgrade | 57 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9bd1814..b6284e1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -2,21 +2,56 @@ # causes the shell to exit if any subcommand or pipeline returns a non-zero status set -e - -app=bozon -parent_path=/var/www -final_path=$parent_path/$app -data_path=/home/yunohost.app/$app +# causes the shell to exit if you try to use an uninitialised variable +set -u # retrieve arguments path=$(sudo yunohost app setting $app path) +stable=$(sudo yunohost app setting $app version) +is_public=$(sudo yunohost app setting $app is_public) -# download bozon -sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip -O $parent_path/master.zip -sudo unzip $parent_path/master.zip -d $parent_path/ -sudo rm $parent_path/master.zip -sudo rsync -avz --exclude="config.php" --exclude=".htaccess" $parent_path/BoZoN-master/* $parent_path/$app/ -sudo rm -R $parent_path/BoZoN-master +# definie useful vars +app=bozon +parent_path=/var/www +data_path=/home/yunohost.app/$app +final_path=$parent_path/$path + +# retrieve stable version of bozon +stable=$(cat ../BoZoN-stable) + +# download stable version of bozon +sudo wget https://github.com/broncowdd/BoZoN/archive/$stable.zip -O $parent_path/bozon-$stable.zip +sudo unzip $parent_path/bozon-$stable.zip -d $parent_path/ +sudo rm $parent_path/bozon-$stable.zip +sudo rsync -avz --exclude="config.php" --exclude=".htaccess" $parent_path/BoZoN-$stable/* $final_path +sudo rm -R $parent_path/BoZoN-$stable + +# configure nginx settings +## file upload size limit +postsize=$(echo "${filesize%?}.1${filesize: -1}") +sudo sed -i "s@YNH_FILE_SIZE@$filesize@g" ../conf/nginx.conf +sudo sed -i "s@YNH_POST_SIZE@$postsize@g" ../conf/nginx.conf +## path +folder_path=${path%/} +sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf +# if path is only / (without subfolder), add trailing slash to alias +alias_path=$final_path +[ "$path" == '/' ] && alias_path=$alias_path'/' +sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" ../conf/nginx.conf +sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" ../conf/nginx.conf + +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +# if app is private, remove url to SSOWat conf from skipped_uris +if [ "$is_public" = "No" ]; +then + # escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html) + domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') + pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') + # redirect to SSOwat login in + sudo yunohost app setting $app unprotected_uris -d + sudo yunohost app setting $app unprotected_regex -v "$domainluaregex$pathluaregex/index.php%?f=.+$","$domainluaregex$pathluaregex/index.php%?zipfolder=.+$","$domainluaregex$pathluaregex/private/temp/.+%.zip$","$domainluaregex$pathluaregex/core/js/.*$","$domainluaregex$pathluaregex/templates/.*$" +fi # Restart services sudo service nginx reload