Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework to plugin Organization specific scripts during ONIE Image build #951

Merged
merged 4 commits into from
Sep 19, 2017
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
8 changes: 8 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ if [ -f sonic_debian_extension.sh ]; then
./sonic_debian_extension.sh $FILESYSTEM_ROOT $PLATFORM_DIR
fi

## Organization specific extensions such as Configuration & Scripts for features like AAA, ZTP...
if [ "${enable_organization_extensions}" = "y" ]; then
if [ -f files/build_templates/organization_extensions.sh ]; then
sudo chmod 755 files/build_templates/organization_extensions.sh
./files/build_templates/organization_extensions.sh -f $FILESYSTEM_ROOT -h $HOSTNAME
fi
fi

## Clean up apt
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get autoremove
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get autoclean
Expand Down
52 changes: 52 additions & 0 deletions files/build_templates/organization_extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
#########################################################################
## This script is to automate Orignaization specific extensions #
## such as Configuration & Scripts for features like AAA, ZTP, etc. #
## to include in ONIE installer image #
## #
## USAGE: #
## ./organization_extensions.sh -f<filesystem_root> -n<hostname> #
## ./organization_extensions.sh \ #
## --fsroot <filesystem_root> \ #
## --hostname <hostname> #
## PARAMETERS: #
## -f FILESYSTEM_ROOT #
## The location of the root file system #
## -h HOSTNAME #
## The hostname of the target system #
#########################################################################

## Initialize the arguments to default values.
## The values get updated to user provided value, if supplied
FILESYSTEM_ROOT=./fsroot
HOSTNAME=sonic

# read the options
TEMP=`getopt -o f:h: --long fsroot:,hostname: -- "$@"`
eval set -- "$TEMP"

# extract options and their arguments into variables.
while true ; do
case "$1" in
-f|--fsroot)
case "$2" in
"") shift 2 ;;
*) FILESYSTEM_ROOT=$2 ; shift 2 ;;
esac ;;
-h|--hostname)
case "$2" in
"") shift 2 ;;
*) HOSTNAME=$2 ; shift 2 ;;
esac ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done

echo "Executing SONIC Organization Extensions"

## Place your Organization specific code / scipts here ...


echo "SONIC Organization Extensions - Done"

3 changes: 3 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ SONIC_ROUTING_STACK = quagga
# ENABLE_SYNCD_RPC - build docker-syncd with rpc packages for testing purposes.
# Uncomment to enable:
# ENABLE_SYNCD_RPC = y

# Enable Origanization Extensions - Specific to the deployment scenarios of the Organization
ENABLE_ORGANIZATION_EXTENSIONS = y
2 changes: 2 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ $(info "SHUTDOWN_BGP_ON_START" : "$(SHUTDOWN_BGP_ON_START)")
$(info "SONIC_CONFIG_DEBUG" : "$(SONIC_CONFIG_DEBUG)")
$(info "ROUTING_STACK" : "$(SONIC_ROUTING_STACK)")
$(info "ENABLE_SYNCD_RPC" : "$(ENABLE_SYNCD_RPC)")
$(info "ENABLE_ORGANIZATION_EXTENSIONS" : "$(ENABLE_ORGANIZATION_EXTENSIONS)")
$(info )

###############################################################################
Expand Down Expand Up @@ -381,6 +382,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform
export image_type="$($*_IMAGE_TYPE)"
export sonicadmin_user="$(USERNAME)"
export sonic_asic_platform="$(CONFIGURED_PLATFORM)"
export enable_organization_extensions="$(ENABLE_ORGANIZATION_EXTENSIONS)"
export enable_dhcp_graph_service="$(ENABLE_DHCP_GRAPH_SERVICE)"
export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)"
export installer_debs="$(addprefix $(DEBS_PATH)/,$($*_DEPENDS))"
Expand Down