Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/bootstrap_openchami.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ generate_environment_file() {
local short_name=$(hostname -s)
local dns_name=$(hostname -d)
local system_fqdn=$(hostname)

sed -i "s/^SYSTEM_NAME=.*/SYSTEM_NAME=${short_name}/" /etc/openchami/configs/openchami.env
sed -i "s/^SYSTEM_DOMAIN=.*/SYSTEM_DOMAIN=${dns_name}/" /etc/openchami/configs/openchami.env
sed -i "s/^SYSTEM_URL=.*/SYSTEM_URL=${system_fqdn}/" /etc/openchami/configs/openchami.env
Expand All @@ -40,10 +41,12 @@ generate_environment_file() {

acme_correction() {
local system_fqdn=$(hostname)
primary_ip=$(hostname -I | awk '{print $1}')
sed -i "s|-d .* \\\\|-d ${system_fqdn} \\\\|" /etc/containers/systemd/acme-deploy.container
sed -i "s/^ContainerName=.*/ContainerName=${system_fqdn}/" /etc/containers/systemd/acme-register.container
sed -i "s/^HostName=.*/HostName=${system_fqdn}/" /etc/containers/systemd/acme-register.container
sed -i "s|-d .* \\\\|-d ${system_fqdn} \\\\|" /etc/containers/systemd/acme-register.container
sed -i "s|--add-host='demo\.openchami\.cluster:[0-9\.]*'|--add-host='${system_fqdn}:${primary_ip}'|" /etc/containers/systemd/opaal.container
}

# Check and create secrets with random passwords if needed
Expand Down
27 changes: 21 additions & 6 deletions scripts/openchami-certificate-update
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ update_dns() {
local system_fqdn=$1
local short_name="${system_fqdn%%.*}"
local dns_name="${system_fqdn#*.}"
local primary_ip=$(hostname -I | awk '{print $1}')

# Update names in environment and acme containers
sed -i "s/^SYSTEM_NAME=.*/SYSTEM_NAME=${short_name}/" /etc/openchami/configs/openchami.env
Expand All @@ -18,15 +19,29 @@ update_dns() {
sed -i "s/^ContainerName=.*/ContainerName=${system_fqdn}/" /etc/containers/systemd/acme-register.container
sed -i "s/^HostName=.*/HostName=${system_fqdn}/" /etc/containers/systemd/acme-register.container
sed -i "s|-d .* \\\\|-d ${system_fqdn} \\\\|" /etc/containers/systemd/acme-register.container
sed -i "s|--add-host='.*|--add-host='${system_fqdn}:${primary_ip}'|" /etc/containers/systemd/opaal.container

# Re-apply Certificates
systemctl restart acme-deploy
systemctl restart haproxy
# Reload systemD after .container changes
systemctl daemon-reload

echo "Changed FQDN to ${1}"
echo 'Either restart all of the OpenCHAMI services:'
echo
echo ' sudo systemctl restart openchami.target'
echo
echo 'or run the following to just regenerate/redeploy the certificates:'
echo
echo ' sudo systemctl restart acme-deploy'
echo
}

help_page() {
echo "OpenCHAMI Certificate Update"
echo "Usage: $0 update (dns name) ex. demo.openchami.cluster"
echo "Update OpenCHAMI Certificates"
echo "Usage: $0 update FQDN"
echo
echo "EXAMPLES:"
echo " $0 update demo.openchami.cluster"

}
case "$1" in
Expand All @@ -43,7 +58,7 @@ case "$1" in
fi
;;
*)
help_page
exit 1
help_page
exit 1
;;
esac