diff --git a/VERSION b/VERSION index 341cf11faf9a29504168de4e54beaad182c5adc5..9325c3ccda9850bb6e102aef07d314210f5c9f41 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 \ No newline at end of file +0.3.0 \ No newline at end of file diff --git a/app/scripts/fedora.sh b/app/scripts/fedora.sh new file mode 100644 index 0000000000000000000000000000000000000000..42f82f525850bed2658e7980bd3d282f08e9400a --- /dev/null +++ b/app/scripts/fedora.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +# Path: app/scripts/fedora.sh +# Support for Fedora Linux + +function version_is_supported() { + # + # Check if the version is supported + # https://endoflife.date/oraclelinux + # + today=$(date +"%Y-%m-%d") + source "/etc/os-release" + # we could calculate the expected expiration date based on the release date and the support period + # but it's easier to get the expiration date from the website and hardcode it here + # we are allowing versions that are not supported yet to avoid false positives + + if [[ -n "${VERSION_ID}" ]]; then + case $VERSION_ID in + 39) + expiration_date="2025-12-15" + ;; + 38) + expiration_date="2024-05-18" + ;; + 37) + expiration_date="2023-12-15" + ;; + 36) + expiration_date="2023-05-18" + ;; + *) + expiration_date="2000-04" + logger INFO "The version $os_version is not supported." + res=1 + ;; + esac + else + expiration_date="2000-04" + logger INFO "The version $os_version is not supported." + res=1 + fi + if [[ $expiration_date > $today ]]; then + # The version supported + res=0 + else + # The version not supported + logger INFO "The version is not supported: $expiration_date > $today." + res=1 + fi + logger INFO "Version supported? $(int_to_bool $res)" + return $res +} +echo +function system_is_up_to_date() { + # + # Check if the system is up to date + # + logger INFO "Checking if the system is up to date..." + MAX_DAYS=30 + + today=$(date +"%s") + + # Get the date of the last update from the dnf history log file and convert it to seconds since 1970-01-01 00:00:00 UTC (epoch) + last_update=$(date -d "$(sudo dnf history | grep -e '^\s+\|update' | head -n 1 | awk -F "|" '{ print $3 }' | awk '{print $1}')" +"%s") + days_since_last_update=$(( (today - last_update) / 86400 )) + if [[ $days_since_last_update -gt $MAX_DAYS ]]; then + # The system is not up to date + res=1 + else + # The system is up to date + res=0 + fi + logger INFO "Days since last update: $days_since_last_update, Updated? $(int_to_bool $res)" + return $res +} + +function firewall_is_enabled() { + # + # Check if the firewall is enabled + # + firewall_status=$(firewall-cmd --state) + if [[ $firewall_status == "running" ]]; then + # The firewall is enabled + res=0 + else + # The firewall is not enabled + res=1 + fi + logger INFO "Firewall status: $firewall_status" + return $res +} + +function globalprotect_installed() { + # + # Check if the GlobalProtect client is installed + # + global_protect_version=$(globalprotect show --version 2>/dev/null) + if [ $? -eq 0 ]; then + # The GlobalProtect client is installed + res=0 + else + # The GlobalProtect client is not installed + res=1 + fi + logger INFO "GlobalProtect installed? $(int_to_bool $res)" + return $res +} + +function check_full_disk_encryption_enabled() { + # + # Check if the full disk encryption is enabled + # + + # if VIRTUAL is set to "virtual" then we are running in a virtual machine + if [[ -n "$VIRTUAL" ]]; then + # We are running in a virtual machine + res=0 + logger INFO "Running in a virtual machine. Full disk encryption bypassed." + return $res + else + if [[ -f /etc/crypttab ]]; then + if [[ $(cat /etc/crypttab | grep -v ^# | wc -l) -gt 0 ]]; then + # Full disk encryption is enabled + res=0 + else + # Full disk encryption is not enabled + res=1 + fi + else + # Full disk encryption is not enabled + res=1 + fi + logger INFO "Full disk encryption enabled? $(int_to_bool $res)" + return $res + fi +} + +function check_all() { + version_is_supported \ + && system_is_up_to_date \ + && firewall_is_enabled \ + && globalprotect_installed \ + && check_full_disk_encryption_enabled + + return $? +} \ No newline at end of file diff --git a/app/scripts/oracle.sh b/app/scripts/oracle.sh index 895c31dd2d7be0d518f93c6529be0c055b95d177..f7d3dc7ee378272ccfa229d07d3ac8e7183e6fc6 100644 --- a/app/scripts/oracle.sh +++ b/app/scripts/oracle.sh @@ -3,17 +3,6 @@ # Path: app/scripts/oracle.sh # Support for Oracle Linux -function int_to_bool() { - # Return YES if the first parameter is 0, NO if the first parameter is 1 - if [[ "$1" -eq 0 ]]; then - echo "YES" - elif [[ "$1" -eq 1 ]]; then - echo "NO" - else - echo "Invalid input. Expected 0 or 1." - fi -} - function version_is_supported() { # # Check if the version is supported