Ver código fonte

update Makefile and all bin/*

volixer 5 meses atrás
pai
commit
857842ddae
9 arquivos alterados com 28 adições e 19 exclusões
  1. 1 1
      Makefile
  2. 4 3
      bin/delDNSName
  3. 3 2
      bin/delSSHKey
  4. 3 2
      bin/getImageDetails
  5. 3 2
      bin/getSSHKeys
  6. 5 3
      bin/getSecret
  7. 3 2
      bin/setDNSName
  8. 3 2
      bin/setNewName
  9. 3 2
      bin/vpsReinstall

+ 1 - 1
Makefile

@@ -52,7 +52,7 @@ install:
 	@echo -e "\nCongrats! Now you should be able to run '$(PKG_NAME)' from your PATH\n"
 
 uninstall:
-	@echo "Uninstall all files from $(PKG_NAME)-$(VERSION)"
+	@echo "Uninstall all files from $(PKG_NAME)"
 	@for file in $(INSTALL_FILES); do sudo rm -f $(PREFIX)/$$file; done
 	@sudo rm -r $(DOC_DIR)
 

+ 4 - 3
bin/delDNSName

@@ -1,15 +1,16 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
 SUB_DOMAIN="${1:?Need customer subdomain code}"
 ZONE="linuxforward.com"
 
 # get subdomain record id
-record_id=$( ./ovhcli 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
-  ./ovhcli 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
-  ./ovhcli 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

+ 3 - 2
bin/delSSHKey

@@ -1,7 +1,8 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
 KEY_NAME="${1:?need a SSHKey name from /me}"
 
-./ovhcli delete "me/sshKey/${KEY_NAME}" | jq -r 'select(. != null)'
+ovhcli delete "me/sshKey/${KEY_NAME}" | jq -r 'select(. != null)'
 
-exit $?
+exit $?

+ 3 - 2
bin/getImageDetails

@@ -1,7 +1,8 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
 SRV="${1:?Need a fqdn}"
 
-./ovhcli get "vps/${SRV}/images/current" | jq -r '.'
+ovhcli get "vps/${SRV}/images/current" | jq -r '.'
 
-exit $?
+exit $?

+ 3 - 2
bin/getSSHKeys

@@ -1,7 +1,8 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
 KEY_NAME="${1:?need a SSHKey name from /me}"
 
-./ovhcli get "me/sshKey/${KEY_NAME}"
+ovhcli get "me/sshKey/${KEY_NAME}"
 
-exit $?
+exit $?

+ 5 - 3
bin/getSecret

@@ -1,10 +1,12 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
+
 # get Email Secret ID :
-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] }' )
+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
-./ovhcli post secret/retrieve '{ "id": "'"${secret_id}"'" }' | jq -r '.secret'
+ovhcli post secret/retrieve '{ "id": "'"${secret_id}"'" }' | jq -r '.secret'
 
 exit $?

+ 3 - 2
bin/setDNSName

@@ -1,5 +1,6 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
 SRV="${1:?Need a current server fqdn}"
 ZONE="linuxforward.com"
 TTL=0
@@ -10,8 +11,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}' }'
 
-./ovhcli post "domain/zone/${ZONE}/record" "${HTTP_PAYLOAD}"
+ovhcli post "domain/zone/${ZONE}/record" "${HTTP_PAYLOAD}"
 sleep 2
-./ovhcli post "domain/zone/${ZONE}/refresh" | jq -r 'select(. != null)'
+ovhcli post "domain/zone/${ZONE}/refresh" | jq -r 'select(. != null)'
 
 exit $?

+ 3 - 2
bin/setNewName

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

+ 3 - 2
bin/vpsReinstall

@@ -1,5 +1,6 @@
 #!/bin/bash
 
+PATH="/usr/local/bin:${PATH}"
 SRV="${1:?Need a fqdn}"
 SSHKEY_NAME="${2:-vpsbot}"
 
@@ -9,6 +10,6 @@ current_image_id=$( ./getImageDetails "${SRV}" | jq -r '.id' )
 IMAGE_ID="${3:-${current_image_id}}"
 HTTP_PAYLOAD='{ "doNotSendPassword": true, "publicSshKey": "'${sshpubkey}'", "imageId": "'${IMAGE_ID}'" }'
 
-./ovhcli post "vps/${SRV}/rebuild" "${HTTP_PAYLOAD}"
+ovhcli post "vps/${SRV}/rebuild" "${HTTP_PAYLOAD}"
 
-exit $?
+exit $?