Skip to content

Instantly share code, notes, and snippets.

@amitkhare
Created February 24, 2021 05:24
Show Gist options
  • Save amitkhare/cedbf1fdf48cdbc67dc8a92c22819abd to your computer and use it in GitHub Desktop.
Save amitkhare/cedbf1fdf48cdbc67dc8a92c22819abd to your computer and use it in GitHub Desktop.
updated cloud9 code start script
#!/bin/bash
dirbase="/var/www/"
# cd $dirbase
read -p "Current Directory as base? (y/N) " isCurrDir
if [ "$isCurrDir" = "Y" ] || [ "$isCurrDir" = "y" ]; then
dirpath=$(pwd)
echo "Base Directory is: " $dirpath
echo ""
else
read -p "Enter project path: $dirbase" ddir
ddir=${ddir:-''}
dirpath=$dirbase$ddir
fi
read -p "Enter Port (default:2082):" pport
pport=${pport:-2082}
if [ ! -e $dirpath ]; then
mkdir $dirpath
elif [ ! -d $dirpath ]; then
echo "$dirpath already exists but is not a directory"
exit
fi
cd $dirpath
echo "Your Project will run on port: $pport"
forever stopall
forever start ~/c9sdk/server.js -w "$dirpath" -p $pport -l 0.0.0.0 -a user:password
clear
echo "Your C9 project '$dirpath' is running on port $pport."
@amitkhare
Copy link
Author

Change username:password in end of line 24

To make this executable:

Add a "shebang" at the top of your file:
#!/bin/bash

And make your file executable (chmod +x script.sh)

Finally, modify your path to add the directory where your script is located:
export PATH=$PATH:/appropriate/directory

(typically, you want $HOME/bin for storing your own scripts)

then run it with
. c9start.sh or soruce c9start.sh
to change directory itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment