added sha sums for verifiable updates via salt
This commit is contained in:
parent
b5819e2768
commit
48c241b383
|
@ -0,0 +1 @@
|
||||||
|
a2577b1eb4dfc9dd142bc8bc91f6c569101eef61d1c47ddbd4e9625079fdb5a4
|
|
@ -0,0 +1,41 @@
|
||||||
|
# /etc/profile.d/sum.sh
|
||||||
|
|
||||||
|
# Ensure the script is sourced
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" || "${(%):-%N}" == "$0" ]]; then
|
||||||
|
echo "This script should be sourced, not executed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to generate SHA-256 hashes for .sh files in a given directory
|
||||||
|
generate_sha256_hashes() {
|
||||||
|
local src_dir="$1"
|
||||||
|
|
||||||
|
# Check if the directory exists
|
||||||
|
if [ ! -d "$src_dir" ]; then
|
||||||
|
echo "Directory $src_dir does not exist."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine the command to use for calculating SHA-256
|
||||||
|
local hash_cmd
|
||||||
|
if command -v sha256sum >/dev/null 2>&1; then
|
||||||
|
hash_cmd="sha256sum"
|
||||||
|
elif command -v shasum >/dev/null 2>&1; then
|
||||||
|
hash_cmd="shasum -a 256"
|
||||||
|
else
|
||||||
|
echo "Neither sha256sum nor shasum command is available."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Loop through all .sh files in the directory
|
||||||
|
for file in "$src_dir"/*.sh; do
|
||||||
|
# Skip if no .sh files are found
|
||||||
|
[ -e "$file" ] || continue
|
||||||
|
|
||||||
|
# Calculate the SHA-256 hash and save it to a .sha256 file
|
||||||
|
$hash_cmd "$file" | awk '{ print $1 }' > "$file.sha256"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "SHA-256 hashes have been saved in .sha256 files."
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
e92965ba035990ee5cb81afc1dda199949521264897f4ec37b99fe6a96c14344
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Directory containing the .sh files
|
||||||
|
src_dir="./src"
|
||||||
|
|
||||||
|
# Check if the directory exists
|
||||||
|
if [ ! -d "$src_dir" ]; then
|
||||||
|
echo "Directory $src_dir does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine the command to use for calculating SHA-256
|
||||||
|
if command -v sha256sum >/dev/null 2>&1; then
|
||||||
|
hash_cmd="sha256sum"
|
||||||
|
elif command -v shasum >/dev/null 2>&1; then
|
||||||
|
hash_cmd="shasum -a 256"
|
||||||
|
else
|
||||||
|
echo "Neither sha256sum nor shasum command is available."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Loop through all .sh files in the directory
|
||||||
|
for file in "$src_dir"/*.sh;
|
||||||
|
do
|
||||||
|
# Skip if no .sh files are found
|
||||||
|
[ -e "$file" ] || continue
|
||||||
|
|
||||||
|
# Calculate the SHA-256 hash and save it to a .sha256 file
|
||||||
|
$hash_cmd "$file" | awk '{ print $1 }' > "$file.sha256"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "SHA-256 hashes have been saved in .sha256 files."
|
||||||
|
|
Loading…
Reference in New Issue