-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11-functions.sh
More file actions
43 lines (35 loc) · 865 Bytes
/
11-functions.sh
File metadata and controls
43 lines (35 loc) · 865 Bytes
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
#!/bin/bash
# the task is to check the packages are installed or not. if not then install
# with implementing functions.
#1. checking for the root user privilges.
VALIDATE() {
if [ $1 -ne 0 ]
then
echo "$2 package installation failed"
else
echo "successfully installed"
fi
}
user_id=$(id -u)
if [ $user_id -ne 0 ] #if not zero then warn user to connect with root priviliges and exit the script.
then
echo "please connect with root user access"
exit 1
fi
dnf list installed mysql
if [ $? -ne 0 ]
then
echo "package is not installed"
VALIDATE $? "mysql"
else
echo "mysql is already installed skipping this"
fi
dnf list installed ansible
if [ $? -ne 0 ]
then
echo "package is not installed"
dnf install ansible
VALIDATE $? "ansible"
else
echo "ansible is already installed skipping this"
fi