-
Notifications
You must be signed in to change notification settings - Fork 0
/
jungle.sh
executable file
·144 lines (128 loc) · 2.78 KB
/
jungle.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env bash
set -e
set -o pipefail
#
# Created by Jugal Kishore - 2021
#
# Colors
GREEN="\033[1;32m"
NC="\033[0m"
YELLOW="\033[1;33m"
RED="\033[0;31m"
# Variable(s)
export DEBIAN_FRONTEND=noninteractive
if [[ -z "${SKIP_PYTHON}" ]]; then
SKIP_PYTHON=false
fi
if [[ -z "${INSTALL_ALL}" ]]; then
INSTALL_ALL=true
fi
function print() {
if ! [ -t 1 ]; then
echo "${2}"
return 0
fi
case "${1}" in
green)
echo -e "${GREEN}[INFO]${NC} ${2}"
;;
yellow)
echo -e "${YELLOW}[WARN]${NC} ${2}"
;;
red)
echo -e "${RED}[ERROR]${NC} ${2}"
;;
*)
echo "${2}"
;;
esac
}
# Root Check
if [[ "${EUID}" -ne "0" ]]; then
print yellow "Run this script as root!"
print error "Exiting..."
exit 1
else
print green "Script running as root, continuing..."
fi
# Check if user 'jungle' exists
if id -u jungle >/dev/null 2>&1; then
print yellow "User 'jungle' already exists!"
print red "Exiting..."
exit 1
else
print green "User 'jungle' does not exist, continuing..."
fi
# Add sudo if not already present
if [[ -z "$(command -v sudo)" ]]; then
print yellow "sudo not found, installing..."
apt-get update
apt-get install -y sudo
fi
# Random Password
PASSWORD=$(date +%s | sha256sum | base64 | head -c 32)
# Add user 'jungle' to the system
useradd --create-home --shell /usr/bin/bash jungle
usermod -aG sudo jungle
print yello "Using Password: ${PASSWORD}"
echo "jungle:${PASSWORD}" | chpasswd jungle
print yellow "Password for user 'jungle' set!"
echo "jungle ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers
# Check if curl is installed
if [[ -z "$(command -v curl)" ]]; then
print yellow "curl not found, installing..."
apt-get update
apt-get install -y curl 1>/dev/null
fi
# Adding SSH Public Key(s)
sudo -i -u jungle bash <<EOF
mkdir ~/.ssh
curl -sL https://keys.devjugal.com/ssh >> /home/jungle/.ssh/authorized_keys
chmod 600 /home/jungle/.ssh/authorized_keys
EOF
# Installing Python3, and Pip3
if [[ "${SKIP_PYTHON}" == "true" ]] || [[ "${SKIP_PYTHON}" == "True" ]]; then
print yellow "Skipping Python3 Installation..."
else
apt-get update 1>/dev/null
apt-get install -y python3 python3-pip python3-dev python3-setuptools 1>/dev/null
print green "Python3 Installed!"
fi
# Upgrading Package(s)
print yellow "Upgrading package(s)..."
apt-get upgrade -y
# Installing package(s)
if [[ "${INSTALL_ALL}" == "true" ]] || [[ "${INSTALL_ALL}" == "True" ]]; then
print yellow "Installing package(s)..."
apt-get install -y --no-install-recommends \
bc \
ccze \
dnsutils \
git \
gpg \
gpg-agent \
iftop \
iputils-ping \
jq \
libssl-dev \
lolcat \
make \
mtr-tiny \
nano \
neofetch \
net-tools \
nmap \
screen \
tar \
tcpdump \
tmux \
traceroute \
tree \
unzip \
vim \
wget \
xz-utils \
zip
fi
print yellow "User Password: ${PASSWORD}"
print green "Script Finished!"