Skip to content

Commit 8dff99d

Browse files
authored
Merge pull request #25 from Heshdude/update-readme-md-and-installers-toml
Update installer scrits, README.md & installers.toml
2 parents 24f424d + b5c4d2a commit 8dff99d

File tree

4 files changed

+69
-31
lines changed

4 files changed

+69
-31
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This will install Git on your machine!
2323
| Tool |Apt|Yum|Packman|APK|DNF|CURL| URL |
2424
|--------|---|---|-------|---|---|----|----------------------------|
2525
|NodeJS |Yes|Yes|No |Yes|Yes|No |https://installer.to/node |
26+
|Kubectl |Yes|Yes|No |No |No |No |https://installer.to/kubectl|
2627
|Git |Yes|Yes|Yes |Yes|Yes|No |https://installer.to/git |
2728
|gCloud |No |No |No |No |No |Yes |https://installer.to/gcloud |
2829
|Nginx |Yes|Yes|Yes |Yes|Yes|No |https://installer.to/nginx |

installers.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
installers = "apt,yum,dnf,apk"
33
name = "NodeJS"
44

5+
[kubectl]
6+
installers = "yum,apt"
7+
name = "Kubectl"
8+
description = "kubectl controls the Kubernetes cluster manager"
9+
510
[git]
611
installers = "apt,yum,pacman,dnf,apk"
712
name = "Git"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
;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 $YUM_CMD ]; then;cat <<EOF > /etc/yum.repos.d/kubernetes.repo;[kubernetes];name=Kubernetes;baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64;enabled=1;gpgcheck=1;repo_gpgcheck=1;gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg;EOF;yum install -y kubectl;;elif [ ! -z $APT_GET_CMD ]; then;$SUDO apt-get update && $SUDO apt-get install -y apt-transport-https gnupg2;curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | $SUDO apt-key add -;echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | $SUDO tee -a /etc/apt/sources.list.d/kubernetes.list;$SUDO apt-get update;$SUDO apt-get install kubectl;;else echo "Couldn't install package";exit 1;;fi;

installers/kubectl/installer.sh

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,65 @@
11
#!/bin/sh
2+
3+
CURL_CMD=$(which curl)
4+
YUM_CMD=$(which yum)
5+
DNF_CMD=$(which dnf)
6+
APT_GET_CMD=$(which apt-get)
7+
PACMAN_CMD=$(which pacman)
8+
APK_CMD=$(which apk)
9+
GIT_CMD=$(which git)
10+
SUDO_CMD=$(which sudo)
211

3-
YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS
4-
DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS
5-
APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions
6-
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
7-
APK_CMD=$(which apk) # apk package manager for Alpine
12+
USER="$(id -un 2>/dev/null || true)"
13+
SUDO=''
14+
if [ "$USER" != 'root' ]; then
15+
if [ ! -z $SUDO_CMD ]; then
16+
SUDO='sudo'
17+
else
18+
cat >&2 <<-'EOF'
19+
Error: this installer needs the ability to run commands as root.
20+
We are unable to find "sudo". Make sure its available to make this happen
21+
EOF
22+
exit 1
23+
fi
24+
fi
825

9-
if [ ! -z $APT_GET_CMD ]; then
10-
sudo apt-get update && sudo apt-get install -y apt-transport-https
11-
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
12-
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
13-
sudo apt-get update
14-
sudo apt-get install -y kubectl
15-
elif [ ! -z $YUM_CMD ]; then
16-
sudo cat <<EOF > /etc/yum.repos.d/kubernetes.repo
17-
[kubernetes]
18-
name=Kubernetes
19-
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
20-
enabled=1
21-
gpgcheck=1
22-
repo_gpgcheck=1
23-
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
24-
EOF
25-
sudo yum install -y kubectl
26-
elif [ ! -z $APK_CMD ]; then
27-
sudo apk add --no-cache curl ca-certificates && sudo apk add --update -t deps curl
28-
curl -L https://storage.googleapis.com/kubernetes-release/release/v1.13.3/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
29-
chmod +x /usr/local/bin/kubectl
30-
else
31-
echo "Couldn't install package"
32-
exit 1;
33-
fi
26+
RESET=''
27+
RED=''
28+
GREEN=''
29+
YELLOW=''
30+
log () {
31+
echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2"
32+
}
33+
info () {
34+
log "$GREEN INFO$RESET $1"
35+
}
36+
warn () {
37+
log "$YELLOW WARN$RESET $1"
38+
}
39+
error () {
40+
log "$RED ERROR$RESET $1"
41+
}
3442

35-
kubectl version
43+
if [ ! -z $YUM_CMD ]; then
44+
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
45+
[kubernetes]
46+
name=Kubernetes
47+
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
48+
enabled=1
49+
gpgcheck=1
50+
repo_gpgcheck=1
51+
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
52+
EOF
53+
yum install -y kubectl
54+
55+
elif [ ! -z $APT_GET_CMD ]; then
56+
$SUDO apt-get update && $SUDO apt-get install -y apt-transport-https gnupg2
57+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | $SUDO apt-key add -
58+
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | $SUDO tee -a /etc/apt/sources.list.d/kubernetes.list
59+
$SUDO apt-get update
60+
$SUDO apt-get install kubectl
61+
62+
else
63+
echo "Couldn't install package"
64+
exit 1;
65+
fi

0 commit comments

Comments
 (0)