diff --git a/bitnami/cassandra/4.0/debian-11/Dockerfile b/bitnami/cassandra/4.0/debian-11/Dockerfile index b44ee79e26b8..da8d69730614 100644 --- a/bitnami/cassandra/4.0/debian-11/Dockerfile +++ b/bitnami/cassandra/4.0/debian-11/Dockerfile @@ -5,7 +5,7 @@ ARG TARGETARCH LABEL org.opencontainers.image.authors="https://bitnami.com/contact" \ org.opencontainers.image.description="Application packaged by Bitnami" \ - org.opencontainers.image.ref.name="4.0.6-debian-11-r4" \ + org.opencontainers.image.ref.name="4.0.6-debian-11-r5" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/cassandra" \ org.opencontainers.image.title="cassandra" \ org.opencontainers.image.vendor="VMware, Inc." \ @@ -27,7 +27,7 @@ RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ fi && \ sha256sum -c python-3.9.14-1-linux-${OS_ARCH}-debian-11.tar.gz.sha256 && \ tar -zxf python-3.9.14-1-linux-${OS_ARCH}-debian-11.tar.gz -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' && \ - rm -rf python-3.9.14-1-linux-${OS_ARCH}-debian-11.tar.gz + rm -rf python-3.9.14-1-linux-${OS_ARCH}-debian-11.tar.gz python-3.9.14-1-linux-${OS_ARCH}-debian-11.tar.gz.sha256 RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ if [ ! -f java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz ]; then \ curl -SsLf https://downloads.bitnami.com/files/stacksmith/java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz -O ; \ @@ -35,7 +35,7 @@ RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ fi && \ sha256sum -c java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz.sha256 && \ tar -zxf java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' && \ - rm -rf java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz + rm -rf java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz java-1.8.345-2-linux-${OS_ARCH}-debian-11.tar.gz.sha256 RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ if [ ! -f gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz ]; then \ curl -SsLf https://downloads.bitnami.com/files/stacksmith/gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz -O ; \ @@ -43,7 +43,7 @@ RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ fi && \ sha256sum -c gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz.sha256 && \ tar -zxf gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' && \ - rm -rf gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz + rm -rf gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz gosu-1.14.0-154-linux-${OS_ARCH}-debian-11.tar.gz.sha256 RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ if [ ! -f yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz ]; then \ curl -SsLf https://downloads.bitnami.com/files/stacksmith/yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz -O ; \ @@ -51,7 +51,7 @@ RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ fi && \ sha256sum -c yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz.sha256 && \ tar -zxf yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' && \ - rm -rf yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz + rm -rf yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz yq-4.27.5-0-linux-${OS_ARCH}-debian-11.tar.gz.sha256 RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ if [ ! -f cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz ]; then \ curl -SsLf https://downloads.bitnami.com/files/stacksmith/cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz -O ; \ @@ -59,7 +59,7 @@ RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ fi && \ sha256sum -c cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz.sha256 && \ tar -zxf cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' && \ - rm -rf cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz + rm -rf cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz cassandra-4.0.6-0-linux-${OS_ARCH}-debian-11.tar.gz.sha256 RUN apt-get update && apt-get upgrade -y && \ rm -r /var/lib/apt/lists /var/cache/apt/archives RUN chmod g+rwX /opt/bitnami diff --git a/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libfs.sh b/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libfs.sh index 1b504b1df458..801b9412bd99 100644 --- a/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libfs.sh +++ b/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libfs.sh @@ -170,18 +170,19 @@ configure_permissions_ownership() { read -r -a filepaths <<<"$paths" for p in "${filepaths[@]}"; do if [[ -e "$p" ]]; then + find -L "$p" -printf "" if [[ -n $dir_mode ]]; then - find -L "$p" -type d -exec chmod "$dir_mode" {} \; + find -L "$p" -type d ! -perm "$dir_mode" -print0 | xargs -r -0 chmod "$dir_mode" fi if [[ -n $file_mode ]]; then - find -L "$p" -type f -exec chmod "$file_mode" {} \; + find -L "$p" -type f ! -perm "$file_mode" -print0 | xargs -r -0 chmod "$file_mode" fi if [[ -n $user ]] && [[ -n $group ]]; then - chown -LR "$user":"$group" "$p" + find -L "$p" -print0 | xargs -r -0 chown "${user}:${group}" elif [[ -n $user ]] && [[ -z $group ]]; then - chown -LR "$user" "$p" + find -L "$p" -print0 | xargs -r -0 chown "${user}" elif [[ -z $user ]] && [[ -n $group ]]; then - chgrp -LR "$group" "$p" + find -L "$p" -print0 | xargs -r -0 chgrp "${group}" fi else stderr_print "$p does not exist" diff --git a/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libos.sh b/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libos.sh index b6c50da90807..08b1d4884c28 100644 --- a/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libos.sh +++ b/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libos.sh @@ -464,3 +464,37 @@ convert_to_hex() { printf '%x' "'${char}" done } + +######################## +# Get boot time +# Globals: +# None +# Arguments: +# None +# Returns: +# Boot time metadata +######################### +get_boot_time() { + stat /proc --format=%Y +} + +######################## +# Get machine ID +# Globals: +# None +# Arguments: +# None +# Returns: +# Machine ID +######################### +get_machine_id() { + local machine_id + if [[ -f /etc/machine-id ]]; then + machine_id="$(cat /etc/machine-id)" + fi + if [[ -z "$machine_id" ]]; then + # Fallback to the boot-time, which will at least ensure a unique ID in the current session + machine_id="$(get_boot_time)" + fi + echo "$machine_id" +} diff --git a/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libservice.sh b/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libservice.sh index a713bd108e15..f964ab09fcba 100644 --- a/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libservice.sh +++ b/bitnami/cassandra/4.0/debian-11/prebuildfs/opt/bitnami/scripts/libservice.sh @@ -271,3 +271,140 @@ remove_logrotate_conf() { local logrotate_conf_dir="/etc/logrotate.d" rm -f "${logrotate_conf_dir}/${service_name}" } + +######################## +# Generate a Systemd configuration file +# Arguments: +# $1 - Service name +# Flags: +# --exec-start - Start command (required) +# --exec-stop - Stop command (optional) +# --exec-reload - Reload command (optional) +# --name - Service full name (e.g. Apache HTTP Server, defaults to $1) +# --restart - When to restart the Systemd service after being stopped (defaults to always) +# --pid-file - Service PID file (required when --restart is set to always) +# --type - Systemd unit type (defaults to forking) +# --user - System user to start the service with +# --group - System group to start the service with +# --environment - Environment variable to define (multiple --environment options may be passed) +# Returns: +# None +######################### +generate_systemd_conf() { + local -r service_name="${1:?service name is missing}" + local -r systemd_units_dir="/etc/systemd/system" + local -r service_file="${systemd_units_dir}/bitnami.${service_name}.service" + # Default values + local name="$service_name" + local type="forking" + local user="" + local group="" + local environment="" + local exec_start="" + local exec_stop="" + local exec_reload="" + local restart="always" + local pid_file="" + # Parse CLI flags + shift + while [[ "$#" -gt 0 ]]; do + case "$1" in + --name \ + | --type \ + | --user \ + | --group \ + | --exec-start \ + | --exec-stop \ + | --exec-reload \ + | --restart \ + | --pid-file \ + ) + var_name="$(echo "$1" | sed -e "s/^--//" -e "s/-/_/g")" + shift + declare "$var_name"="${1:?"$var_name" is missing}" + ;; + --environment) + shift + # It is possible to add multiple environment lines + [[ -n "$environment" ]] && environment+=$'\n' + environment+="Environment=${1:?"environment" is missing}" + ;; + *) + echo "Invalid command line flag ${1}" >&2 + return 1 + ;; + esac + shift + done + # Validate inputs + local error="no" + if [[ -z "$exec_start" ]]; then + error "The --exec-start option is required" + error="yes" + fi + if [[ "$restart" = "always" && -z "$pid_file" ]]; then + error "The --restart option cannot be set to 'always' if --pid-file is not set" + error="yes" + fi + if [[ "$error" != "no" ]]; then + return 1 + fi + # Generate the Systemd unit + cat > "$service_file" <> "$service_file" <> "$service_file" <> "$service_file" <> "$service_file" <> "$service_file" <> "$service_file" <<< "$environment" + fi + cat >> "$service_file" <