From b95e6ec9cf9dbbec09d18cf55709bbe408386b03 Mon Sep 17 00:00:00 2001
From: Dave Yap <github@dave.yap-family.com>
Date: Fri, 14 Mar 2025 21:28:26 +0800
Subject: [PATCH] Seafile - Minor bug fix: domain.sh script fix (#3046)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Create zitadel-install.sh

* Create zitadel.json

* Create zitadel.sh

* Update zitadel.sh

Edit reference back to upstream build.func

* Update zitadel.json

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel.sh

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel.sh

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel.sh

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel.sh

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel.sh

* Update zitadel-install.sh

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel-install.sh

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>

* Update zitadel.sh

Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com>

* Update zitadel.json

Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com>

* Use declared variables in config files

* Remove other architectures

* Update to fit changes requested

Include mc for install; removal of variable ARCH and put into direct links; correct the default resources required

* Update zitadel.sh

Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com>

* Update zitadel-install.sh

Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com>

* Update zitadel-install.sh

Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com>

* Made changes to fit suggestions

* Update zitadel-install.sh

correct version output

* Update zitadel-install.sh

* Update path for version.txt

* Set update part default to our project defaults

* Update zitadel.sh, Remove v befor ${RELEASE}

* Update zitadel-install.sh

* Created Seafile script

* Update seafile-install.sh

Removed sudo and tarball when cleaning up.

* Update seafile-install.sh

* Updated script

Corrected source and remove comments

* Move dependencies

Move Python installation and dependencies down to Python block. Fix typos.

* Update seafile-install.sh

Missing -y

* Fix typo

* Remove python lib deps version pinning

* Update seafile-install.sh

* Use generated password instead of plain text

* Change reference

* Reset reference

* Update seafile-install.sh

* Update seafile.json

* Fix syntax error

* Fix uploading files error and broken MOTD

* Fix systemd file and corrected domain.sh script

* Added better explanation of domain.sh script usage

* Edited script creation date

---------

Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>
Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com>
Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com>
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
---
 install/seafile-install.sh | 18 +++++---
 json/seafile.json          | 90 +++++++++++++++++++-------------------
 2 files changed, 58 insertions(+), 50 deletions(-)

diff --git a/install/seafile-install.sh b/install/seafile-install.sh
index 3e3776a39..48efb0fcc 100644
--- a/install/seafile-install.sh
+++ b/install/seafile-install.sh
@@ -188,6 +188,8 @@ msg_info "Adjusting Conf files"
 sed -i "0,/127.0.0.1/s/127.0.0.1/0.0.0.0/" /opt/seafile/conf/gunicorn.conf.py
 sed -i "0,/SERVICE_URL = \"http:\/\/$IP\"/s/SERVICE_URL = \"http:\/\/$IP\"/SERVICE_URL = \"http:\/\/$IP:8000\"/" /opt/seafile/conf/seahub_settings.py
 echo -e "\nFILE_SERVER_ROOT = \"http://$IP:8082\"" >> /opt/seafile/conf/seahub_settings.py
+echo -e "CSRF_TRUSTED_ORIGINS = [\"http://$IP/\"]" >> /opt/seafile/conf/seahub_settings.py
+echo -e "ALLOWED_HOSTS = [\"$IP\"]" >> /opt/seafile/conf/seahub_settings.py
 echo -e "CSRF_TRUSTED_ORIGINS = ['http://$IP/']" >> /opt/seafile/conf/seahub_settings.py
 msg_ok "Conf files adjusted"
 
@@ -224,14 +226,15 @@ After=network.target mysql.service memcached.service
 Wants=mysql.service memcached.service
 
 [Service]
-Type=forking
+Type=oneshot
 User=seafile
 Group=seafile
 WorkingDirectory=/opt/seafile
+RemainAfterExit=yes
 
-ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
-ExecStartPost=/opt/seafile/seafile-server-latest/seahub.sh start
-ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
+ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start 
+ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
+ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop 
 ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
 
 Restart=on-failure
@@ -265,8 +268,13 @@ IP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
 DOMAIN_NOSCHEME=$(echo $DOMAIN | sed 's|^https://||')
 
 #Change the CORS to provided domain
-sed -i "s|CSRF_TRUSTED_ORIGINS = ['http://$IP:8000/']|CSRF_TRUSTED_ORIGINS = ['$DOMAIN']|g" /opt/seafile/conf/seahub_settings.py
+sed -i "s|SERVICE_URL = \"http://$IP:8000\"|SERVICE_URL = \"$DOMAIN\"|g" /opt/seafile/conf/seahub_settings.py
+sed -i "s|CSRF_TRUSTED_ORIGINS = \[\"http://$IP/\"\]|CSRF_TRUSTED_ORIGINS = \[\"$DOMAIN/\"\]|g" /opt/seafile/conf/seahub_settings.py
 sed -i "s|FILE_SERVER_ROOT = \"http://$IP:8082\"|FILE_SERVER_ROOT = \"$DOMAIN/seafhttp\"|g" /opt/seafile/conf/seahub_settings.py
+sed -i "s|ALLOWED_HOSTS = \[\"$IP\"\]|ALLOWED_HOSTS = \[\"\.$DOMAIN_NOSCHEME\"\]|g" /opt/seafile/conf/seahub_settings.py
+
+systemctl restart seafile
+echo "Seafile server restarted! Access it at $DOMAIN."
 EOF
 chmod +x ~/domain.sh
 msg_ok "Bash Script for Domain access created"
diff --git a/json/seafile.json b/json/seafile.json
index ea7336a60..c26172013 100644
--- a/json/seafile.json
+++ b/json/seafile.json
@@ -1,47 +1,47 @@
 {
-  "name": "Seafile",
-  "slug": "Seafile",
-  "categories": [
-    12
-  ],
-  "date_created": "2025-03-11",
-  "type": "ct",
-  "updateable": false,
-  "privileged": false,
-  "interface_port": 8000,
-  "documentation": "https://manual.seafile.com/11.0/deploy",
-  "website": "https://seafile.com",
-  "logo": "https://manual.seafile.com/11.0/media/seafile-transparent-1024.png",
-  "description": "Seafile is an open source file sync and share platform, focusing on reliability and performance.",
-  "install_methods": [
-    {
-      "type": "default",
-      "script": "ct/seafile.sh",
-      "resources": {
-        "cpu": 2,
-        "ram": 2048,
-        "hdd": 20,
-        "os": "debian",
-        "version": "12"
-      }
-    }
-  ],
-  "default_credentials": {
-    "username": null,
-    "password": null
-  },
-  "notes": [
-    {
-      "text": "Application credentials: `cat ~/seafile.creds`",
-      "type": "info"
+    "name": "Seafile",
+    "slug": "Seafile",
+    "categories": [
+        12
+    ],
+    "date_created": "2025-03-11",
+    "type": "ct",
+    "updateable": false,
+    "privileged": false,
+    "interface_port": 8000,
+    "documentation": "https://manual.seafile.com/11.0/deploy",
+    "website": "https://seafile.com",
+    "logo": "https://manual.seafile.com/11.0/media/seafile-transparent-1024.png",
+    "description": "Seafile is an open source file sync and share platform, focusing on reliability and performance.",
+    "install_methods": [
+        {
+            "type": "default",
+            "script": "ct/seafile.sh",
+            "resources": {
+                "cpu": 2,
+                "ram": 2048,
+                "hdd": 20,
+                "os": "debian",
+                "version": "12"
+            }
+        }
+    ],
+    "default_credentials": {
+        "username": null,
+        "password": null
     },
-    {
-      "text": "Change STORAGE_DIR value in `external-storage.sh` and run `bash external-storage.sh` to use your defined storage instead of internal.",
-      "type": "info"
-    },
-    {
-      "text": "Execute `~/domain.sh <HTTPS://YOUR_DOMAIN.COM_HERE>` to enable access to Seafile via your domain",
-      "type": "info"
-    }
-  ]
-}
+    "notes": [
+        {
+            "text": "Application credentials: `cat ~/seafile.creds`",
+            "type": "info"
+        },
+        {
+            "text": "Change STORAGE_DIR value in `external-storage.sh` and run `bash external-storage.sh` to use your defined storage instead of internal.",
+            "type": "info"
+        },
+        {
+            "text": "Execute `~/domain.sh <FULL_DOMAIN_URL_WITH_HTTPS_OR_HTTP>` to enable access to Seafile via your domain. Example: ~/domain.sh https://seafile.example.com",
+            "type": "info"
+        }
+    ]
+}
\ No newline at end of file