Skip to content

Commit

Permalink
local
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Sep 7, 2024
1 parent 0010f5c commit 4c6b63d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cyberpanel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,16 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "openEuler" ]] ; then
dnf install -y gpgme-devel
Check_Return
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
Check_Return
elif [[ "$Server_OS_Version" = "20" ]] || [[ "$Server_OS_Version" = "22" ]] ; then
Expand Down
44 changes: 44 additions & 0 deletions install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,50 @@ def __init__(self, rootPath, ip, path, cwd, cyberPanelPath, distro, remotemysql=
self.mysqlport = mysqlport
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
def stdOut(message, log=0, do_exit=0, code=os.EX_OK):
print("\n\n")
Expand Down

0 comments on commit 4c6b63d

Please sign in to comment.