mirror of
https://github.com/Snigdha-OS/snigdhaos-pkgbuilds.git
synced 2025-12-06 08:03:50 +01:00
31 lines
940 B
Bash
Executable File
31 lines
940 B
Bash
Executable File
#!/bin/bash
|
|
|
|
snigdhaoslib_add_update_notice() {
|
|
# Ensure the directory exists
|
|
if ! mkdir -p /var/lib/snigdhaos/tmp; then
|
|
echo "Error: Failed to create directory /var/lib/snigdhaos/tmp" >&2
|
|
return 1
|
|
fi
|
|
|
|
# Get the current date
|
|
current_date=$(date +%F)
|
|
|
|
# Ensure the input message is not empty
|
|
if [ -z "$1" ]; then
|
|
echo "Error: No update message provided." >&2
|
|
return 1
|
|
fi
|
|
|
|
# Replace multiple spaces with a single space
|
|
message="${1//[[:space:]]+/ }"
|
|
|
|
# Append the message to the file with the current date
|
|
if ! printf "%s %s\n" "$current_date" "$message" >> /var/lib/snigdhaos/tmp/update_notices; then
|
|
echo "Error: Failed to write to /var/lib/snigdhaos/tmp/update_notices" >&2
|
|
return 1
|
|
fi
|
|
|
|
# Optionally, display a success message (for debugging/logging purposes)
|
|
echo "Update notice successfully added for $current_date."
|
|
}
|