2 # ============LICENSE_START=======================================================
4 # ================================================================================
5 # Copyright © 2018 AT&T Intellectual Property. All rights reserved.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
20 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 if [[ $# != 1 ]]; then
25 echo "Usage: $0 string-to-urlencode"
28 data="$(curl -s -o /dev/null -w %url_effective --get --data-urlencode "$1" "")"
29 if [[ $? != 3 ]]; then
30 echo "Unexpected error" 1>&2
38 PATH=/opt/app/datartr/bin:/bin:/usr/bin:$PATH
40 export PATH PROVSRVR PROVCMD NOPROXY
42 if [ ! -x /usr/bin/curl ]
44 echo provcmd: curl is required for this tool.
48 while [ -z "$optloop" ]
69 echo "provcmd: you need to specify the server, either via the -s option"
70 echo " or by setting and exporting PROVSRVR"
76 if [ "$CMD" == 'delete' ]
82 [ -n "$VERBOSE" ] && echo curl -4 -k -X DELETE "https://$PROVSRVR/internal/api/$1$NOPROXY"
83 curl -4 -k -X DELETE "https://$PROVSRVR/internal/api/$1$NOPROXY"
87 elif [ "$CMD" == 'create' ]
91 # create (with POST), then set the value
92 [ -n "$VERBOSE" ] && echo curl -4 -k -X POST --data '' "https://$PROVSRVR/internal/api/$1$NOPROXY"
93 curl -4 -k -X POST --data '' "https://$PROVSRVR/internal/api/$1$NOPROXY"
94 $PROVCMD set "$1" "$2"
97 elif [ "$CMD" == 'get' ]
102 [ -n "$VERBOSE" ] && echo curl -4 -k "https://$PROVSRVR/internal/api/$1$NOPROXY"
103 curl -4 -k "https://$PROVSRVR/internal/api/$1$NOPROXY" 2>/dev/null | tr '|' '\012' | sort
106 elif [ "$CMD" == 'set' ]
113 for i; do [ -n "$v" ] && v="$v|"; v="$v$i"; done
116 NOPROXY=`echo $NOPROXY | tr '?' '&'`
117 [ -n "$VERBOSE" ] && echo curl -4 -k -X PUT "https://$PROVSRVR/internal/api/$p?val=$ue$NOPROXY"
118 curl -4 -k -X PUT "https://$PROVSRVR/internal/api/$p?val=$ue$NOPROXY"
121 elif [ "$CMD" == 'append' ]
127 tmp=`curl -4 -k "https://$PROVSRVR/internal/api/$p$NOPROXY" 2>/dev/null`
128 $PROVCMD set "$p" "$tmp" "$@"
131 elif [ "$CMD" == 'remove' ]
137 $PROVCMD get "$p" | grep -v "^$rm\$" > /tmp/pc$$
139 $PROVCMD set "$p" `cat /tmp/pc$$`
145 # Some error somewhere - display usage
147 usage: provcmd [ -s server ] delete name1 [ name2 ... ]
148 provcmd [ -s server ] get name
149 provcmd [ -s server ] create name value
150 provcmd [ -s server ] set name value1 [ value2 ... ]
151 provcmd [ -s server ] append name value1 [ value2 ... ]
152 provcmd [ -s server ] remove name value
154 delete - remove the parameters named name1, name2 ...
155 get - displays the parameters' value
156 create - creates a new parameter
157 set - sets the value of an existing parameter
158 append - appends the value to a list-based parameter
159 remove - removes a value from a list based parameter
161 server - the provisioning server FQDN (feeds-drtr.web.att.com for production)
163 Standard Parameters Names:
164 ------------------------------
166 DELIVERY_INIT_RETRY_INTERVAL
168 DELIVERY_MAX_RETRY_INTERVAL