Home > Networking Solutions > Enterprise/Data Center Networking Solutions > Enterprise SONiC Networking Solutions > Guides > Zero Touch Deployment of Open Dell Switches with SONiC > Provisioning script
Save the provisioning in /tftpboot/sonic/postscript/postscript_simple.sh.
This is the last script executed in the ZTP cycle. In this lab, the script will perform the following:
Copy the following contents into the postscript_simple.sh
#!/bin/bash
ZTD_SERVER_IP="192.168.240.101"
ZTD_PATH=/tftpboot
CALLBACK=/callback
CGI=/cgi-bin/callback.sh
HOSTS=/etc/hosts
USER_NAME=admin
PASSWORD=YourPaSsWoRd
MGMT_IP=localhost
APP=http://
APPLOCAL=https://
## Extract the ip-address that was received from dhcp server
DHCP_IP=`hostname -I | awk '{printf $1}'`
# Request callback script at http server (cgi-script)
# This creates a file with name <ip-address> and hostname in it on the server end
/usr/bin/curl -s ${APP}${ZTD_SERVER_IP}${CGI}
sleep 2
# Fetch switch hostname
SWITCHNAME=`/usr/bin/curl ${APP}${ZTD_SERVER_IP}${ZTD_PATH}${CALLBACK}/${DHCP_IP}`
sleep 2
# Check if switchname was found on webserver and received
if [ -z "${SWITCHNNAME}" ]
then
SWITCHNAME="ztp-staged-done" #Callback script malfunctioning
else
SWITCHNAME=${SWITCHNAME}
fi
echo "Found desired hostname: $SWITCHNAME"
# current hostname of switch
CURRENTHOSTNAME=`hostname`
echo "current hostname: ${CURRENTHOSTNAME}"
# set hostname via localhost REST call
curl -s -k -X PATCH "https://localhost/restconf/data/openconfig-system:system/config/hostname" -H "accept: */*" -H "Content-Type: application/yang-data+json" -u ${USER_NAME}:${PASSWORD} -d "{\"openconfig-system:hostname\":\"$SWITCHNAME\"}"
# Save config permanent
config save -y
Set executable attribute:
chmod a+x /tftpboot/sonic/postscript/postscript_simple.sh