Skip to content

Instantly share code, notes, and snippets.

@emresebat
Last active August 29, 2015 14:16
Show Gist options
  • Save emresebat/7ef827ad879059357641 to your computer and use it in GitHub Desktop.
Save emresebat/7ef827ad879059357641 to your computer and use it in GitHub Desktop.
Shell scripts for BaasBox admin/plugin
#!/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"
#!/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