-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotfix: remove outdated Docker cleanup scripts and replace with a uni…
…fied cleanup system script
- Loading branch information
1 parent
426c87e
commit bcd4407
Showing
7 changed files
with
117 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# Docker Cleanup Script | ||
|
||
echo "=====================================" | ||
echo " Starting Docker Cleanup " | ||
echo "=====================================" | ||
|
||
echo "Remove everything unused" | ||
docker system prune -a -f | ||
|
||
echo "=====================================" | ||
echo " Docker Cleanup Completed " | ||
echo "=====================================" | ||
|
||
echo "Disk usage after cleanup:" | ||
docker system df | ||
|
||
echo "=====================================" | ||
echo " Starting System Cleanup " | ||
echo "=====================================" | ||
echo "Clearing system cache..." | ||
sync | ||
echo 3 > /proc/sys/vm/drop_caches | ||
|
||
echo "Memory usage after cleanup:" | ||
free -h | ||
|
||
echo "=====================================" | ||
echo " Starting APT Cleanup " | ||
echo "=====================================" | ||
|
||
echo "Cleaning APT cache..." | ||
apt-get clean -y | ||
|
||
echo "Removing unused packages..." | ||
apt-get autoremove -y | ||
|
||
echo "Removing old downloaded archive files..." | ||
apt-get autoclean -y | ||
|
||
echo "Current disk usage:" | ||
df -h | ||
|
||
echo "=====================================" | ||
echo " Cleanup Complete " | ||
echo "=====================================" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 45 additions & 8 deletions
53
.../leonardo/labutilities/qualitylabpro/utils/components/StringToLocalDateTimeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
package leonardo.labutilities.qualitylabpro.utils.components; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeParseException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Component | ||
public class StringToLocalDateTimeConverter implements Converter<String, LocalDateTime> { | ||
|
||
private static final DateTimeFormatter FORMATTER = | ||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
private static final List<DateTimeFormatter> DATE_FORMATTERS = Arrays.asList( | ||
DateTimeFormatter.ISO_DATE_TIME, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"), | ||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"), | ||
DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss"), | ||
DateTimeFormatter.ofPattern("yyyy-MM-dd"), DateTimeFormatter.ofPattern("dd/MM/yyyy")); | ||
|
||
@Override | ||
@NonNull | ||
public LocalDateTime convert(@NonNull String source) { | ||
return LocalDateTime.parse(source, FORMATTER); | ||
} | ||
@Override | ||
public LocalDateTime convert(String source) { | ||
if (source == null || source.trim().isEmpty()) { | ||
return null; | ||
} | ||
|
||
// Sanitize input | ||
source = sanitizeDate(source); | ||
|
||
DateTimeParseException lastException = null; | ||
|
||
for (DateTimeFormatter formatter : DATE_FORMATTERS) { | ||
try { | ||
if (source.length() <= 10) { | ||
LocalDate date = LocalDate.parse(source, formatter); | ||
return LocalDateTime.of(date, LocalTime.MIDNIGHT); | ||
} else { | ||
return LocalDateTime.parse(source, formatter); | ||
} | ||
} catch (DateTimeParseException e) { | ||
lastException = e; | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException("Unable to parse date: " + source, lastException); | ||
} | ||
|
||
private String sanitizeDate(String date) { | ||
return date.trim().replaceAll("--", "-") // Fix double dashes | ||
.replaceAll("\\s+", " ") // Fix multiple spaces | ||
.replaceAll("T\\s", "T") // Fix space after T | ||
.replaceAll("\\s(\\d:\\d)", "T$1") // Add T between date and time if missing | ||
.replaceAll("(\\d)(\\s00:00:00)", "$1T00:00:00"); // Standardize midnight time | ||
// format | ||
} | ||
} |