From eb0f02c0cc8150a7c8eb5e196d76f12cc96a6b67 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 13:50:20 +0100 Subject: [PATCH 01/13] [fix] license in manifest is deprecated --- manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.json b/manifest.json index 8e8076c..85b197f 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,6 @@ "url": "" }, "multi_instance": "false", - "license": "GPL", "arguments": { "install" : [ { From 8f5ed2d81ba3086378588118d4d321a7faad3158 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 13:56:51 +0100 Subject: [PATCH 02/13] [fix] remove bad substitution This causes the following error : install: line 13: ${$domain%?}: bad substitution I guess the intended subtitution was : domain=${domain%?} instead, which removes the last character of domain, and thus is wrong. --- scripts/install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 5d02da8..81d2916 100644 --- a/scripts/install +++ b/scripts/install @@ -10,9 +10,6 @@ password=$4 is_public=$5 default_lang=$6 -domain=${$domain%?} - - # Check domain/path availability sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then @@ -73,4 +70,4 @@ sudo yunohost app addaccess $app -u $admin sudo rm -f $final_path/install.php # Restart services sudo service nginx reload -sudo yunohost app ssowatconf \ No newline at end of file +sudo yunohost app ssowatconf From a0e71cd73c7e50331fec49a93a2977aa8a6da1ac Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 14:04:17 +0100 Subject: [PATCH 03/13] [enh] indentation --- scripts/install | 8 ++++---- scripts/upgrade | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 81d2916..7d63c2b 100644 --- a/scripts/install +++ b/scripts/install @@ -13,14 +13,14 @@ default_lang=$6 # Check domain/path availability sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then -exit 1 + exit 1 fi # Check user sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" if [[ ! $? -eq 0 ]]; then -echo "Wrong user" -exit 1 + echo "Wrong user" + exit 1 fi # Save app settings @@ -61,7 +61,7 @@ sudo chmod 750 -R $final_path # If app is private, remove url to SSOWat conf from skipped_uris if [ "$is_public" = "No" ]; then -sudo yunohost app setting $app unprotected_uris -d + sudo yunohost app setting $app unprotected_uris -d fi #adding admin to the allowed users diff --git a/scripts/upgrade b/scripts/upgrade index ac204c1..b9eade8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,9 +25,9 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # If app is public, add url to SSOWat conf as skipped_uris if [ "$is_public" = "Yes" ]; then -sudo yunohost app setting $app unprotected_uris -v "/" + sudo yunohost app setting $app unprotected_uris -v "/" fi # Restart services sudo service nginx reload -sudo yunohost app ssowatconf \ No newline at end of file +sudo yunohost app ssowatconf From 9aa650a52baa20ceaed5250a44cba26daf4f7f5f Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 14:14:56 +0100 Subject: [PATCH 04/13] [enh] set permission to root except data dir --- scripts/install | 6 ++++-- scripts/upgrade | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 7d63c2b..6018a86 100644 --- a/scripts/install +++ b/scripts/install @@ -35,7 +35,10 @@ sudo mkdir -p $final_path #copy files to final folder and set permissions sudo cp -R ../sources/* $final_path/ -sudo chown www-data:www-data -R $final_path +sudo chown -R root: $final_path +sudo chown -R www-data: $final_path/data +sudo find $final_path -type f | xargs sudo chmod 644 +sudo find $final_path -type d | xargs sudo chmod 755 #configure nginx settings sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf @@ -56,7 +59,6 @@ sudo curl -kL -o install_page.html https://$domain/$path/install.php >/dev/null token=$(sudo cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2) #send http POST values sudo curl -k -X POST --data "default_lang=$default_lang&install=Installer&name=$admin&login=$admin&pwd=$password&pwd2=$password&token=$token" https://$domain/$path/install.php >/dev/null 2>&1 -sudo chmod 750 -R $final_path # If app is private, remove url to SSOWat conf from skipped_uris if [ "$is_public" = "No" ]; diff --git a/scripts/upgrade b/scripts/upgrade index b9eade8..f23369d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,6 +17,12 @@ final_path=/var/www/$app sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path +sudo chown -R root: $final_path +sudo chown -R www-data: $final_path/data +sudo find $final_path -type f | xargs sudo chmod 644 +sudo find $final_path -type d | xargs sudo chmod 755 + + #configure nginx settings sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf From 73b09ca6190a6a8fa9d2f6064a759a0b9eacff4f Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 14:23:41 +0100 Subject: [PATCH 05/13] [enh] add type tag to manifest install params --- manifest.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.json b/manifest.json index 85b197f..e338297 100644 --- a/manifest.json +++ b/manifest.json @@ -15,6 +15,7 @@ "install" : [ { "name": "domain", + "type": "domain", "ask": { "en": "Choose a domain for pluxml", "fr": "Choisissez un domaine pour pluxml" @@ -23,6 +24,7 @@ }, { "name": "path", + "type": "path", "ask": { "en": "Choose a path for pluxml", "fr": "Choisissez un chemin pour pluxml" @@ -32,6 +34,7 @@ }, { "name": "admin", + "type": "user", "ask": { "en": "Choose an admin user for pluxml", "fr": "Choisissez un administrateur pour pluxml" @@ -40,6 +43,7 @@ }, { "name": "password", + "type": "password", "ask": { "en": "Choose an admin password for pluxml", "fr": "Choisissez un mot de passe administrateur pour pluxml" From 2399c9dc38363617668cc5b340568028578f00f2 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 14:39:11 +0100 Subject: [PATCH 06/13] [enh] urlencode when sending param via curl, and clearer command line --- scripts/install | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 6018a86..0e4810a 100644 --- a/scripts/install +++ b/scripts/install @@ -58,7 +58,15 @@ sudo curl -kL -o install_page.html https://$domain/$path/install.php >/dev/null #get the token for form validation token=$(sudo cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2) #send http POST values -sudo curl -k -X POST --data "default_lang=$default_lang&install=Installer&name=$admin&login=$admin&pwd=$password&pwd2=$password&token=$token" https://$domain/$path/install.php >/dev/null 2>&1 +sudo curl -k -X POST \ + --data-urlencode "default_lang=$default_lang" \ + --data-urlencode "install=Installer" \ + --data-urlencode "name=$admin" \ + --data-urlencode "login=$admin" \ + --data-urlencode "pwd=$password" \ + --data-urlencode "pwd2=$password" \ + --data-urlencode "token=$token" \ + https://$domain/$path/install.php > /dev/null 2>&1 # If app is private, remove url to SSOWat conf from skipped_uris if [ "$is_public" = "No" ]; From 2fa610ec99af18e96f2847a05c5aea9788f101f1 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 14:42:57 +0100 Subject: [PATCH 07/13] [fix] remove unnecessary sudo --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 0e4810a..e27e5a3 100644 --- a/scripts/install +++ b/scripts/install @@ -54,11 +54,11 @@ sudo yunohost app ssowatconf #make request to install app #get the html page -sudo curl -kL -o install_page.html https://$domain/$path/install.php >/dev/null 2>&1 +curl -kL -o install_page.html https://$domain/$path/install.php >/dev/null 2>&1 #get the token for form validation token=$(sudo cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2) #send http POST values -sudo curl -k -X POST \ +curl -k -X POST \ --data-urlencode "default_lang=$default_lang" \ --data-urlencode "install=Installer" \ --data-urlencode "name=$admin" \ From ef7bd4371666feb923b15018b6bad2af5eae585c Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 15:01:27 +0100 Subject: [PATCH 08/13] [fix] yet another unnecessary sudo --- scripts/install | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index e27e5a3..9e1c528 100644 --- a/scripts/install +++ b/scripts/install @@ -56,7 +56,7 @@ sudo yunohost app ssowatconf #get the html page curl -kL -o install_page.html https://$domain/$path/install.php >/dev/null 2>&1 #get the token for form validation -token=$(sudo cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2) +token=$(cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2) #send http POST values curl -k -X POST \ --data-urlencode "default_lang=$default_lang" \ @@ -68,6 +68,8 @@ curl -k -X POST \ --data-urlencode "token=$token" \ https://$domain/$path/install.php > /dev/null 2>&1 +sudo rm -f $final_path/install.php + # If app is private, remove url to SSOWat conf from skipped_uris if [ "$is_public" = "No" ]; then @@ -77,7 +79,6 @@ fi #adding admin to the allowed users sudo yunohost app addaccess $app -u $admin -sudo rm -f $final_path/install.php # Restart services sudo service nginx reload sudo yunohost app ssowatconf From a9618b2dfaa568b3ef67433f50a5c313bd33e48d Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 15:57:08 +0100 Subject: [PATCH 09/13] [fix] fix permission issue on data dir --- conf/nginx.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 90fe813..3d18ce7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -12,6 +12,10 @@ location YNH_EXAMPLE_PATH { fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; } + location YNH_EXAMPLE_PATH/data { + deny all; + return 403; + } # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } From 6d97f1acb547dd09063564fc5a797b8f7d02cb95 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 16:05:08 +0100 Subject: [PATCH 10/13] [enh] remove additionnal / --- scripts/install | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 9e1c528..e9dcc32 100644 --- a/scripts/install +++ b/scripts/install @@ -35,6 +35,8 @@ sudo mkdir -p $final_path #copy files to final folder and set permissions sudo cp -R ../sources/* $final_path/ + +#setup permissions sudo chown -R root: $final_path sudo chown -R www-data: $final_path/data sudo find $final_path -type f | xargs sudo chmod 644 @@ -45,7 +47,7 @@ sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf -#temporal set public acessible +#temporary set public accessible sudo yunohost app setting $app unprotected_uris -v "/" # Restart services @@ -66,7 +68,7 @@ curl -k -X POST \ --data-urlencode "pwd=$password" \ --data-urlencode "pwd2=$password" \ --data-urlencode "token=$token" \ - https://$domain/$path/install.php > /dev/null 2>&1 + https://$domain$path/install.php > /dev/null 2>&1 sudo rm -f $final_path/install.php From e2e5ef10ef38b2476aa5e6194f3c17d09f921e1d Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 16:07:40 +0100 Subject: [PATCH 11/13] [enh] remove useless .htaccess --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index e9dcc32..9f516a1 100644 --- a/scripts/install +++ b/scripts/install @@ -35,6 +35,7 @@ sudo mkdir -p $final_path #copy files to final folder and set permissions sudo cp -R ../sources/* $final_path/ +sudo find $final_path -type f -name ".htaccess" | xargs sudo rm #setup permissions sudo chown -R root: $final_path From 7cbf289dee28d619c4d5606fcf24d4b23df67da4 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 16:09:14 +0100 Subject: [PATCH 12/13] [enh] remove useless .htaccess --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index f23369d..efa4132 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,6 +16,7 @@ path=${path%/} final_path=/var/www/$app sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path +sudo find $final_path -type f -name ".htaccess" | xargs sudo rm sudo chown -R root: $final_path sudo chown -R www-data: $final_path/data From 71c34b27815fb1244c03045c3bc7976981789c3b Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 17 Nov 2014 16:11:42 +0100 Subject: [PATCH 13/13] [fix] remove install.php when upgrading --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index efa4132..8c630c2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,6 +17,7 @@ final_path=/var/www/$app sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path sudo find $final_path -type f -name ".htaccess" | xargs sudo rm +sudo rm $final_path/install.php sudo chown -R root: $final_path sudo chown -R www-data: $final_path/data