Browse Source

rename ovh-bash to ovhcli

volixer 5 months ago
parent
commit
6dd86687e6

+ 5 - 5
scripts/bash/README.md

@@ -16,7 +16,7 @@ And add the Application_key,secret_key and consumer_key to the [ovh.conf](/../go
 **Examples**
 1. Get all VPS
 ```bash
-./ovh-bash get vps
+./ovhcli get vps
 
 [
   "vps-3e2da6b4.vps.ovh.net",
@@ -30,7 +30,7 @@ And add the Application_key,secret_key and consumer_key to the [ovh.conf](/../go
 ```
 2. Get all records for a DNS Zone "linuxforward.com"
 ```bash
-./ovh-bash get domain/zone/linuxforward.com/record/
+./ovhcli get domain/zone/linuxforward.com/record/
 [
   5344790631,
   5344790632,
@@ -50,7 +50,7 @@ And add the Application_key,secret_key and consumer_key to the [ovh.conf](/../go
 3. Get info from a specific DNS Zone record
 
 ```bash
-./ovh-bash get domain/zone/linuxforward.com/record/5344790650
+./ovhcli get domain/zone/linuxforward.com/record/5344790650
 {
   "fieldType": "A",
   "id": 5344790650,
@@ -64,7 +64,7 @@ And add the Application_key,secret_key and consumer_key to the [ovh.conf](/../go
 
 4. List all details from all VPS
 ```bash
-./ovh-bash get vps | jq -r '.[]' | while read vps;  do ./ovh-bash get vps/${vps} | jq  '[.name, .model.name, .model.version, .model.disk, .model.memory]|@tsv' ; done | column -t
+./ovhcli get vps | jq -r '.[]' | while read vps;  do ./ovhcli get vps/${vps} | jq  '[.name, .model.name, .model.version, .model.disk, .model.memory]|@tsv' ; done | column -t
 vps-3e2da6b4.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
 vps-556c9180.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
 vps-59e2e922.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
@@ -77,7 +77,7 @@ vps-f31d3392.vps.ovh.net  vps-starter-1-2-20  2019v1  20  2048
 5. If credentials are revoked
 
 ```bash
-./ovh-bash get vps
+./ovhcli get vps
 {
   "class": "Client::Forbidden",
   "message": "This credential is not valid",

+ 3 - 3
scripts/bash/delDNSName

@@ -5,12 +5,12 @@ ZONE="linuxforward.com"
 
 
 # get subdomain record id
-record_id=$( ./ovh-bash get "domain/zone/${ZONE}/record?fieldType=A&subDomain=${SUB_DOMAIN}" | jq -r '.[]' )
+record_id=$( ./ovhcli get "domain/zone/${ZONE}/record?fieldType=A&subDomain=${SUB_DOMAIN}" | jq -r '.[]' )
 
 if [ -n "${record_id}" ]; then
-  ./ovh-bash delete "domain/zone/${ZONE}/record/${record_id}" | jq -r 'select(. != null)'
+  ./ovhcli delete "domain/zone/${ZONE}/record/${record_id}" | jq -r 'select(. != null)'
   sleep 2
-  ./ovh-bash post "domain/zone/${ZONE}/refresh" | jq -r 'select(. != null)'
+  ./ovhcli post "domain/zone/${ZONE}/refresh" | jq -r 'select(. != null)'
 else
   echo "Could not find any RecordID for ${SUB_DOMAIN}"
 fi

+ 1 - 1
scripts/bash/delSSHKey

@@ -2,6 +2,6 @@
 
 KEY_NAME="${1:?need a SSHKey name from /me}"
 
-./ovh-bash delete "me/sshKey/${KEY_NAME}" | jq -r 'select(. != null)'
+./ovhcli delete "me/sshKey/${KEY_NAME}" | jq -r 'select(. != null)'
 
 exit $?

+ 1 - 1
scripts/bash/getImageDetails

@@ -2,6 +2,6 @@
 
 SRV="${1:?Need a fqdn}"
 
-./ovh-bash get "vps/${SRV}/images/current" | jq -r '.'
+./ovhcli get "vps/${SRV}/images/current" | jq -r '.'
 
 exit $?

+ 1 - 1
scripts/bash/getSSHKeys

@@ -2,6 +2,6 @@
 
 KEY_NAME="${1:?need a SSHKey name from /me}"
 
-./ovh-bash get "me/sshKey/${KEY_NAME}"
+./ovhcli get "me/sshKey/${KEY_NAME}"
 
 exit $?

+ 3 - 3
scripts/bash/getSecret

@@ -1,10 +1,10 @@
 #!/bin/bash
 
 # get Email Secret ID :
-last_id=$( ./ovh-bash get me/notification/email/history | jq 'last(.[])' )
-secret_id=$( ./ovh-bash get "me/notification/email/history/${last_id}"  | jq -r '.body' | awk '/secret/ { split($NF,a,"=") ; print a[2] }' )
+last_id=$( ./ovhcli get me/notification/email/history | jq 'last(.[])' )
+secret_id=$( ./ovhcli get "me/notification/email/history/${last_id}"  | jq -r '.body' | awk '/secret/ { split($NF,a,"=") ; print a[2] }' )
 
 # retrieve or set Password from email link
-./ovh-bash post secret/retrieve '{ "id": "'"${secret_id}"'" }' | jq -r '.secret'
+./ovhcli post secret/retrieve '{ "id": "'"${secret_id}"'" }' | jq -r '.secret'
 
 exit $?

+ 3 - 3
scripts/bash/newSSHKey

@@ -16,10 +16,10 @@ PUBKEY="$( cat "${KEY_DIR}/${KEY_NAME}.pub" )"
 
 # check if KEY_NAME exists into OVH User Account /me
 # remote_keyname = "string or empty"
-remote_keyname=$( ./ovh-bash get "me/sshKey" | jq --arg v "${KEY_NAME}" -r '.|to_entries[]|select(.value == $v ).value' )
+remote_keyname=$( ./ovhcli get "me/sshKey" | jq --arg v "${KEY_NAME}" -r '.|to_entries[]|select(.value == $v ).value' )
 
 # if remote_keyname exists check if pubkey is matching.
-remote_pubkey=$( ./ovh-bash get "me/sshKey/${KEY_NAME}" | jq -r '.key' )
+remote_pubkey=$( ./ovhcli get "me/sshKey/${KEY_NAME}" | jq -r '.key' )
   
 # if remote_keyname does not match KEY_NAME = this KEY_NAME is not already uploaded into OVH Account
 if [ -z "${remote_keyname}" ] || [ "${remote_pubkey}" != "${PUBKEY}" ] ; then
@@ -27,7 +27,7 @@ if [ -z "${remote_keyname}" ] || [ "${remote_pubkey}" != "${PUBKEY}" ] ; then
   echo ">>> Uploading ${KEY_DIR}/${KEY_NAME} to OVH account"
   HTTP_PAYLOAD='{ "key": "'${PUBKEY}'", "keyName": "'${KEY_NAME}'" }'
 
-  ./ovh-bash post "me/sshKey" "${HTTP_PAYLOAD}" | jq -r 'select(. != null)'
+  ./ovhcli post "me/sshKey" "${HTTP_PAYLOAD}" | jq -r 'select(. != null)'
 
 else
   echo "SSH Keys are up-to-date"

+ 1 - 1
scripts/bash/ovh-bash → scripts/bash/ovhcli

@@ -25,7 +25,7 @@ esac
 TIME=$( curl -s "${ENDPOINT}/auth/time" )
 
 # Method
-# ovh-bash get vps
+# ovhcli get vps
 HTTP_METHOD="${1:?need a http method}"
 HTTP_QUERY="${ENDPOINT}/${2:?need a query}"
 HTTP_PAYLOAD="${3}"

+ 2 - 2
scripts/bash/setDNSName

@@ -10,8 +10,8 @@ SUB_DOMAIN_2="$( awk '$0 ~ /^\w{5}$/ { print tolower($1) }' /usr/share/dict/word
 
 HTTP_PAYLOAD='{ "fieldType": "A", "subDomain": "'${SUB_DOMAIN_1}-${SUB_DOMAIN_2}'", "target": "'${SRV_IP}'", "ttl": '${TTL}' }'
 
-./ovh-bash post "domain/zone/${ZONE}/record" "${HTTP_PAYLOAD}"
+./ovhcli post "domain/zone/${ZONE}/record" "${HTTP_PAYLOAD}"
 sleep 2
-./ovh-bash post "domain/zone/${ZONE}/refresh" | jq -r 'select(. != null)'
+./ovhcli post "domain/zone/${ZONE}/refresh" | jq -r 'select(. != null)'
 
 exit $?

+ 1 - 1
scripts/bash/setNewName

@@ -4,6 +4,6 @@ SRV=${1:?need a fqdn}
 NEWDISPLAY_NAME=${2:?new display name, a human readable one}
 HTTP_PAYLOAD='{ "displayName": "'${NEWDISPLAY_NAME}'" }'
 
-./ovh-bash put "vps/${SRV}" "${HTTP_PAYLOAD}" | jq -r 'select(. != null)'
+./ovhcli put "vps/${SRV}" "${HTTP_PAYLOAD}" | jq -r 'select(. != null)'
 
 exit $?

+ 1 - 1
scripts/bash/vpsReinstall

@@ -9,6 +9,6 @@ current_image_id=$( ./getImageDetails "${SRV}" | jq -r '.id' )
 IMAGE_ID="${3:-${current_image_id}}"
 HTTP_PAYLOAD='{ "doNotSendPassword": true, "publicSshKey": "'${sshpubkey}'", "imageId": "'${IMAGE_ID}'" }'
 
-./ovh-bash post "vps/${SRV}/rebuild" "${HTTP_PAYLOAD}"
+./ovhcli post "vps/${SRV}/rebuild" "${HTTP_PAYLOAD}"
 
 exit $?