From 7bd69fbc1bac9734cf3b1c4bad3285c865cd03d7 Mon Sep 17 00:00:00 2001 From: Hayden Date: Sun, 11 Feb 2024 13:05:53 -0800 Subject: [PATCH 01/12] fix subdomain installations --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 28274c0..fda7377 100755 --- a/scripts/install +++ b/scripts/install @@ -41,7 +41,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/config.php" --destination="$install_dir/config.php" +if "$path" == "/" then ynh_add_config --template="../conf/config-subdomain.php" --destination="$install_dir/config.php" else ynh_add_config --template="../conf/config-withpath.php" chmod 400 "$install_dir/config.php" chown $app:$app "$install_dir/config.php" From 8eb23ab029847ccf2ce6d6d513829fa758ddd9dd Mon Sep 17 00:00:00 2001 From: Hayden Date: Sun, 11 Feb 2024 13:07:06 -0800 Subject: [PATCH 02/12] split config templates into 2 files --- conf/{config.php => config-withpath.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename conf/{config.php => config-withpath.php} (100%) diff --git a/conf/config.php b/conf/config-withpath.php similarity index 100% rename from conf/config.php rename to conf/config-withpath.php From 55d31c6518320527347d1d2ccdd00d78f94c6886 Mon Sep 17 00:00:00 2001 From: Hayden Date: Sun, 11 Feb 2024 13:07:55 -0800 Subject: [PATCH 03/12] split config templates into 2 files --- conf/config-subdomain.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 conf/config-subdomain.php diff --git a/conf/config-subdomain.php b/conf/config-subdomain.php new file mode 100644 index 0000000..923fdd4 --- /dev/null +++ b/conf/config-subdomain.php @@ -0,0 +1,27 @@ + 'https://__DOMAIN__', + 'db' => array ( + 'connection' => 'mysql', + 'dsn' => 'host=localhost;port=3306;dbname=__DB_NAME__', + 'username' => '__DB_NAME__', + 'password' => '__DB_PWD__', + ), + + 'storage' => array( + 'driver' => 'local', + 'path' => '__DATA_DIR__', + ), + + 'ldap' => array( + 'enabled' => true, + 'schema' => 'ldap', + 'host' => 'ldap://127.0.0.1', + 'port' => 389, + 'base_domain' => 'dc=yunohost,dc=org', + 'search_filter' => '(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))', + 'user_domain' => 'ou=Users', + 'rdn_attribute' => 'uid=', + ), +); From 8683ecfa2b4d80c3b10a2e2bb1b96992edc534cc Mon Sep 17 00:00:00 2001 From: Hayden Date: Sun, 11 Feb 2024 13:16:25 -0800 Subject: [PATCH 04/12] forgot how bash scripting works for a moment there --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index fda7377..c69bf31 100755 --- a/scripts/install +++ b/scripts/install @@ -41,7 +41,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -if "$path" == "/" then ynh_add_config --template="../conf/config-subdomain.php" --destination="$install_dir/config.php" else ynh_add_config --template="../conf/config-withpath.php" +if "$path" == "/" then ynh_add_config --template="../conf/config-subdomain.php" --destination="$install_dir/config.php" else ynh_add_config --template="../conf/config-withpath.php" fi chmod 400 "$install_dir/config.php" chown $app:$app "$install_dir/config.php" From c94d66fec5cbe1dccf011cb34529ed9da0b3ac60 Mon Sep 17 00:00:00 2001 From: Hayden Date: Sun, 11 Feb 2024 13:20:37 -0800 Subject: [PATCH 05/12] Knew i wouldnt get it first shot but dang --- scripts/install | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index c69bf31..f153d25 100755 --- a/scripts/install +++ b/scripts/install @@ -41,7 +41,11 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -if "$path" == "/" then ynh_add_config --template="../conf/config-subdomain.php" --destination="$install_dir/config.php" else ynh_add_config --template="../conf/config-withpath.php" fi +if [ "$path" == "/" ]; then + ynh_add_config --template="../conf/config-subdomain.php" --destination="$install_dir/config.php" +else + ynh_add_config --template="../conf/config-withpath.php" --destination="$install_dir/config.php" +fi chmod 400 "$install_dir/config.php" chown $app:$app "$install_dir/config.php" @@ -52,7 +56,7 @@ chown $app:$app "$install_dir/config.php" ynh_script_progression --message="Install database" --weight=1 pushd $install_dir - php$phpversion bin/migrate --install + php$phpversion bin/migrate --install popd #================================================= @@ -60,3 +64,4 @@ popd #================================================= ynh_script_progression --message="Installation of $app completed" --last + From c6017f4e39412a8758d1ba030049550dd14733d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:27:46 +0100 Subject: [PATCH 06/12] Update nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index e67414b..305e968 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,7 +8,7 @@ location __PATH__/ { client_max_body_size 1G; - try_files $uri $uri/ __PATH__/index.php + try_files $uri $uri/ __PATH__/index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; From a0eefa185ca61710108f540fa5b97e160c62493a Mon Sep 17 00:00:00 2001 From: Hayden Date: Mon, 12 Feb 2024 09:31:53 -0800 Subject: [PATCH 07/12] Update change_url (unfinished, dont test yet) --- scripts/change_url | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 4ba8cf7..c00e68f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,6 +16,17 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config +# +# MODIFY URL IN APP CONFIG +# +ynh_script_progression --message="Updating app configuration..." --weight=1 + +# Try a sed command? nowhere near finished I'll finish it soon enough +if [ "$new_path" == "/" ] && [ "$old_path" == "/" ]; then + sed 's/${old_domain//\//\\\/}/${new_domain//\//\\\/}/g' +else + sed 's/${old_domain//\//\\\/}/ + #================================================= # END OF SCRIPT #================================================= From e1002897564bf14d95d1a335992c63e165d462ea Mon Sep 17 00:00:00 2001 From: Hayden Date: Mon, 12 Feb 2024 10:08:28 -0800 Subject: [PATCH 08/12] Should work now (ive jinxed it havent i) --- scripts/change_url | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c00e68f..2c593f7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -21,11 +21,19 @@ ynh_change_url_nginx_config # ynh_script_progression --message="Updating app configuration..." --weight=1 -# Try a sed command? nowhere near finished I'll finish it soon enough +# this might be a roundabout way of doing it? if [ "$new_path" == "/" ] && [ "$old_path" == "/" ]; then - sed 's/${old_domain//\//\\\/}/${new_domain//\//\\\/}/g' + sed -i 's|$old_domain|$new_domain' $install_dir/config.php +elif [ "$new_path" == "/" ] && [ "$old_path" != "/" ]; then + sed -i 's|$old_domain$old_path|$new_domain' +elif [ "$new_path" != "/" ] && [ "$old_path" == "/" ]; then + sed -i 's|$old_domain|$new_domain$new_path' +elif [ "$new_path" != "/" ] && [ "$old_path" != "/" ]; then + sed -i 's|$old_domain$old_path|$new_domain$new_path' $install_dir/config.php else - sed 's/${old_domain//\//\\\/}/ + ynh_print_warn --message="Didn't match a result for old/new paths. Attempting subdomain config." + sed -i 's|$old_domain|$new_domain' $install_dir/config.php +fi #================================================= # END OF SCRIPT From 623d0644b5ec3816d7748d70b17f2ecb75bfae2b Mon Sep 17 00:00:00 2001 From: Hayden Date: Mon, 12 Feb 2024 10:11:53 -0800 Subject: [PATCH 09/12] i did jinx it, unterminated commands - should work now --- scripts/change_url | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 2c593f7..246227b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,13 +23,13 @@ ynh_script_progression --message="Updating app configuration..." --weight=1 # this might be a roundabout way of doing it? if [ "$new_path" == "/" ] && [ "$old_path" == "/" ]; then - sed -i 's|$old_domain|$new_domain' $install_dir/config.php + sed -i 's|$old_domain|$new_domain|' $install_dir/config.php elif [ "$new_path" == "/" ] && [ "$old_path" != "/" ]; then - sed -i 's|$old_domain$old_path|$new_domain' + sed -i 's|$old_domain$old_path|$new_domain|' $install_dir/config.php elif [ "$new_path" != "/" ] && [ "$old_path" == "/" ]; then - sed -i 's|$old_domain|$new_domain$new_path' + sed -i 's|$old_domain|$new_domain$new_path|' $install_dir/config.php elif [ "$new_path" != "/" ] && [ "$old_path" != "/" ]; then - sed -i 's|$old_domain$old_path|$new_domain$new_path' $install_dir/config.php + sed -i 's|$old_domain$old_path|$new_domain$new_path|' $install_dir/config.php else ynh_print_warn --message="Didn't match a result for old/new paths. Attempting subdomain config." sed -i 's|$old_domain|$new_domain' $install_dir/config.php From 7d524c2c2757ae947c0ce277a7545d1a92740ad1 Mon Sep 17 00:00:00 2001 From: Hayden Date: Mon, 12 Feb 2024 10:28:01 -0800 Subject: [PATCH 10/12] Update change_url tested 1 and it works, working on the rest. --- scripts/change_url | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 246227b..c6d1d15 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,14 +25,15 @@ ynh_script_progression --message="Updating app configuration..." --weight=1 if [ "$new_path" == "/" ] && [ "$old_path" == "/" ]; then sed -i 's|$old_domain|$new_domain|' $install_dir/config.php elif [ "$new_path" == "/" ] && [ "$old_path" != "/" ]; then - sed -i 's|$old_domain$old_path|$new_domain|' $install_dir/config.php + sed -i 's|$old_domain${old_path%?}|$new_domain|' $install_dir/config.php elif [ "$new_path" != "/" ] && [ "$old_path" == "/" ]; then - sed -i 's|$old_domain|$new_domain$new_path|' $install_dir/config.php + sed -i 's|$old_domain|$new_domain${new_path%?}|' $install_dir/config.php elif [ "$new_path" != "/" ] && [ "$old_path" != "/" ]; then - sed -i 's|$old_domain$old_path|$new_domain$new_path|' $install_dir/config.php + # Works + sed -i 's|$old_domain${old_path%?}|$new_domain${new_path%?}|' $install_dir/config.php else ynh_print_warn --message="Didn't match a result for old/new paths. Attempting subdomain config." - sed -i 's|$old_domain|$new_domain' $install_dir/config.php + sed -i 's|$old_domain|$new_domain|' $install_dir/config.php fi #================================================= From bb83443137fe7fa6d8c762b764ef31c126baba5b Mon Sep 17 00:00:00 2001 From: Hayden Date: Mon, 12 Feb 2024 12:32:23 -0800 Subject: [PATCH 11/12] likely not gonna work but we're gonna try --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c6d1d15..1538f77 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,12 +25,12 @@ ynh_script_progression --message="Updating app configuration..." --weight=1 if [ "$new_path" == "/" ] && [ "$old_path" == "/" ]; then sed -i 's|$old_domain|$new_domain|' $install_dir/config.php elif [ "$new_path" == "/" ] && [ "$old_path" != "/" ]; then - sed -i 's|$old_domain${old_path%?}|$new_domain|' $install_dir/config.php + sed -i 's|$old_domain${old_path:0:-1}|$new_domain|' $install_dir/config.php elif [ "$new_path" != "/" ] && [ "$old_path" == "/" ]; then - sed -i 's|$old_domain|$new_domain${new_path%?}|' $install_dir/config.php + sed -i 's|$old_domain|$new_domain${old_path:0:-1}|' $install_dir/config.php elif [ "$new_path" != "/" ] && [ "$old_path" != "/" ]; then # Works - sed -i 's|$old_domain${old_path%?}|$new_domain${new_path%?}|' $install_dir/config.php + sed -i 's|$old_domain${old_path:0:-1}|$new_domain${old_path:0:-1}|' $install_dir/config.php else ynh_print_warn --message="Didn't match a result for old/new paths. Attempting subdomain config." sed -i 's|$old_domain|$new_domain|' $install_dir/config.php From 5832e47f8513b421c8af50d32dbfbbacd5f46929 Mon Sep 17 00:00:00 2001 From: Hayden Date: Mon, 12 Feb 2024 13:23:29 -0800 Subject: [PATCH 12/12] beyond me, if you have a better alternative lmk --- scripts/change_url | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1538f77..4ba8cf7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,26 +16,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -# -# MODIFY URL IN APP CONFIG -# -ynh_script_progression --message="Updating app configuration..." --weight=1 - -# this might be a roundabout way of doing it? -if [ "$new_path" == "/" ] && [ "$old_path" == "/" ]; then - sed -i 's|$old_domain|$new_domain|' $install_dir/config.php -elif [ "$new_path" == "/" ] && [ "$old_path" != "/" ]; then - sed -i 's|$old_domain${old_path:0:-1}|$new_domain|' $install_dir/config.php -elif [ "$new_path" != "/" ] && [ "$old_path" == "/" ]; then - sed -i 's|$old_domain|$new_domain${old_path:0:-1}|' $install_dir/config.php -elif [ "$new_path" != "/" ] && [ "$old_path" != "/" ]; then - # Works - sed -i 's|$old_domain${old_path:0:-1}|$new_domain${old_path:0:-1}|' $install_dir/config.php -else - ynh_print_warn --message="Didn't match a result for old/new paths. Attempting subdomain config." - sed -i 's|$old_domain|$new_domain|' $install_dir/config.php -fi - #================================================= # END OF SCRIPT #=================================================