Last active
August 29, 2015 14:16
-
-
Save emresebat/7ef827ad879059357641 to your computer and use it in GitHub Desktop.
Shell scripts for BaasBox admin/plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#post .js file contents to BaasBox to create plugin | |
#usage bash postBaasBoxPlugin.sh sample.js | |
#get fileName | |
fileName="$1" | |
#uncomment below line to read file contents to variable | |
#codeContent=$(<$fileName) | |
#uncomment below line to read file contents as base64 encoded to variable | |
#codeContent=$( base64 $fileName) | |
#until base64 decoding is implemented on the server just replace newline for valid JSON | |
codeContent=$(while read line; do echo -n "$line "; done < $fileName) | |
#strip .js part of fileName to set as plugin name | |
codeName=${fileName/.js/} | |
#post the data | |
curl \ | |
-X POST \ | |
-H "X-BAASBOX-APPCODE:ENTER_YOUR_APPCODE" \ | |
-H "Authorization:ENTER_YOUR_AUTHRIZATION" \ | |
-H "Content-Type:application/json" \ | |
--data '{ "lang": "javascript", "name": "'"$codeName"'", "code": "'"$codeContent"'" }' \ | |
"ENTER_YOUR_BASEURL/admin/plugin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#post .js file contents to BaasBox to update plugin | |
#usage bash putBaasBoxPlugin.sh sample.js | |
#get fileName | |
fileName="$1" | |
#uncomment below line to read file contents to variable | |
#codeContent=$(<$fileName) | |
#uncomment below line to read file contents as base64 encoded to variable | |
#codeContent=$( base64 $fileName) | |
#until base64 decoding is implemented on the server just replace newline for valid JSON | |
codeContent=$(while read line; do echo -n "$line "; done < $fileName) | |
#strip .js part of fileName to set as plugin name | |
codeName=${fileName/.js/} | |
#post the data | |
curl \ | |
-X PUT \ | |
-H "X-BAASBOX-APPCODE:ENTER_YOUR_APPCODE" \ | |
-H "Authorization:ENTER_YOUR_AUTHRIZATION" \ | |
-H "Content-Type:application/json" \ | |
--data '{ "lang": "javascript", "name": "'"$codeName"'", "code": "'"$codeContent"'" }' \ | |
"ENTER_YOUR_BASEURL/admin/plugin/$codeName" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment