...
This commit is contained in:
@@ -11,7 +11,6 @@ import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import ir.peeco.pline.enums.CdrDatabaseType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
@@ -19,7 +18,6 @@ import org.hibernate.validator.constraints.Range;
|
||||
@Data
|
||||
@Table
|
||||
@Entity(name = "Tbl_cdr_settings")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor(access = AccessLevel.PUBLIC, force = true)
|
||||
public class TblCdrSetting {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.time.ZoneId;
|
||||
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
|
||||
@@ -30,6 +31,7 @@ import java.util.regex.Pattern;
|
||||
public class GlobalTools {
|
||||
|
||||
private static final String NAST_MOUNT_PATH = "/mnt/nas-";
|
||||
private static final String DEFAULT_HOST_UUID = "0000-0000-0000-0000";
|
||||
private static final Pattern ASTERISK_VERSION_PATTERN = Pattern.compile(
|
||||
"Asterisk\\s+([0-9][A-Za-z0-9.+~-]*)", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern NGINX_VERSION_PATTERN = Pattern.compile(
|
||||
@@ -313,17 +315,28 @@ public class GlobalTools {
|
||||
}
|
||||
|
||||
public static String getHostUUID() {
|
||||
return HostUUIDHolder.VALUE;
|
||||
}
|
||||
|
||||
private static String loadHostUUID() {
|
||||
String prefix = "pline".equals(System.getProperty("user.name")) ? "/usr/bin/sudo -n " : "";
|
||||
String r1 = execHostSerialCommand(prefix + "/usr/sbin/blkid");
|
||||
String r2 = execHostSerialCommand(prefix
|
||||
+ "/usr/sbin/dmidecode | grep -w UUID | sed \"s/^.UUID\\: //g\"");
|
||||
if (r1.isBlank() || r2.isBlank()) {
|
||||
System.err.println("Host serial unavailable; check hardware ID command availability and service permissions.");
|
||||
return DEFAULT_HOST_UUID;
|
||||
}
|
||||
return getHostUUID(r1, r2);
|
||||
}
|
||||
|
||||
private static final class HostUUIDHolder {
|
||||
private static final String VALUE = loadHostUUID();
|
||||
}
|
||||
|
||||
static String getHostUUID(String r1, String r2) {
|
||||
if (r1 == null || r1.isBlank() || r2 == null || r2.isBlank()) {
|
||||
// An unreadable fingerprint is not a serial. Keep the caller running.
|
||||
return "";
|
||||
return DEFAULT_HOST_UUID;
|
||||
}
|
||||
String r = r2 + r1 + r2;
|
||||
String uuid = String.format("%012d", -1 * r.hashCode());
|
||||
@@ -355,10 +368,8 @@ public class GlobalTools {
|
||||
return "";
|
||||
}
|
||||
String output = stdout.get(2, TimeUnit.SECONDS);
|
||||
String error = stderr.get(2, TimeUnit.SECONDS).trim();
|
||||
stderr.get(2, TimeUnit.SECONDS);
|
||||
if (process.exitValue() != 0 || output.isBlank()) {
|
||||
System.err.println("Host serial command failed (exit " + process.exitValue()
|
||||
+ "): " + command + "; " + error);
|
||||
return "";
|
||||
}
|
||||
return output;
|
||||
@@ -558,8 +569,15 @@ public class GlobalTools {
|
||||
|
||||
public static String getTimeZone() {
|
||||
String date = execLinuxCli("/usr/bin/timedatectl show | grep Timezone", new String[] { "" }, true);
|
||||
assert date != null;
|
||||
return date.trim().replaceAll("Timezone=", "");
|
||||
String timeZone = date == null ? "" : date.trim().replaceFirst("^Timezone=", "");
|
||||
if (!timeZone.isBlank()) {
|
||||
try {
|
||||
return ZoneId.of(timeZone).getId();
|
||||
} catch (RuntimeException ignored) {
|
||||
// Use the JVM's configured zone when timedatectl returns an invalid value.
|
||||
}
|
||||
}
|
||||
return TimeZone.getDefault().toZoneId().getId();
|
||||
}
|
||||
|
||||
public static String getNTPServiceStatus() {
|
||||
|
||||
@@ -19,7 +19,7 @@ management.endpoint.health.probes.enabled=true
|
||||
spring.jpa.show-sql=false
|
||||
spring.jpa.generate-ddl=false
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
||||
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
|
||||
@@ -67,8 +67,7 @@ spring.banner.location=classpath:banner.txt
|
||||
# LOGGING
|
||||
# ============================================================
|
||||
|
||||
# Log file
|
||||
logging.file.name=./log/pline.log
|
||||
# Log output is captured by app.sh into logs/backend/backend.log
|
||||
|
||||
# فقط ERROR و FATAL
|
||||
logging.level.root=ERROR
|
||||
|
||||
Reference in New Issue
Block a user