HOW TO SETUP HASTEBIN SERVER THAT WORKS WITH CLI
EXAMPLE END RESULT: http://ec2.kossboss.com:7777/mejodeboca - note thats just for show, the final article which you are looking at on this kossboss.com site is the final deal, the ec2.kossboss one is a draft.
OBJECTIVE: run "output-command | hpaste" which then tells me what URL to go to see my output in a nice formated text permenantly
I followed the instructions here: http://aricgardner.com/intranet-pastebin-hasteserver/ All credit goes to that guy. Just incase his link or server is down, I included a copy paste of his article below - I hope thats not breaking any copywrite laws :) after all we are talking about pastebins :} Anyhow all credit goes to the owner of that site.
Back to topic...
I used Method 1 and did some modification, I like I only used the root user.
Before we begin:
Sorry If I make a mistake on path, all of the commands are ran as root either from /root or from /root/scripts, or a couple other locations with in /root.
THE HOW TO BEGINS
First step log in as root, he goes about making a pastebin user and I dont know - now its typically better to follow the recommended way of user per service but I decide to break that rule here - more on that below in the SIDE NOTE section at the end.
Its important to get all the right tools for the job right?
sudo apt-get install build-essential libssl-dev redis-server git-core curl libssl-dev libcurl4-openssl-dev
GET NVM AND RUN IN
git clone git://github.com/creationix/nvm.git ~/nvm
#log out of the server
#log back in (i logged back in as root)
INSTALL LATEST NVM
nvm install 0.6.14
git clone https://github.com/seejohnrun/haste-server.git
I LEFT CONFIG DEFAULT - JUST FYI THATS WHERE YOU SET THE PORT
BUT THATS WHERE YOU WOULD CHANGE THE PORT - MY CONFIG.JS LOOKS LIKE THIS: cat
npm start &
Now the hastebin server is starter, go to your IP:7777 (not https unfortunatly - https instructions are Method 2 on that link above)
LETS MAKE AN INIT SCRIPT THAT WILL START IT OFF DURING BOOT
This is where my script is different. Remember to start an NPM app, first start NVM then start NPM from within the folder where the app is.
First I make the script, into a scripts folder in my ~ aka /root and then put the text into the script via vim, then edit the /etc/rc.local script (which launches during boot) to launch that script we just wrote with the sudo prefix - I tested the rc.local script and trust me without that sudo it doesnt work.
chmod +x hstart
PUT THIS INTO SCRIPT (scripts are red):
nvm use 0.6.14
npm start &
Save and exit with it, then go to rc.local script in etc and before the "exit 0" line add in the following line "sudo /root/scripts/hstart" without quotes of course. (Side note: The sudo I was talking about earlier was the sudo in that previous line.)
What about reboot? Havent made the script yet, but just rebooting doesnt hurt, you will some errors, but it recovers, if you want a legit shutdown, I would just do the reverse of the init script, and find out the npm stop and nvm stop commands.
NOW TO PASTE THINGS
Make this script (and put it in one your directories from $PATH for easier use)
mkdir scripts; cd scripts; touch hpaste; chmod +x hpaste; vim hpaste;
SCRIPT (scripts are red):
key="$(curl --silent --insecure --data-binary @/dev/fd/0 $url/documents | cut -d "\"" -f 4)"
HOW TO USE:
Take a command that has some output to stdout, and redirect it through a pipe into hpaste.
It will output the full link, it autogenerates the last part called the key.
AS AN EXAMPLE HERE IS HOW I DID THE config.js PASTLET:
cat config.js | /root/scripts/hpaste
verbose: added document key=situpajova
So then I would share with everyone http://ec2.kossboss.com:7777/situpajova
And the situpajova is the random key it made up
SIDENOTE: As I was following the instructions I got lost on which user he wanted me to be throughout the commands, so in the very beginning I logged in as root and actually made the pastebin user and gave it a simple password, any how from there on I never logged in as that pastebin user, I wasnt sure If I was supposed to as the instructions were ambigious on that part. I stayed as root and everthing worked out. So if you follow my instructions no need to make pastebin user.
COPY OF SITE - I have an OCD thing about thinking peoples sites might be down one day, so I copy paste the material out, but I still give full credit where its due, in this case its all due to the owner of the site: http://aricgardner.com/intranet-pastebin-hasteserver/ - If this is something bad and you dont want me to include this, let me know my contact information is all over this blog. email@example.com will get to me.
LINUX - Pastebin called hastebin - hosting Haste-server make your own pastebin server with a cli pasteing ability
|Selection||File type icon||File name||Description||Size||Revision||Time||User|