[oneimage] Check if graph service address got from dhcp is valid url (#324)
* [oneimage] Check if graph service address got from dhcp is valid url
This commit is contained in:
parent
151a7d2a90
commit
873f6f8fb6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user