Skip to content

Commit

Permalink
[oneimage] Check if graph service address got from dhcp is valid url (#…
Browse files Browse the repository at this point in the history
…324)

* [oneimage] Check if graph service address got from dhcp is valid url
  • Loading branch information
taoyl-ms authored Feb 23, 2017
1 parent 151a7d2 commit 873f6f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions files/image_config/updategraph/updategraph
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ if [ "$src" = "dhcp" ]; then

HOSTNAME=`hostname -s`
GRAPH_URL=`sonic-cfggen -t /tmp/dhcp_graph_url -a "{\"hostname\": \"$HOSTNAME\"}"`
URL_REGEX='^(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'
if [[ ! $GRAPH_URL =~ $URL_REGEX ]]; then
echo "\"$GRAPH_URL\" is not a valid url. Skipping graph update."
exit 0
fi
if [ "$dhcp_as_static" = "true" ]; then
sed -i "/src=d/d" /etc/sonic/updategraph.conf
echo "src=$GRAPH_URL" >> /etc/sonic/updategraph.conf
sed -i "/src=/d" /etc/sonic/updategraph.conf
echo "src=\"$GRAPH_URL\"" >> /etc/sonic/updategraph.conf
fi
else
GRAPH_URL=$src
Expand Down

0 comments on commit 873f6f8

Please sign in to comment.