diff --git a/local/install.sh b/local/install.sh new file mode 100755 index 00000000..4075cb6c --- /dev/null +++ b/local/install.sh @@ -0,0 +1,242 @@ +#!/bin/bash -e +set -e +has() { + type "$1" > /dev/null 2>&1 + return $? +} + +# Redirect stdout ( > ) into a named pipe ( >() ) running "tee" +exec > >(tee /tmp/installlog.txt) + +# Without this, only stdout would be captured - i.e. your +# log file would not contain any error messages. +exec 2>&1 + +NODE_VERSION=v0.10.28 +APPSUPPORT_USER=$HOME/.c9 +SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +RUNTIME=$SCRIPT/.. +INSTALL_DIR=/tmp/c9-`date '+%s'` +ORIGINAL_USER=`basename $HOME` +OSX_INSTALLER_PATH=$2 + +start() { + if [ $# -lt 1 ]; then + start base + return + fi + + # Try to figure out the os and arch for binary fetching + local uname="$(uname -a)" + local os= + local arch="$(uname -m)" + case "$uname" in + Linux\ *) os=linux ;; + Darwin\ *) os=darwin ;; + SunOS\ *) os=sunos ;; + FreeBSD\ *) os=freebsd ;; + esac + case "$uname" in + *x86_64*) arch=x64 ;; + *i*86*) arch=x86 ;; + *armv6l*) arch=arm-pi ;; + esac + + if [ $os != "linux" ] && [ $os != "darwin" ]; then + echo "Unsupported Platform: $os $arch" 1>&2 + exit 1 + fi + + if [ $arch != "x64" ] && [ $arch != "x86" ]; then + echo "Unsupported Architecture: $os $arch" 1>&2 + exit 1 + fi + + if [ $os == "darwin" ]; then + APPSUPPORT_USER="$HOME/Library/Application Support/Cloud9" + APPTARGET=$OSX_INSTALLER_PATH + APPSUPPORT="/Library/Application Support/Cloud9" + RUNTIME="${APPTARGET}/Contents/Resources/app.nw" + fi + + case $1 in + "help" ) + echo + echo "Cloud9 Installer" + echo + echo "Usage:" + echo " install help Show this message" + echo " install install [name [name ...]] Download and install a set of packages" + echo " install ls List available packages" + echo + ;; + + "ls" ) + echo "!node - Node.js" + echo "!tmux_install - TMUX" + echo "!nak - NAK" + echo "!vfsextend - VFS extend" + echo "!ptyjs - pty.js" + echo "!c9cli - C9 CLI" + echo "!sc - Sauce Connect" + echo "coffee - Coffee Script" + echo "less - Less" + echo "sass - Sass" + echo "typescript - TypeScript" + echo "stylus - Stylus" + # echo "go - Go" + # echo "heroku - Heroku" + # echo "rhc - RedHat OpenShift" + # echo "gae - Google AppEngine" + ;; + + "install" ) + shift + + # make sure dirs are around + mkdir -p "$APPSUPPORT/bin" + mkdir -p "$APPSUPPORT/node_modules" + cd "$APPSUPPORT" + + cp -a "$SCRIPT" "$INSTALL_DIR" + + # install packages + while [ $# -ne 0 ] + do + time eval ${1} $os $arch + shift + done + + # finalize + #pushd $APPSUPPORT/node_modules/.bin + #for FILE in $APPSUPPORT/node_modules/.bin/*; do + # if [ `uname` == Darwin ]; then + # sed -i "" -E s:'#!/usr/bin/env node':"#!$NODE":g $(readlink $FILE) + # else + # sed -i -E s:'#!/usr/bin/env node':"#!$NODE":g $(readlink $FILE) + # fi + #done + #popd + + VERSION=`cat $RUNTIME/version || echo 1` + echo 1 > "$APPSUPPORT/installed" + echo $VERSION > "$APPSUPPORT/version" + + # set chown/chmod of application dirs for update + echo "Testing existence of APPTARGET (${APPTARGET})" + if [ -d "$APPTARGET" ]; then + echo "Updating permissions of APPTARGET (${APPTARGET})" + chown -R root:admin "$APPTARGET" || chown -R root:staff "$APPTARGET" + chmod -R 775 "$APPTARGET" + fi + + echo "Testing existence of APPSUPPORT (${APPSUPPORT})" + if [ -d "$APPSUPPORT" ]; then + echo "Updating permissions of APPSUPPORT (${APPSUPPORT})" + chown -R root:admin "$APPSUPPORT" || chown -R root:staff "$APPSUPPORT" + chmod -R 775 "$APPSUPPORT" + fi + + echo "Testing existence of APPSUPPORT_USER (${APPSUPPORT_USER})" + if [ -n "$ORIGINAL_USER" ] && [ -d "$APPSUPPORT_USER" ]; then + echo "Updating permissions of APPSUPPORT_USER (${APPSUPPORT_USER})" + chown -R $ORIGINAL_USER "$APPSUPPORT_USER" + fi + + rm -Rf $INSTALL_DIR + + echo :Done. + ;; + + "base" ) + echo "Installing base packages. Use '`basename $0` help' for more options" + start install node tmux_install nak ptyjs sc vfsextend c9cli + ;; + + * ) + start base + ;; + esac +} + +# NodeJS + +node(){ + # clean up + rm -rf node + rm -rf node-$NODE_VERSION* + + echo :Installing Node $NODE_VERSION + + cd "$INSTALL_DIR" + tar xvfz node-$NODE_VERSION-$1-$2.tar.gz + rm -Rf "$APPSUPPORT/node" + mv node-$NODE_VERSION-$1-$2 "$APPSUPPORT/node" +} + +tmux_install(){ + echo :Installing TMUX + mkdir -p "$APPSUPPORT/bin" + + if [ $os = "darwin" ]; then + cd "$INSTALL_DIR" + python rudix.py -i libevent-2.0.21-0.pkg + python rudix.py -i tmux-1.9-0.pkg + + if ! type "/usr/local/bin/tmux"; then + echo "Installation Failed" + exit 100 + fi + + ln -sf "/usr/local/bin/tmux" "$APPSUPPORT/bin/tmux" + # Linux + else + echo "Unsupported" + fi +} + +vfsextend(){ + echo :Installing VFS extend + cd "$INSTALL_DIR" + tar xvfz c9-vfs-extend.tar.gz + rm -Rf "$APPSUPPORT/c9-vfs-extend" + mv c9-vfs-extend "$APPSUPPORT" +} + +sc(){ + echo :Installing Sauce Connect + cd "$INSTALL_DIR" + tar xvzf sc-4.0-latest.tar.gz + rm -rf "$APPSUPPORT/sc" + mv sc-4.0-latest "$APPSUPPORT/sc" +} + +nak(){ + echo :Installing Nak + cd "$INSTALL_DIR" + tar -zxvf nak.tar.gz + mkdir -p "$APPSUPPORT/node_modules/.bin" + rm -Rf "$APPSUPPORT/node_modules/nak" + mv nak "$APPSUPPORT/node_modules" + ln -s "$APPSUPPORT/node_modules/nak/bin/nak" "$APPSUPPORT/node_modules/.bin/nak" &2> /dev/null +} + +ptyjs(){ + echo :Installing pty.js + cd "$INSTALL_DIR" + tar -zxvf pty-$NODE_VERSION-$1-$2.tar.gz + mkdir -p "$APPSUPPORT/node_modules" + rm -Rf "$APPSUPPORT/node_modules/pty.js" + mv pty.js "$APPSUPPORT/node_modules" +} + +c9cli(){ + if [ -d "/usr/local/bin/" ]; then + chmod +x "$RUNTIME/bin/c9" + ln -s -f "$RUNTIME/bin/c9" /usr/local/bin/c9 + else + echo "unable to add c9cli to the path" + fi +} + +start $@ diff --git a/package.json b/package.json index 96cc49bd..7a893a9e 100644 --- a/package.json +++ b/package.json @@ -49,23 +49,24 @@ }, "licenses": [], "c9plugins": { - "c9.ide.language": "#34de5e56ae", + "c9.ide.language": "#4a23a36945", "c9.ide.language.css": "#afda1f867c", "c9.ide.language.generic": "#87a4a44671", "c9.ide.language.html": "#fa4833e117", "c9.ide.language.html.diff": "#a7311cfc9f", - "c9.ide.language.javascript": "#26cf518b28", + "c9.ide.language.javascript": "#8479d0a9c1", "c9.ide.language.javascript.immediate": "#9a2cce9121", - "c9.ide.language.javascript.eslint": "#1baacc275b", - "c9.ide.language.javascript.tern": "#a65ad88dd9", + "c9.ide.language.javascript.eslint": "#8832423ad1", + "c9.ide.language.javascript.tern": "#7aab8b0b6a", "c9.ide.language.javascript.infer": "#ebb2daf81a", - "c9.ide.language.jsonalyzer": "#c5dfe5fb7e", - "c9.ide.collab": "#e2a500a964", + "c9.ide.language.jsonalyzer": "#a1057f20db", + "c9.ide.collab": "#7b09419b5c", "c9.ide.local": "#2bfd7ff051", "c9.ide.find": "#989c06e6a7", "c9.ide.find.infiles": "#f98dfef554", "c9.ide.find.replace": "#e4daf722b8", - "c9.ide.run.debug": "#a3e0f7b134", + "c9.ide.run.debug": "#6b7ab83781", + "c9.automate": "#86bf1ee1ca", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#6c4bb65b1f", @@ -73,32 +74,33 @@ "c9.ide.ace.split": "#0ae0151c78", "c9.ide.ace.statusbar": "#d7b45bb7c3", "c9.ide.ace.stripws": "#34426a03d1", - "c9.ide.behaviors": "#3dbcad4203", + "c9.ide.behaviors": "#6aad7006a0", "c9.ide.closeconfirmation": "#a28bfd8272", "c9.ide.configuration": "#b8470f4107", "c9.ide.dialog.wizard": "#a588b64050", "c9.ide.fontawesome": "#781602c5d8", - "c9.ide.format": "#1ae38e60e6", + "c9.ide.format": "#f51451ac57", "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#e9ba147cc2", "c9.ide.installer": "#24e7d6f399", "c9.ide.mount": "#32e79866ee", - "c9.ide.navigate": "#eab638cc2f", + "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#9a7464cc47", "c9.ide.openfiles": "#28a4f5af16", - "c9.ide.preview": "#3c4dded23f", - "c9.ide.preview.browser": "#be197b0464", - "c9.ide.preview.markdown": "#bf952685f6", + "c9.ide.preview": "#dba2f4214d", + "c9.ide.preview.browser": "#ac18aaf31d", + "c9.ide.preview.markdown": "#ab8d30ad9f", "c9.ide.pubsub": "#92ec19ed3a", "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", - "c9.ide.remote": "#37773d905b", - "c9.ide.run": "#f5a056e6ce", + "c9.ide.remote": "#cd45e81d2f", + "c9.ide.run": "#e510a39b4b", "c9.ide.run.build": "#6726030127", + "c9.ide.run.debug.xdebug": "#b91d23f48b", "c9.ide.save": "#a32a8f4346", - "c9.ide.terminal.monitor": "#df9936daa2", - "c9.ide.theme.flat": "#5c7c27ab74", + "c9.ide.terminal.monitor": "#b0b4d03280", + "c9.ide.theme.flat": "#b1d65fa9bb", "c9.ide.threewaymerge": "#229382aa0b", "c9.ide.undo": "#b028bcb4d5", "c9.ide.upload": "#0bd010d3dc",