Skip to content

Commit

Permalink
Update function comments, remove duplicate rpm package installs
Browse files Browse the repository at this point in the history
Add source to util-common.sh in all files, for shellcheck definitions.
  • Loading branch information
s-fairchild committed Aug 21, 2024
1 parent 7a4b447 commit 2bfee45
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
4 changes: 1 addition & 3 deletions pkg/deploy/generator/scripts/gatewayVMSS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ main() {

# shellcheck disable=SC2034
local -ra install_pkgs=(
azure-cli
clamav
azsec-clamav
azure-cli
Expand All @@ -44,7 +43,6 @@ main() {
# Required to enable fips
grubby
dracut-fips
dracut-fips
)

dnf_install_pkgs install_pkgs \
Expand Down Expand Up @@ -159,7 +157,7 @@ RPIMAGE='$rpimage'"
export AZURE_CLOUD_NAME="${AZURECLOUDNAME:?"Failed to carry over variables"}"

# util.sh does not exist when deployed to VMSS via VMSS extensions
# This is because commonVMSS.sh is concatenated with this script
# Provides shellcheck definitions
util="util.sh"
if [ -f "$util" ]; then
# shellcheck source=util.sh
Expand Down
4 changes: 1 addition & 3 deletions pkg/deploy/generator/scripts/rpVMSS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ main() {

# shellcheck disable=SC2034
local -ra install_pkgs=(
azure-cli
clamav
azsec-clamav
azure-cli
Expand All @@ -43,7 +42,6 @@ main() {
# Required to enable fips
grubby
dracut-fips
dracut-fips
)

dnf_install_pkgs install_pkgs \
Expand Down Expand Up @@ -197,7 +195,7 @@ OIDC_STORAGE_ACCOUNT_NAME='$OIDCSTORAGEACCOUNTNAME'
export AZURE_CLOUD_NAME="${AZURECLOUDNAME:?"Failed to carry over variables"}"

# util.sh does not exist when deployed to VMSS via VMSS extensions
# This is because commonVMSS.sh is concatenated with this script
# Provides shellcheck definitions
util="util.sh"
if [ -f "$util" ]; then
# shellcheck source=util.sh
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/generator/scripts/util-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare -r role_devproxy="devproxy"
# log is a wrapper for echo that includes the function name
# Args
# 1) msg - string
# 2) stack_level - int; optional, defaults to calling function
# 2) stack_level - int; optional, defaults to the function at the bottom of the call stack
log() {
local -r msg="${1:-"log message is empty"}"
local -r stack_level="${2:-1}"
Expand Down Expand Up @@ -127,7 +127,7 @@ get_keyvault_suffix() {
esac
}

# reboot_vm restores all selinux file contexts, then schedules a reboot for one hour later
# reboot_vm restores calls shutdown -r in a subshell
# Reboots should scheduled after all VM extensions have had time to complete
# Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux#tips
reboot_vm() {
Expand Down
8 changes: 8 additions & 0 deletions pkg/deploy/generator/scripts/util-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,11 @@ rpm_import_keys() {
retry cmd "$2" "${3:-}" && unset key
done
}

# util-common.sh does not exist when deployed to VMSS via VMSS extensions
# Provides shellcheck definitions
util_common="util-common.sh"
if [ -f "$util_common" ]; then
# shellcheck source=util-common.sh
source "$util_common"
fi
10 changes: 10 additions & 0 deletions pkg/deploy/generator/scripts/util-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,18 @@ configure_vmss_aro_services() {
run_azsecd_config_scan
}

# util-common.sh does not exist when deployed to VMSS via VMSS extensions
# Provides shellcheck definitions
util_common="util-common.sh"
if [ -f "$util_common" ]; then
# shellcheck source=util-common.sh
source "$util_common"
fi

# util-system.sh does not exist when deployed to VMSS via VMSS extensions
# Provides shellcheck definitions
util_system="util-system.sh"
if [ -f "$util_system" ]; then
# shellcheck source=util-system.sh
source "$util_system"
fi
8 changes: 8 additions & 0 deletions pkg/deploy/generator/scripts/util-system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,11 @@ firewalld_configure() {
log "Writing runtime config to permanent config"
firewall-cmd --runtime-to-permanent
}

# util-common.sh does not exist when deployed to VMSS via VMSS extensions
# Provides shellcheck definitions
util_common="util-common.sh"
if [ -f "$util_common" ]; then
# shellcheck source=util-common.sh
source "$util_common"
fi

0 comments on commit 2bfee45

Please sign in to comment.