|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +################################################################################################## |
| 4 | +# hoobs-cli # |
| 5 | +# Copyright (C) 2020 HOOBS # |
| 6 | +# Copyright (C) 2020 NodeSource # |
| 7 | +# # |
| 8 | +# This program is free software: you can redistribute it and/or modify # |
| 9 | +# it under the terms of the GNU General Public License as published by # |
| 10 | +# the Free Software Foundation, either version 3 of the License, or # |
| 11 | +# (at your option) any later version. # |
| 12 | +# # |
| 13 | +# This program is distributed in the hope that it will be useful, # |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
| 16 | +# GNU General Public License for more details. # |
| 17 | +# # |
| 18 | +# You should have received a copy of the GNU General Public License # |
| 19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. # |
| 20 | +################################################################################################## |
| 21 | + |
| 22 | +export DEBIAN_FRONTEND=noninteractive |
| 23 | + |
| 24 | +if test -t 1; then # if terminal |
| 25 | + ncolors=$(which tput > /dev/null && tput colors) # supports color |
| 26 | + |
| 27 | + if test -n "$ncolors" && test $ncolors -ge 8; then |
| 28 | + termcols=$(tput cols) |
| 29 | + bold="$(tput bold)" |
| 30 | + underline="$(tput smul)" |
| 31 | + standout="$(tput smso)" |
| 32 | + normal="$(tput sgr0)" |
| 33 | + black="$(tput setaf 0)" |
| 34 | + red="$(tput setaf 1)" |
| 35 | + green="$(tput setaf 2)" |
| 36 | + yellow="$(tput setaf 3)" |
| 37 | + blue="$(tput setaf 4)" |
| 38 | + magenta="$(tput setaf 5)" |
| 39 | + cyan="$(tput setaf 6)" |
| 40 | + white="$(tput setaf 7)" |
| 41 | + fi |
| 42 | +fi |
| 43 | + |
| 44 | +bail() { |
| 45 | + echo 'Error executing command, exiting' |
| 46 | + exit 1 |
| 47 | +} |
| 48 | + |
| 49 | +exec_cmd_nobail() { |
| 50 | + echo "+ $1" |
| 51 | + bash -c "$1" |
| 52 | +} |
| 53 | + |
| 54 | +exec_cmd() { |
| 55 | + exec_cmd_nobail "$1" || bail |
| 56 | +} |
| 57 | + |
| 58 | +setup() { |
| 59 | + echo "Adding the Node repository" |
| 60 | + |
| 61 | + exec_cmd "wget -qO- https://dl.hoobs.org/deb/key.gpg | apt-key add -" |
| 62 | + exec_cmd "echo 'deb https://dl.hoobs.org/deb/node/ buster main' | tee /etc/apt/sources.list.d/hoobs-node.list" |
| 63 | + |
| 64 | + echo "Adding the Yarn repository" |
| 65 | + |
| 66 | + exec_cmd "wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -" |
| 67 | + exec_cmd "echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list" |
| 68 | + |
| 69 | + echo "Adding the HOOBS repository" |
| 70 | + |
| 71 | + exec_cmd "echo 'deb https://dl.hoobs.org/deb/stable/ buster main' | tee /etc/apt/sources.list.d/hoobs.list" |
| 72 | + |
| 73 | + echo "Updating packages" |
| 74 | + |
| 75 | + exec_cmd 'apt-get update' |
| 76 | + |
| 77 | + echo "Run \"${bold}sudo apt install -y hoobs${normal}\" to install HOOBS, node and yarn" |
| 78 | +} |
| 79 | + |
| 80 | +clean() { |
| 81 | + exec_cmd "rm -f /etc/apt/sources.list.d/hoobs.list" |
| 82 | + exec_cmd "rm -f /etc/apt/sources.list.d/hoobs-node.list" |
| 83 | +} |
| 84 | + |
| 85 | +clean |
| 86 | +setup |
0 commit comments