haiwen / seahub

The web end of seafile server.
seafile.com
Other
526 stars 369 forks source link

v9.0.0 :: Migrating script for moving SERVICE_URL configuration from ccnet.conf to seahub_settings.py match commented line #5032

Closed jobenvil closed 1 year ago

jobenvil commented 2 years ago

Unfortunatedly migratiing script not working as expected. The script takes the first match for SERVICE_URL even the match is a commented one:

Example of ccnet.conf:

 [General]
 USER_NAME = myusername
 ID = <redacted>
 NAME = myname
 #SERVICE_URL = https://mydomain.de/seafile    <== LINE IS COMMENTED
 SERVICE_URL = https://cloud.mydomain.de
 ...

The commented line and not the uncommented line appears now on at the bottom of the seahub_settings.py file:

...
...
SERVICE_URL = https://mydomain.de/seafile
arw-thomasm commented 2 years ago

I can confirm this issue: I had the same issue after upgrading from 8.0.8 to 9.0.9. Obviously this issue is still there...

My ccnet.conf:

[General]
USER_NAME = Juno
ID = <redacted>
NAME = Juno
#SERVICE_URL = http://<fqdn>:8000
SERVICE_URL = https://<fqdn>/seafile
[...]

The bug is located in the upgrade script (seafile-server-9.0.9/upgrade/upgrade_8.0_9.0.sh) on line 193 in function update_seahub_settings ():

  service_url=`awk -F '=' '/\[General\]/{a=1}a==1&&$1~/SERVICE_URL/{print $2;exit}' ${default_conf_dir}/ccnet.conf`

You are looking for a line which has SERVICE_URL included, but you want to ensure, that the string is at the beginning of the line. You can simply do this by adding a ^ before SERVICE_URL:

  service_url=`awk -F '=' '/\[General\]/{a=1}a==1&&$1~/^SERVICE_URL/{print $2;exit}' ${default_conf_dir}/ccnet.conf`

You can also ignore all lines starting with a pound key "#" before looking for SERVICE_URL.

Regards, Thomas

arw-thomasm commented 2 years ago

I fixed this issue in PR #5277.