@@ -132,7 +132,6 @@ update_server_command() {
132132# change version
133133update_version () {
134134 local version=" $1 "
135- local full_version=" ${version} .0"
136135
137136 if [ -z " $version " ]; then
138137 echo " Error: Version number is required."
@@ -144,23 +143,12 @@ update_version() {
144143 s/(:v)[^:]+$/\1${version} /
145144 }
146145 " " $COMPOSE_FILE "
147-
148- sed -i.bak -E '
149- /^[[:space:]]*swanlab-server:/,/^$/ {
150- /^[[:space:]]*environment:/,/^$/ {
151- /^[[:space:]]*- VERSION=[0-9]+[.][0-9]+[.][0-9]+/ {
152- s/(VERSION=)[0-9]+[.][0-9]+[.][0-9]+/\1' " ${full_version} " ' /
153- }
154- }
155- }
156- ' " $COMPOSE_FILE "
157146}
158147
159148# update specific service version
160149update_service_version () {
161150 local service=" $1 "
162151 local version=" $2 "
163- local full_version=" ${version} .0"
164152
165153 if [ -z " $service " ] || [ -z " $version " ]; then
166154 echo " Error: Service name and version number are required."
@@ -172,18 +160,20 @@ update_service_version() {
172160 s/(:v?)[^:]+$/\1${version} /
173161 }
174162 " " $COMPOSE_FILE "
163+ }
175164
176- if [ " $service " = " swanlab-server" ]; then
177- sed -i.bak -E "
178- /^[[:space:]]*swanlab-server:/,/^$/ {
179- /^[[:space:]]*environment:/,/^$/ {
180- /^[[:space:]]*- VERSION=[0-9]+([.][0-9]+)*[.][0-9]+/ {
181- s/(VERSION=)[0-9]+([.][0-9]+)*[.][0-9]+/\\ 1${full_version} /
182- }
183- }
184- }
185- " " $COMPOSE_FILE "
186- fi
165+ # update self-hosted version
166+ update_self_hosted_version () {
167+ local full_version=" $1 "
168+ sed -i.bak -E "
169+ /^[[:space:]]*swanlab-server:/,/^$/ {
170+ /^[[:space:]]*environment:/,/^$/ {
171+ /^[[:space:]]*- VERSION=[0-9]+([.][0-9]+)*[.][0-9]+/ {
172+ s/(VERSION=)[0-9]+([.][0-9]+)*[.][0-9]+/\\ 1${full_version} /
173+ }
174+ }
175+ }
176+ " " $COMPOSE_FILE "
187177}
188178
189179# check docker-compose.yaml exists
@@ -198,10 +188,14 @@ read -p "Updating the container version will restart docker compose. Do you agre
198188# # check y or Y
199189if [[ " $confirm " == [yY] || " $confirm " == [yY][eE][sS] ]]; then
200190 echo " begin update"
191+ # 更新设置页面版本号
192+ update_self_hosted_version " 2.3.1"
201193 # update all containers version
202194 update_version " 2.3"
203195 update_service_version " swanlab-cloud" " 2.3.1"
196+ update_service_version " swanlab-server" " 2.3.1"
204197 update_service_version " fluent-bit" " 3.1"
198+ update_service_version " traefik" " 3.1"
205199
206200 # update DATABASE_URL_REPLICA
207201 if ! grep -q " DATABASE_URL_REPLICA" " $COMPOSE_FILE " ; then
@@ -241,13 +235,29 @@ if [[ "$confirm" == [yY] || "$confirm" == [yY][eE][sS] ]]; then
241235 fi
242236 # add swanlab-server environment variable
243237 if ! grep -q " VERSION" " $COMPOSE_FILE " ; then
244- add_new_var " swanlab-server" " environment" " - VERSION=2.3.0 "
238+ add_new_var " swanlab-server" " environment" " - VERSION=2.3.1 "
245239 fi
246240
247241 # add missing minio middleware if needed
242+ if ! grep -q ' traefik.http.routers.minio3.rule=PathPrefix(`/swanlab-private`)' " $COMPOSE_FILE " ; then
243+ add_new_var " minio" " labels" " - \" traefik.http.routers.minio3.rule=PathPrefix(\` /swanlab-private\` )\" "
244+ fi
248245 if ! grep -q " traefik.http.routers.minio2.middlewares=minio-host@file" " $COMPOSE_FILE " ; then
249246 add_new_var " minio" " labels" " - \" traefik.http.routers.minio2.middlewares=minio-host@file\" "
250247 fi
248+ if ! grep -q ' traefik.http.routers.minio2.rule=PathPrefix(`/swanlab-private/exports`)' " $COMPOSE_FILE " ; then
249+ add_new_var " minio" " labels" " - \" traefik.http.routers.minio2.rule=PathPrefix(\` /swanlab-private/exports\` )\" "
250+ fi
251+ # delete old minio labels if exists
252+ if grep -q ' traefik.http.routers.minio2.rule=PathPrefix(`/swanlab-private`)' " $COMPOSE_FILE " ; then
253+ sed -i.bak ' \|traefik\.http\.routers\.minio2\.rule=PathPrefix(`/swanlab-private`)|d' " $COMPOSE_FILE "
254+ fi
255+ # delete minio ports mapping
256+ # 删除以 'ports:' 开头,并且下一行包含 9000:9000 的两行
257+ sed -i.bak ' /^[[:space:]]*ports:[[:space:]]*$/{
258+ N
259+ /"9000:9000"/d
260+ }' " $COMPOSE_FILE "
251261 # add healthcheck for swanlab-cloud
252262 if ! grep -A 10 ' swanlab-cloud:' " $COMPOSE_FILE " | grep -q ' ^ healthcheck:' ; then
253263 add_health_check " swanlab-cloud" 80
0 commit comments