From 7ac0f338011d3259cebe08d1cd998e7fc57e1af9 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Sat, 29 Aug 2015 02:30:09 +0200 Subject: [PATCH 1/6] Updated nginx.conf --- conf/nginx.conf | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 6577935..db624ba 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,19 +1,21 @@ location LOCATIONTOCHANGE { - alias ALIASTOCHANGE/; + alias ALIASTOCHANGE/; - try_files $uri $uri/ PATHTOCHANGE/yourls-loader.php; + try_files $uri $uri/ PATHTOCHANGE/yourls-loader.php; - index index.php index.html index.htm; + index index.php index.html index.htm; - location ~ \.php$ { - fastcgi_split_path_info ^(.+.php)(/.+)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } - + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } From 07f0e6e4f3cbea2e6ed2c8b9621330ca76347bf6 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Sat, 29 Aug 2015 02:30:34 +0200 Subject: [PATCH 2/6] Check admin user case insensitive --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 4b48183..e864bb8 100644 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,7 @@ exit 1 fi # Check that admin user is an existing account -sudo yunohost user list --json | grep -q "\"username\": \"$admin_user\"" +sudo yunohost user list --json | grep -qi "\"username\": \"$admin_user\"" if [[ ! $? -eq 0 ]]; then echo "Error : the chosen admin user does not exist" exit 1 From 9415f50f63b397150548c2a3fa22dd06811b9243 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Sat, 29 Aug 2015 02:30:41 +0200 Subject: [PATCH 3/6] Upgrade script --- scripts/install | 2 ++ scripts/upgrade | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 scripts/upgrade diff --git a/scripts/install b/scripts/install index e864bb8..5d9c4f8 100644 --- a/scripts/install +++ b/scripts/install @@ -17,6 +17,8 @@ if [[ ! $? -eq 0 ]]; then echo "Error : the chosen admin user does not exist" exit 1 fi +# Save admin user +sudo yunohost app setting yourls admin -v $admin_user # Generate random password db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..884a4f9 --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,47 @@ +#!/bin/bash + + +# Retrieve arguments +domain=$(sudo yunohost app setting yourls domain) +path=$(sudo yunohost app setting yourls path) +db_user=yourls +db_pwd=$(sudo yunohost app setting yourls mysqlpwd) +admin_user=$(sudo yunohost app setting yourls admin) + + +# Copy files to the right place +final_path=/var/www/yourls +sudo mkdir -p $final_path +sudo cp -a ../sources/* $final_path + +sudo cp ../conf/index.php $final_path/ +sudo cp -r ../conf/yunohost_auth $final_path/user/plugins + + +# Change variable in yourls configuration +sudo cp ../conf/config.php $final_path/user/config.php +sudo sed -i "s/yunouser/$db_user/g" $final_path/user/config.php +sudo sed -i "s/yunopass/$db_pwd/g" $final_path/user/config.php +sudo sed -i "s/yunobase/$db_user/g" $final_path/user/config.php +sudo sed -i "s/yunodomain/$domain/g" $final_path/user/config.php +sudo sed -i "s/yourlsuser/$admin_user/g" $final_path/user/config.php +sudo sed -i "s@_yourlspath@$path@g" $final_path/user/config.php + +# Set permissions +sudo chown -R www-data: $final_path + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@LOCATIONTOCHANGE@$path@g" ../conf/nginx.conf* +sed -i "s@PATHTOCHANGE@${path%/}@g" ../conf/nginx.conf* +sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/nginx.conf* +sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/nginx.conf* +nginxconf=/etc/nginx/conf.d/$domain.d/yourls.conf +sudo cp ../conf/nginx.conf $nginxconf +sudo chown root: $nginxconf +sudo chmod 600 $nginxconf + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload +sudo yunohost app setting yourls unprotected_uris -v "/" +sudo yunohost app ssowatconf + From 0581deaa55425789eb1654c95b38db37bcbb237d Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Sat, 29 Aug 2015 14:46:20 +0200 Subject: [PATCH 4/6] Correct yourls site url --- conf/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.php b/conf/config.php index e01ce43..db04337 100644 --- a/conf/config.php +++ b/conf/config.php @@ -29,7 +29,7 @@ define( 'YOURLS_DB_PREFIX', 'yourls_' ); /** YOURLS installation URL -- all lowercase and with no trailing slash. ** If you define it to "http://site.com", don't use "http://www.site.com" in your browser (and vice-versa) */ -define( 'YOURLS_SITE', 'http://yunodomain/_yourlspath' ); +define( 'YOURLS_SITE', 'https://yunodomain_yourlspath' ); /** Timezone GMT offset */ define( 'YOURLS_HOURS_OFFSET', 0 ); From 81d4aaf1f4fdc67b3f9a940afc8864ada96af673 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Sat, 29 Aug 2015 14:46:55 +0200 Subject: [PATCH 5/6] Tried something with url protection --- scripts/install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 5d9c4f8..f3b3361 100644 --- a/scripts/install +++ b/scripts/install @@ -72,10 +72,7 @@ curl -kL -X POST https://$domain$path/admin/install.php --data "install=dummy" > # Activate auth plugin mysql -u $db_user -p$db_pwd $db_user < ../conf/activate_plugins.sql - -#sudo yunohost app setting yourls skipped_uris -d -#sudo yunohost app setting yourls unprotected_uris -v "/admin" - +sudo yunohost app setting yourls protected_uris -v "/admin" sudo service nginx reload sudo yunohost app ssowatconf From a7985b5567cadc275c20570780a2ef0da6ece62e Mon Sep 17 00:00:00 2001 From: zamentur Date: Fri, 10 Jun 2016 12:09:26 +0200 Subject: [PATCH 6/6] [fix] Curl doesn't work if dns is not set --- scripts/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index f3b3361..9098bf5 100644 --- a/scripts/install +++ b/scripts/install @@ -68,11 +68,10 @@ sudo yunohost app setting yourls unprotected_uris -v "/" sudo yunohost app ssowatconf # Start Yourls install (database table creation) -curl -kL -X POST https://$domain$path/admin/install.php --data "install=dummy" > /dev/null 2>&1 +curl --header "Host: $domain" -kL -X POST https://127.0.0.1$path/admin/install.php --data "install=Install+YOURLS" > /dev/null 2>&1 # Activate auth plugin mysql -u $db_user -p$db_pwd $db_user < ../conf/activate_plugins.sql sudo yunohost app setting yourls protected_uris -v "/admin" sudo service nginx reload sudo yunohost app ssowatconf -