Skip to content

Instantly share code, notes, and snippets.

@matthewflanneryaustralia
Created August 9, 2016 00:47
Show Gist options
  • Save matthewflanneryaustralia/37001f99dddcfa486dc637607a2b3990 to your computer and use it in GitHub Desktop.
Save matthewflanneryaustralia/37001f99dddcfa486dc637607a2b3990 to your computer and use it in GitHub Desktop.
Install NVM via ec2 userdata
cat > /tmp/subscript.sh << EOF
# START UBUNTU USERSPACE
echo "Setting up NodeJS Environment"
curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
echo 'export NVM_DIR="/home/ubuntu/.nvm"' >> /home/ubuntu/.bashrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /home/ubuntu/.bashrc
# Dot source the files to ensure that variables are available within the current shell
. /home/ubuntu/.nvm/nvm.sh
. /home/ubuntu/.profile
. /home/ubuntu/.bashrc
# Install NVM, NPM, Node.JS & Grunt
nvm alias default 4.4.4
nvm install 4.4.4
nvm use 4.4.4
EOF
chown ubuntu:ubuntu /tmp/subscript.sh && chmod a+x /tmp/subscript.sh
sleep 1; su - ubuntu -c "/tmp/subscript.sh"
@aaasp18
Copy link

aaasp18 commented Apr 24, 2018

Love this! Thanks!

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