├── LICENSE ├── README.md └── node-install.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Tim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NodeJS Linux Installer 2 | This is an universal NodeJS installer for Linux. 3 | I don't take any responsibilities if you blow your system up! 4 | 5 | ### Installing 6 | ``` 7 | curl https://raw.githubusercontent.com/taaem/nodejs-linux-installer/master/node-install.sh 2>/dev/null | sh 8 | ``` 9 | ### Contributing 10 | Just create a fork and please contribute all your improvements back here! 11 | 12 | ### License 13 | MIT 14 | 15 | Thanks for all Contributions 16 | -------------------------------------------------------------------------------- /node-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Node Linux Installer by www.github.com/taaem" 4 | if [[ $EUID -ne 0 ]]; then 5 | echo "Need Root for installing NodeJS" 6 | sudo sh -c 'echo "Got Root!"' 7 | else 8 | echo "Running as Root User" 9 | fi 10 | 11 | echo "Get Latest Version Number..." 12 | 13 | node_latest=$(curl http://nodejs.org/dist/latest/ 2>/dev/null) 14 | if [[ ! $node_latest ]] 15 | then 16 | echo "ERROR: No Internet Connection" >&2 17 | exit 1 18 | fi 19 | 20 | ARCH=$(uname -m) 21 | 22 | if [ $ARCH = arm64 ] || [ $ARCH = aarch64 ] 23 | then 24 | NAME=$(echo "$node_latest" | grep -o '>node-v.*-linux-arm64.tar.gz' ) 25 | VER=$(echo "$NAME" | grep -o 'node-v.*-linux-arm64.tar.gz') 26 | 27 | elif [ $ARCH = armv6l ] 28 | then 29 | NAME=$(echo "$node_latest" | grep -o '>node-v.*-linux-armv6l.tar.gz' ) 30 | VER=$(echo "$NAME" | grep -o 'node-v.*-linux-armv6l.tar.gz') 31 | 32 | elif [ $ARCH = armv7l ] 33 | then 34 | NAME=$(echo "$node_latest" | grep -o '>node-v.*-linux-armv7l.tar.gz' ) 35 | VER=$(echo "$NAME" | grep -o 'node-v.*-linux-armv7l.tar.gz') 36 | 37 | elif [ $ARCH = x86_64 ] 38 | then 39 | NAME=$(echo "$node_latest" | grep -o '>node-v.*-linux-x64.tar.gz' ) 40 | VER=$(echo "$NAME" | grep -o 'node-v.*-linux-x64.tar.gz') 41 | 42 | else 43 | NAME=$(echo "$node_latest" | grep -o '>node-v.*-linux-x86.tar.gz' ) 44 | VER=$(echo "$NAME" | grep -o 'node-v.*-linux-x86.tar.gz') 45 | fi 46 | 47 | echo "Done" 48 | 49 | echo "Downloading latest stable Version $VER..." 50 | 51 | URL=http://nodejs.org/dist/latest/$VER 52 | FILE_PATH=/tmp/node.tar.gz 53 | 54 | curl -o $FILE_PATH $URL 2>/dev/null 55 | exit_status=$(echo "$?") 56 | if [[ $exit_status -ne "0" ]] 57 | then 58 | echo "ERROR: Target tar not found" 59 | exit $exit_status 60 | fi 61 | 62 | echo "Done" 63 | 64 | echo "Installing..." 65 | cd /usr/local && sudo tar --strip-components 1 -xzf /tmp/node.tar.gz 66 | exit_status=$(echo "$?") 67 | if [[ $exit_status -ne "0" ]] 68 | then 69 | echo "ERROR: Couldn't extract tar" 70 | exit $exit_status 71 | fi 72 | 73 | rm $FILE_PATH 74 | 75 | echo "Finished installing!" 76 | exit 0 77 | --------------------------------------------------------------------------------