Skip to content

Commit

Permalink
Framework to plugin Organization specific scripts during ONIE Image b…
Browse files Browse the repository at this point in the history
…uild (#951)

* Framework to plugin Organization specific scripts

* Framework to plugin Organization specific scripts

* Framework to plugin Organization specific scripts

* add getopt option to organization script
  • Loading branch information
ravijo2 authored and lguohan committed Sep 19, 2017
1 parent 9139c7f commit 458093f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,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 @@ -48,3 +48,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 @@ -388,6 +389,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

0 comments on commit 458093f

Please sign in to comment.