Skip to content

Commit

Permalink
Merge pull request #9 from Heshdude/creating-installer-generator
Browse files Browse the repository at this point in the history
Adding curl as a install method
  • Loading branch information
Heshdude authored Jul 2, 2020
2 parents 4065771 + f134209 commit 5a1226d
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 6 deletions.
4 changes: 3 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import errno

methods = {
"curl": "$CURL",
"apt": "$APT_GET",
"yum": "$YUM",
"dnf": "$DNF",
Expand Down Expand Up @@ -36,6 +37,7 @@ def generate(path):

installer_sh.write("""#!/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
Expand All @@ -47,7 +49,7 @@ def generate(path):
USER="$(id -un 2>/dev/null || true)"
SUDO=''
if [ "$USER" != 'root' ]; then
if $SUDO_CMD; then
if [ ! -z $SUDO_CMD ]; then
SUDO='sudo'
else
cat >&2 <<-'EOF'
Expand Down
5 changes: 2 additions & 3 deletions installers/git/installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/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
Expand All @@ -22,8 +23,6 @@ if [ "$USER" != 'root' ]; then
fi
fi

echo $SUDO

if [ ! -z $APT_GET_CMD ]; then
$SUDO apt-get update
$SUDO apt-get install git
Expand All @@ -43,4 +42,4 @@ elif [ ! -z $APK_CMD ]; then
else
echo "Couldn't install package"
exit 1;
fi
fi
24 changes: 24 additions & 0 deletions installers/hello/installer.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/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

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

if [ ! -z $APT_GET_CMD ]; then
echo "Installing hello"
Expand All @@ -15,6 +31,10 @@ elif [ ! -z $YUM_CMD ]; then
echo "Installing hello"
echo "Installed hello"

elif [ ! -z $PACMAN_CMD ]; then
echo "Installing hello"
echo "Installed hello"

elif [ ! -z $APK_CMD ]; then
echo "Installing hello"
echo "Installed hello"
Expand All @@ -23,6 +43,10 @@ elif [ ! -z $DNF_CMD ]; then
echo "Installing hello"
echo "Installed hello"

elif [ ! -z $CURL_CMD ]; then
echo "Installing hello"
echo "Installed hello"

else
echo "Couldn't install package"
exit 1;
Expand Down
6 changes: 6 additions & 0 deletions installers/hello/installer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ sh = """
echo "Installing hello"
echo "Installed hello"
"""

[curl]
sh = """
echo "Installing hello"
echo "Installed hello"
"""
2 changes: 1 addition & 1 deletion installers/hello/spec/hello_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Describe "Installer script for"
Describe "hello"
It "should say hello!"
When call installers/hello/installer.sh
The output should eq "Hello!"
The output should include "Installed"
End
End
End
18 changes: 17 additions & 1 deletion installers/nginx/installer.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/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

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

if [ ! -z $APT_GET_CMD ]; then
sudo apt-get update
Expand All @@ -15,7 +31,7 @@ elif [ ! -z $YUM_CMD ]; then
sudo yum install nginx

elif [ ! -z $PACMAN_CMD ]; then
sudo pacman -S nginx
$SUDO pacman -S nginx

elif [ ! -z $APK_CMD ]; then
sudo apk update
Expand Down
16 changes: 16 additions & 0 deletions installers/node/installer.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/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

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

if [ ! -z $APT_GET_CMD ]; then
if [ -n "$(uname -a | grep Ubuntu)" ]; then
Expand Down
15 changes: 15 additions & 0 deletions installers/python3/installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/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
Expand All @@ -8,6 +9,20 @@ 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

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

if [ ! -z $APT_GET_CMD ]; then
sudo apt-get update
sudo apt-get install python3
Expand Down

0 comments on commit 5a1226d

Please sign in to comment.