Skip to content

Commit e18472f

Browse files
feat: optimize disk mount logic (#11519)
1 parent e3dea80 commit e18472f

File tree

12 files changed

+39
-2
lines changed

12 files changed

+39
-2
lines changed

agent/app/service/disk_utils.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ func isPointMounted(mountPoint string) bool {
463463
}
464464

465465
func addToFstabWithOptions(device, mountPoint, filesystem, options string) error {
466+
uuid, err := getDeviceUUID(device)
467+
if err != nil {
468+
return fmt.Errorf("failed to get UUID for device %s: %v", device, err)
469+
}
470+
466471
if filesystem == "" {
467472
fsType, err := getFilesystemType(device)
468473
if err != nil {
@@ -476,7 +481,7 @@ func addToFstabWithOptions(device, mountPoint, filesystem, options string) error
476481
options = "defaults"
477482
}
478483

479-
entry := fmt.Sprintf("%s %s %s %s 0 2\n", device, mountPoint, filesystem, options)
484+
entry := fmt.Sprintf("UUID=%s %s %s %s 0 2\n", uuid, mountPoint, filesystem, options)
480485

481486
file, err := os.OpenFile("/etc/fstab", os.O_APPEND|os.O_WRONLY, 0644)
482487
if err != nil {
@@ -568,3 +573,15 @@ func parseSizeToBytes(sizeStr string) int64 {
568573
return val
569574
}
570575
}
576+
577+
func getDeviceUUID(device string) (string, error) {
578+
output, err := cmd.RunDefaultWithStdoutBashC(fmt.Sprintf("blkid -s UUID -o value %s", device))
579+
if err != nil {
580+
return "", err
581+
}
582+
uuid := strings.TrimSpace(output)
583+
if uuid == "" {
584+
return "", fmt.Errorf("no UUID found for device %s", device)
585+
}
586+
return uuid, nil
587+
}

frontend/src/lang/modules/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,6 +2755,8 @@ const message = {
27552755
streamPortsHelper:
27562756
'Set the external listening port number, clients will access the service through this port, separated by commas, e.g., 5222,5223',
27572757
streamHelper: 'TCP/UDP Port Forwarding and Load Balancing',
2758+
2759+
syncHtmlHelper: 'Sync to PHP and static websites',
27582760
},
27592761
php: {
27602762
short_open_tag: 'Short tag support',

frontend/src/lang/modules/es-es.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,8 @@ const message = {
27472747
streamPortsHelper:
27482748
'Configura el número de puerto de escucha externo, los clientes accederán al servicio a través de este puerto, separado por comas, p. ej., 5222,5223',
27492749
streamHelper: 'Reenvío de Puertos y Balanceo de Carga TCP/UDP',
2750+
2751+
syncHtmlHelper: 'Sincronizar con PHP y sitios web estáticos',
27502752
},
27512753
php: {
27522754
short_open_tag: 'Soporte de etiquetas cortas',

frontend/src/lang/modules/ja.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,8 @@ const message = {
26792679
streamPortsHelper:
26802680
'外部リスニングポート番号を設定します。クライアントはこのポートを通じてサービスにアクセスします。カンマで区切ってください。例:5222,5223',
26812681
streamHelper: 'TCP/UDP ポート転送とロードバランシング',
2682+
2683+
syncHtmlHelper: 'PHP と静的ウェブサイトに同期',
26822684
},
26832685
php: {
26842686
short_open_tag: '短いタグサポート',

frontend/src/lang/modules/ko.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,8 @@ const message = {
26342634
streamPortsHelper:
26352635
'외부 수신 포트 번호를 설정합니다. 클라이언트는 이 포트를 통해 서비스에 액세스합니다. 쉼표로 구분하세요. 예: 5222,5223',
26362636
streamHelper: 'TCP/UDP 포트 포워딩 및 로드 밸런싱',
2637+
2638+
syncHtmlHelper: 'PHP 및 정적 웹사이트에 동기화',
26372639
},
26382640
php: {
26392641
short_open_tag: '짧은 태그 지원',

frontend/src/lang/modules/ms.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,6 +2736,8 @@ const message = {
27362736
streamPortsHelper:
27372737
'Tetapkan nombor port pendengaran luaran, pelanggan akan mengakses perkhidmatan melalui port ini, dipisahkan dengan koma, cth., 5222,5223',
27382738
streamHelper: 'Penerusan Port dan Pengimbangan Beban TCP/UDP',
2739+
2740+
syncHtmlHelper: 'Segerakkan ke PHP dan laman web statik',
27392741
},
27402742
php: {
27412743
short_open_tag: 'Sokongan tag pendek',

frontend/src/lang/modules/pt-br.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,6 +2741,8 @@ const message = {
27412741
streamPortsHelper:
27422742
'Defina o número da porta de escuta externa, os clientes acessarão o serviço através desta porta, separados por vírgulas, por exemplo: 5222,5223',
27432743
streamHelper: 'Encaminhamento de Portas e Balanceamento de Carga TCP/UDP',
2744+
2745+
syncHtmlHelper: 'Sincronizar com PHP e sites estáticos',
27442746
},
27452747
php: {
27462748
short_open_tag: 'Suporte para short tags',

frontend/src/lang/modules/ru.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,6 +2736,8 @@ const message = {
27362736
streamPortsHelper:
27372737
'Установите номер внешнего порта прослушивания, клиенты будут получать доступ к службе через этот порт, разделяйте запятыми, например: 5222,5223',
27382738
streamHelper: 'Перенаправление портов и балансировка нагрузки TCP/UDP',
2739+
2740+
syncHtmlHelper: 'Синхронизировать с PHP и статическими сайтами',
27392741
},
27402742
php: {
27412743
short_open_tag: 'Поддержка коротких тегов',

frontend/src/lang/modules/tr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,6 +2793,8 @@ const message = {
27932793
streamPortsHelper:
27942794
'Harici dinleme bağlantı noktası numarasını ayarlayın, istemciler bu bağlantı noktası üzerinden hizmete erişecektir, virgülle ayırın, örn.: 5222,5223',
27952795
streamHelper: 'TCP/UDP Port Yönlendirme ve Yük Dengeleme',
2796+
2797+
syncHtmlHelper: 'PHP ve statik web siteleriyle senkronize et',
27962798
},
27972799
php: {
27982800
short_open_tag: 'Kısa etiket desteği',

frontend/src/lang/modules/zh-Hant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,8 @@ const message = {
25652565
streamPorts: '監聽端口',
25662566
streamPortsHelper: '設定對外監聽的埠號,客戶端將透過此埠存取服務,按逗號分割,例如:5222,5223',
25672567
streamHelper: 'TCP/UDP 端口轉發與負載均衡',
2568+
2569+
syncHtmlHelper: '同步到 PHP 和靜態網站',
25682570
},
25692571
php: {
25702572
short_open_tag: '短標籤支援',

0 commit comments

Comments
 (0)