From e156919cdb8b650b4e3fe4b690810ed6efc3a6dd Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 24 Aug 2016 19:43:33 +0200 Subject: [PATCH] Make it multiinstance --- manifest.json | 2 +- scripts/install | 12 +++++++----- scripts/upgrade | 17 ++++++++++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/manifest.json b/manifest.json index 6471874..6bb192b 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "name": "julien", "email": "julien.malik@paraiso.me" }, - "multi_instance": "false", + "multi_instance": "true", "services": [ "nginx", "php5-fpm" diff --git a/scripts/install b/scripts/install index e9c0071..278b60d 100644 --- a/scripts/install +++ b/scripts/install @@ -8,8 +8,10 @@ domain=$1 path=$2 is_public=$3 +app=$YNH_APP_INSTANCE_NAME + # Check domain/path availability -sudo yunohost app checkurl $domain$path -a zerobin +sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then exit 1 fi @@ -20,7 +22,7 @@ if [[ ! "$path" == "/" ]]; then fi # Copy files to the right place -final_path=/var/www/zerobin +final_path=/var/www/$app sudo mkdir -p $final_path extract_source $final_path @@ -37,15 +39,15 @@ sudo chmod 700 $final_path/{data,tmp} # 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 -nginxconf=/etc/nginx/conf.d/$domain.d/zerobin.conf +nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf $nginxconf sudo chown root: $nginxconf sudo chmod 600 $nginxconf -sudo yunohost app setting zerobin is_public -v "$is_public" +sudo yunohost app setting $app is_public -v "$is_public" if [ "$is_public" = "Yes" ]; then - sudo yunohost app setting zerobin unprotected_uris -v "/" + sudo yunohost app setting $app unprotected_uris -v "/" fi sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index 3bbb239..a10da4a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,9 +3,12 @@ source /usr/share/yunohost/helpers source ./_common -domain=$(sudo yunohost app setting zerobin domain) -path=$(sudo yunohost app setting zerobin path) -is_public=$(sudo yunohost app setting zerobin is_public) +app=$YNH_APP_INSTANCE_NAME + +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) +is_public=$(sudo yunohost app setting $app is_public) + # Remove trailing "/" for next commands if [[ ! "$path" == "/" ]]; then @@ -13,7 +16,7 @@ if [[ ! "$path" == "/" ]]; then fi # Init final_path, if ever it got deleted somehow -final_path=/var/www/zerobin +final_path=/var/www/$app sudo mkdir -p $final_path # Clean up @@ -35,15 +38,15 @@ sudo chmod 700 $final_path/{data,tmp} # 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 -nginxconf=/etc/nginx/conf.d/$domain.d/zerobin.conf +nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf $nginxconf sudo chown root: $nginxconf sudo chmod 600 $nginxconf if [ "$is_public" = "Yes" ]; then - sudo yunohost app setting zerobin skipped_uris -d - sudo yunohost app setting zerobin unprotected_uris -v "/" + sudo yunohost app setting $app skipped_uris -d + sudo yunohost app setting $app unprotected_uris -v "/" fi sudo service nginx reload