Skip to content

Commit 696241b

Browse files
chore(install-script): 🔧 amazon-linux improvements and fixes (#900)
Signed-off-by: Prashant Shahi <[email protected]>
1 parent 8a883f1 commit 696241b

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

deploy/install.sh

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ install_docker() {
158158
echo
159159
# yum install docker
160160
# service docker start
161-
$sudo_cmd amazon-linux-extras install docker
161+
$sudo_cmd yum install -y amazon-linux-extras
162+
$sudo_cmd amazon-linux-extras enable docker
163+
$sudo_cmd yum install -y docker
162164
else
163165

164166
yum_cmd="$sudo_cmd yum --assumeyes --quiet"
@@ -195,16 +197,16 @@ install_docker_compose() {
195197

196198
start_docker() {
197199
echo -e "🐳 Starting Docker ...\n"
198-
if [ $os = "Mac" ]; then
200+
if [[ $os == "Mac" ]]; then
199201
open --background -a Docker && while ! docker system info > /dev/null 2>&1; do sleep 1; done
200202
else
201203
if ! $sudo_cmd systemctl is-active docker.service > /dev/null; then
202204
echo "Starting docker service"
203205
$sudo_cmd systemctl start docker.service
204206
fi
205-
if [ -z $sudo_cmd ]; then
207+
if [[ -z $sudo_cmd ]]; then
206208
docker ps > /dev/null && true
207-
if [ $? -ne 0 ]; then
209+
if [[ $? -ne 0 ]]; then
208210
request_sudo
209211
fi
210212
fi
@@ -230,7 +232,7 @@ wait_for_containers_start() {
230232
}
231233

232234
bye() { # Prints a friendly good bye message and exits the script.
233-
if [ "$?" -ne 0 ]; then
235+
if [[ "$?" -ne 0 ]]; then
234236
set +o errexit
235237

236238
echo "🔴 The containers didn't seem to start correctly. Please run the following command to check containers that may have errored out:"
@@ -266,17 +268,17 @@ bye() { # Prints a friendly good bye message and exits the script.
266268

267269
request_sudo() {
268270
if hash sudo 2>/dev/null; then
269-
sudo_cmd="sudo"
270271
echo -e "\n\n🙇 We will need sudo access to complete the installation."
271-
if ! $sudo_cmd -v && (( $EUID != 0 )); then
272-
echo -e "Please enter your sudo password now:"
273-
274-
if ! $sudo_cmd -v; then
272+
if (( $EUID != 0 )); then
273+
sudo_cmd="sudo"
274+
echo -e "Please enter your sudo password, if prompt."
275+
$sudo_cmd -l | grep -e "NOPASSWD: ALL" > /dev/null
276+
if [[ $? -ne 0 ]] && ! $sudo_cmd -v; then
275277
echo "Need sudo privileges to proceed with the installation."
276278
exit 1;
277279
fi
278280

279-
echo -e "Thanks! 🙏\n"
281+
echo -e "Got it! Thanks!! 🙏\n"
280282
echo -e "Okay! We will bring up the SigNoz cluster from here 🚀\n"
281283
fi
282284
fi
@@ -291,9 +293,6 @@ sudo_cmd=""
291293
# Check sudo permissions
292294
if (( $EUID != 0 )); then
293295
echo "🟡 Running installer with non-sudo permissions."
294-
if ! is_command_present docker; then
295-
$sudo_cmd docker ps
296-
fi
297296
echo " In case of any failure or prompt, please consider running the script with sudo privileges."
298297
echo ""
299298
else
@@ -309,7 +308,7 @@ check_os
309308

310309
# Obtain unique installation id
311310
sysinfo="$(uname -a)"
312-
if [ $? -ne 0 ]; then
311+
if [[ $? -ne 0 ]]; then
313312
uuid="$(uuidgen)"
314313
uuid="${uuid:-$(cat /proc/sys/kernel/random/uuid)}"
315314
sysinfo="${uuid:-$(cat /proc/sys/kernel/random/uuid)}"
@@ -324,7 +323,7 @@ elif hash openssl 2>/dev/null; then
324323
digest_cmd="openssl dgst -sha256"
325324
fi
326325

327-
if [ -z $digest_cmd ]; then
326+
if [[ -z $digest_cmd ]]; then
328327
SIGNOZ_INSTALLATION_ID="$sysinfo"
329328
else
330329
SIGNOZ_INSTALLATION_ID=$(echo "$sysinfo" | $digest_cmd | grep -E -o '[a-zA-Z0-9]{64}')
@@ -407,7 +406,7 @@ send_event() {
407406
;;
408407
esac
409408

410-
if [ "$error" != "" ]; then
409+
if [[ "$error" != "" ]]; then
411410
error='"error": "'"$error"'", '
412411
fi
413412

0 commit comments

Comments
 (0)