This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·55 lines (52 loc) · 2.1 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# set some printing colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;36m'
NC='\033[0m'
shell=$(basename $SHELL)
engine="docker"
packagemanager="dnf"
local=false
which podman >/dev/null 2>&1 && engine="podman"
which $engine >/dev/null 2>&1
if [ "$?" != "0" ] ; then
echo -e "${BLUE}No container engine found. Leaving${NC}"
fi
which kcli-openshift4 >/dev/null 2>&1
BIN="$?"
alias kcli-openshift4 >/dev/null 2>&1
ALIAS="$?"
if [ "$BIN" != "0" ] && [ "$ALIAS" != "0" ]; then
echo -e "${BLUE}Installing as alias for $engine${NC}"
$engine pull docker.io/karmab/kcli-openshift4:latest
SSHVOLUME="-v $(realpath $HOME/.ssh):/root/.ssh"
if [ -d /var/lib/libvirt/images ] && [ -d /var/run/libvirt ]; then
echo -e """${BLUE}Make sure you have libvirt access from your user by running:
sudo usermod -aG qemu,libvirt $(id -un)
newgrp qemu
newgrp libvirt${NC}"""
VOLUMES="-v /var/lib/libvirt/images:/var/lib/libvirt/images -v /var/run/libvirt:/var/run/libvirt"
fi
[ -d $HOME/.kcli ] || mkdir -p $HOME/.kcli
[ -d $HOME/.ssh ] || ssh-keygen -t rsa -N '' -f $HOME/.ssh/id_rsa
case $shell in
bash|zsh)
shellfile="$HOME/.bashrc"
[ "$shell" == zsh ] && shellfile="$HOME/.zshrc"
grep -q kcli-openshift4= $shellfile || echo alias kcli-openshift4=\'$engine run --net host -it --rm --security-opt label=disable -v $HOME/.kcli:/root/.kcli $SSHVOLUME $VOLUMES '-v $PWD:/workdir -v /var/tmp:/ignitiondir -v /etc:/etcdir karmab/kcli-openshift4'\' >> $shellfile
;;
fish)
shellfile="$HOME/.config/fish/config.fish"
[ ! -d ~/.config/fish ] && mkdir -p ~/.config/fish
grep -q 'kcli-openshift4 ' $shellfile || echo alias kcli-openshift4 $engine run --net host -it --rm --security-opt label=disable -v $HOME/.kcli:/root/.kcli $SSHVOLUME $VOLUMES '-v $PWD:/workdir -v /var/tmp:/ignitiondir -v /etc:/etcdir karmab/kcli-openshift4' >> $shellfile
;;
*)
echo -e "${RED}Installing aliases for $shell is not supported :(${NC}"
;;
esac
echo -e """${GREEN}Installed kcli-openshift4
Launch a new shell for alias kcli-openshift4 to work${NC}"""
else
echo -e "${BLUE}Skipping already installed kcli-openshift4${NC}"
fi