From a0cfd9da447811d8faa762df440ab903c873d95b Mon Sep 17 00:00:00 2001 From: Heshdude Date: Sun, 26 Jul 2020 21:39:02 +0530 Subject: [PATCH 1/4] Adding GCloud CLI --- installers/gcloud/installer.sh | 49 ++++++++++++++++++++++++++++++++ installers/gcloud/installer.toml | 8 ++++++ 2 files changed, 57 insertions(+) create mode 100755 installers/gcloud/installer.sh create mode 100644 installers/gcloud/installer.toml diff --git a/installers/gcloud/installer.sh b/installers/gcloud/installer.sh new file mode 100755 index 0000000..ffb4f93 --- /dev/null +++ b/installers/gcloud/installer.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +CURL_CMD=$(which curl) +YUM_CMD=$(which yum) +DNF_CMD=$(which dnf) +APT_GET_CMD=$(which apt-get) +PACMAN_CMD=$(which pacman) +APK_CMD=$(which apk) +GIT_CMD=$(which git) +SUDO_CMD=$(which sudo) + +USER="$(id -un 2>/dev/null || true)" +SUDO='' +if [ "$USER" != 'root' ]; then + if [ ! -z $SUDO_CMD ]; then + SUDO='sudo' + else + cat >&2 <<-'EOF' + Error: this installer needs the ability to run commands as root. + We are unable to find "sudo". Make sure its available to make this happen + EOF + exit 1 + fi +fi + +RESET='' +RED='' +GREEN='' +YELLOW='' +log () { + echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2" +} +info () { + log "$GREEN INFO$RESET $1" +} +warn () { + log "$YELLOW WARN$RESET $1" +} +error () { + log "$RED ERROR$RESET $1" +} + +if [ ! -z $CURL_CMD ]; then + curl https://sdk.cloud.google.com | bash + +else + echo "Couldn't install package" + exit 1; +fi \ No newline at end of file diff --git a/installers/gcloud/installer.toml b/installers/gcloud/installer.toml new file mode 100644 index 0000000..eab69fc --- /dev/null +++ b/installers/gcloud/installer.toml @@ -0,0 +1,8 @@ +name = "gCloud" +shortname = "gcloud" +description = "CLI tool of GCP" + +[curl] +sh = """ +curl https://sdk.cloud.google.com | bash +""" From ed720278c456994bb44c71efc59af7f0ff4ea26c Mon Sep 17 00:00:00 2001 From: Heshdude Date: Sun, 26 Jul 2020 21:47:23 +0530 Subject: [PATCH 2/4] Improving hfl installer --- README.md | 2 +- installers.toml | 2 +- installers/hlf/installer.sh | 72 ++++++++++++++++++++++------------- installers/hlf/installer.toml | 33 +++++++--------- 4 files changed, 61 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 0d1b0b1..b6acd7b 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,6 @@ This will install Git on your machine! |Nginx |Yes|Yes|Yes |Yes|Yes|No |https://installer.to/nginx | |gCloud |No |No |No |No |No |Yes |https://installer.to/gcloud | |Docker |Yes|Yes|No |No |No |No |https://installer.to/docker | -|Fabric |Yes|Yes|Yes |Yes|Yes|No |https://installer.to/hlf | +|Fabric |No |No |No |No |No |Yes |https://installer.to/hlf | diff --git a/installers.toml b/installers.toml index 7f58d95..4cce609 100644 --- a/installers.toml +++ b/installers.toml @@ -35,4 +35,4 @@ installers = "apt,yum" [hlf] name = "Fabric" description = "Hyperledger Fabric" -installers = "apt,yum,pacman,dnf,apk" +installers = "curl" diff --git a/installers/hlf/installer.sh b/installers/hlf/installer.sh index 146a451..8ea4d99 100644 --- a/installers/hlf/installer.sh +++ b/installers/hlf/installer.sh @@ -1,13 +1,13 @@ #!/bin/sh - -CURL_CMD=$(which curl) # curl tool -YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS -DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS -APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions -PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux -APK_CMD=$(which apk) # apk package manager for Alpine -GIT_CMD=$(which git) # to build from source pulling from git -SUDO_CMD=$(which sudo) # check if sudo command is there + +CURL_CMD=$(which curl) +YUM_CMD=$(which yum) +DNF_CMD=$(which dnf) +APT_GET_CMD=$(which apt-get) +PACMAN_CMD=$(which pacman) +APK_CMD=$(which apk) +GIT_CMD=$(which git) +SUDO_CMD=$(which sudo) USER="$(id -un 2>/dev/null || true)" SUDO='' @@ -23,21 +23,41 @@ if [ "$USER" != 'root' ]; then fi fi - -if ! command -v docker -then - echo "docker could not be found" - curl https://installer.to/docker | bash +RESET='' +RED='' +GREEN='' +YELLOW='' +log () { + echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2" +} +info () { + log "$GREEN INFO$RESET $1" +} +warn () { + log "$YELLOW WARN$RESET $1" +} +error () { + log "$RED ERROR$RESET $1" +} + +if [ ! -z $CURL_CMD ]; then + if ! command -v docker + then + warn "docker could not be found" + curl https://installer.to/docker | bash + else + info "docker found" + fi + + info "downloading Fabric........" + curl -sSL http://bit.ly/2ysbOFE -o bootstrap.sh + chmod 755 ./bootstrap.sh + $SUDO bash ./bootstrap.sh + + $SUDO cp ./fabric-samples/bin/* /usr/local/bin + + else - echo "docker found" -fi - - -echo "downloading Fabric........" -curl -sSL http://bit.ly/2ysbOFE -o bootstrap.sh -chmod 755 ./bootstrap.sh -$SUDO bash ./bootstrap.sh - -# Copying binaries -$SUDO cp ./fabric-samples/bin/* /usr/local/bin - + echo "Couldn't install package" + exit 1; +fi \ No newline at end of file diff --git a/installers/hlf/installer.toml b/installers/hlf/installer.toml index fd508b9..badb1fb 100644 --- a/installers/hlf/installer.toml +++ b/installers/hlf/installer.toml @@ -3,28 +3,21 @@ shortname = "hlf" description = "Hyperledger Fabric" -[apt] +[curl] sh = """ -@sudo apt-get update -@sudo apt-get install git -""" +if ! command -v docker +then + @warn "docker could not be found" + curl https://installer.to/docker | bash +else + @info "docker found" +fi -[yum] -sh = """ -@sudo yum install git -""" +@info "downloading Fabric........" +curl -sSL http://bit.ly/2ysbOFE -o bootstrap.sh +chmod 755 ./bootstrap.sh +@sudo bash ./bootstrap.sh -[pacman] -sh = """ -pacman -Sy git -""" +@sudo cp ./fabric-samples/bin/* /usr/local/bin -[dnf] -sh = """ -@sudo dnf install git -""" - -[apk] -sh = """ -@sudo apk add git """ From 88eb326f4ef6b69bd7f2f23d9d8eb73b42320127 Mon Sep 17 00:00:00 2001 From: Heshdude Date: Sun, 26 Jul 2020 21:49:25 +0530 Subject: [PATCH 3/4] Fixing issue --- generate.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/generate.py b/generate.py index dd68c22..c302405 100644 --- a/generate.py +++ b/generate.py @@ -3,12 +3,9 @@ import os import logging import errno -import constants import pytablewriter import re -print (constants.CURL_CHECK) - methods = { "curl": "$CURL", "apt": "$APT_GET", From 7dfd004c3dcc2d4eb28be5a3de237395cfe70ffe Mon Sep 17 00:00:00 2001 From: Heshdude Date: Sun, 26 Jul 2020 21:53:02 +0530 Subject: [PATCH 4/4] Adding pytablewriter to the pip install --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 2593110..caf4358 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -19,4 +19,4 @@ jobs: - uses: actions/checkout@v2 - uses: technote-space/get-diff-action@v1 - name: Get the list of modified files only - run: pip install toml && python generate.py ${{ env.GIT_DIFF }} && docker build -t shellspec . && docker run -v $PWD:/app shellspec bash -c "cd /app && ./test.sh ${{ env.GIT_DIFF }}" + run: pip install toml pytablewriter && python generate.py ${{ env.GIT_DIFF }} && docker build -t shellspec . && docker run -v $PWD:/app shellspec bash -c "cd /app && ./test.sh ${{ env.GIT_DIFF }}"