-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
73 lines (63 loc) · 2.95 KB
/
setup.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Function to print error on stderr
echoerr() { echo "$@" 1>&2; }
# Preparing gpu hardware acceleration if requested or skipped
if [[ "$*" == *"--nvidia-gpu"* || "$*" == *"-n"* ]]; then
echo "Installing host package for nvidia gpu..."
if [[ -x "$(command -v apt)" ]]; then
echo "Found Package Manager: apt"
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt update
apt install -y nvidia-docker2
elif [[ -x "$(command -v dnf)" ]]; then
echo "Found Package Manager: dnf"
dnf install nvidia-container-toolkit
elif [[ -x "$(command -v pacman)" ]]; then
if ! [[ -x "$(command -v yay)" ]]; then
echoerr "Yay Package Manager NOT FOUND"
echoerr "For using this script you need to install yay first."
exit 2
fi
echo "Found Package Manager: yay"
yay -Sy nvidia-container-toolkit
else
echoerr "System: not supported by this script"
echoerr 'Try installing "nvidia hardware acceleration" packages by yourself and then run this script without "-n" or "--nvidia-gpu" flag'
echoerr "In this case also consider to edit aliases manually (remove any of -b, --bash, -z and --zsh)."
exit 1
fi
else
echo "Nvidia hardware acceleration: skipped"
fi
# Building Dockerfile
echo "Building image..."
# TODO implement
#docker build -t lori_more/kalishell .
# Preparing aliases for shell config file
if [[ "$*" == *"--nvidia-gpu"* || "$*" == *"-n"* ]]; then
normalAlias='alias openKaliHere="docker run -it --gpus all --rm --net='host' --name tmpKali -v $(pwd):/shared_folder lori_more/kalishell"'
sudoAlias='alias openKaliHereSudo="docker run -it --gpus all --rm --net='host' --name tmpKali --privileged -v $(pwd):/shared_folder lori_more/kalishell"'
else
normalAlias='alias openKaliHere="docker run -it --rm --net='host' --name tmpKali -v $(pwd):/shared_folder kalishell"'
sudoAlias='alias openKaliHereSudo="docker run -it --rm --net='host' --name tmpKali --privileged -v $(pwd):/shared_folder kalishell"'
fi
# Add aliases to shell config file
if [[ "$*" == *"--bash"* || "$*" == *"-b"* ]]; then
echo "Adding aliases to .bashrc..."
echo "# Automatically genereted aliases by OpenKaliHere script" >> ~/.bashrc
echo $normalAlias >> ~/.bashrc
echo $sudoAlias >> ~/.bashrc
elif [[ "$*" == *"--zsh"* || "$*" == *"-z"* ]]; then
echo "Adding aliases to .zshrc..."
echo "# Automatically genereted aliases by OpenKaliHere script" >> ~/.zshrc
echo $normalAlias >> ~/.zshrc
echo $sudoAlias >> ~/.zshrc
else # default case is manual (do nothing)
echo "Setting aliases skipped."
fi
echo "Done, enjoy ethical hacking"
exit 0