Skip to content

Instantly share code, notes, and snippets.

@joe-at-cp
Last active January 14, 2022 17:51
Show Gist options
  • Select an option

  • Save joe-at-cp/e833127a9545db29a5b488b06d263947 to your computer and use it in GitHub Desktop.

Select an option

Save joe-at-cp/e833127a9545db29a5b488b06d263947 to your computer and use it in GitHub Desktop.
Azure Custom-Data - Check Point Gateway - Basic Autoreg Setup
#!/bin/bash
CP_MGMT="10.200.1.3"
API_USER="api_user"
API_PASS="vpn123"
SIC_KEY="vpn123"
MGMT_IF="eth0"
MGMT_IP=$(ifconfig $MGMT_IF | grep inet | awk '{print $2}' | cut -d ':' -f 2)
blink_config -s "gateway_cluster_member=false&ftw_sic_key=$SIC_KEY&upload_info=true&download_info=true"
SID=`curl_cli -s -k -H "Content-Type: application/json" -H "Accept: bla" -X POST -d '{"user":"'"$API_USER"'","password":"'"$API_PASS"'"}' https://$CP_MGMT/web_api/login | jq '.sid' | sed s/\"//g`
curl_cli -s -k -H "Content-Type: application/json" -H "Accept: bla" -H "X-chkp-sid: $SID" -X POST -d '{"name":"'"$(hostname)"'","ip-address":"'"$MGMT_IP"'","one-time-password":"'"$SIC_KEY"'"}' https://$CP_MGMT/web_api/add-simple-gateway
PUBLISH_TASK=$(curl_cli -s -k -H "Content-Type: application/json" -H "Accept: bla" -H "X-chkp-sid: $SID" -X POST -d '{}' https://$CP_MGMT/web_api/publish | jq ."task-id" -r)
while true;
do
PUBLISH_STATUS=$(curl_cli -s -k -H "Content-Type: application/json" -H "Accept: bla" -H "X-chkp-sid: $SID" -X POST -d '{"task-id":"'"$PUBLISH_TASK"'"}' https://$CP_MGMT/web_api/show-task | jq '.[]?' -r)
if [ "$PUBLISH_STATUS" == "succeeded" ]; then break; else sleep 1s; fi
done
curl_cli -s -k -H "Content-Type: application/json" -H "Accept: bla" -H "X-chkp-sid: $SID" -X POST -d '{}' https://$CP_MGMT/web_api/logout
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment