This commit is contained in:
usmannasir 2024-09-07 14:25:33 +05:00
parent 0010f5c79e
commit 4c6b63dff4
2 changed files with 54 additions and 0 deletions

View File

@ -1040,6 +1040,16 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "openEuler" ]] ; then
dnf install -y gpgme-devel dnf install -y gpgme-devel
Check_Return Check_Return
elif [[ "$Server_OS_Version" = "9" ]] ; then elif [[ "$Server_OS_Version" = "9" ]] ; then
#!/bin/bash
# Check if architecture is aarch64
if uname -m | grep -q 'aarch64' ; then
# Run the following commands if architecture is aarch64
/usr/bin/crb enable
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
fi
dnf install -y libnsl zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel MariaDB-server MariaDB-client MariaDB-devel curl-devel git platform-python-devel tar socat python3 zip unzip bind-utils gpgme-devel dnf install -y libnsl zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel MariaDB-server MariaDB-client MariaDB-devel curl-devel git platform-python-devel tar socat python3 zip unzip bind-utils gpgme-devel
Check_Return Check_Return
elif [[ "$Server_OS_Version" = "20" ]] || [[ "$Server_OS_Version" = "22" ]] ; then elif [[ "$Server_OS_Version" = "20" ]] || [[ "$Server_OS_Version" = "22" ]] ; then

View File

@ -143,6 +143,50 @@ class preFlightsChecks:
self.mysqlport = mysqlport self.mysqlport = mysqlport
self.mysqldb = mysqldb self.mysqldb = mysqldb
@staticmethod
def edit_fstab(mount_point, options_to_add):
# Backup the original fstab file
fstab_path = '/etc/fstab'
backup_path = fstab_path + '.bak'
if not os.path.exists(backup_path):
shutil.copy(fstab_path, backup_path)
preFlightsChecks.stdOut(f"Backup of /etc/fstab created at " + backup_path, 0)
# Read the fstab file
with open(fstab_path, 'r') as file:
lines = file.readlines()
# Modify the appropriate line
modified = False
for i, line in enumerate(lines):
parts = line.split()
# Ensure the line has at least 2 fields and matches the root mount point
if len(parts) > 1 and parts[1] == mount_point:
# Check that the first field is a UUID or a device (not /proc, etc.)
if parts[0].startswith("UUID=") or parts[0].startswith("/dev/"):
# Check if options already exist
if options_to_add in parts[3]:
preFlightsChecks.stdOut(f"{options_to_add} already present in {mount_point} entry", 0)
return
# Append options to the fourth column (mount options)
parts[3] = parts[3] + ',' + options_to_add
lines[i] = ' '.join(parts) + '\n'
modified = True
preFlightsChecks.stdOut(f"Modified the entry for {mount_point}", 0)
break
# If the mount point was found and modified, write back the file
if modified:
with open(fstab_path, 'w') as file:
file.writelines(lines)
preFlightsChecks.stdOut("fstab file updated successfully.", 0)
else:
preFlightsChecks.stdOut(f"No entry found for {mount_point} in /etc/fstab.", 0)
@staticmethod @staticmethod
def stdOut(message, log=0, do_exit=0, code=os.EX_OK): def stdOut(message, log=0, do_exit=0, code=os.EX_OK):
print("\n\n") print("\n\n")