Browse Source

centos install fixes

pull/21/head
pb 6 days ago
parent
commit
04165e828e
4 changed files with 205 additions and 1 deletions
  1. 50
    0
      i.mysql.centos.sh
  2. 16
    1
      index.js
  3. 69
    0
      loopback.linkmodels.sh
  4. 70
    0
      r.mysql.centos.sh

+ 50
- 0
i.mysql.centos.sh View File

@@ -0,0 +1,50 @@
#!/bin/bash

# Update the system
echo "Updating the system..."
sudo yum update -y

# Install the MySQL repository
echo "Installing MySQL repository..."
sudo yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

# Enable the MySQL repository
echo "Enabling MySQL repository..."
sudo yum-config-manager --enable mysql80-community

# Install MySQL server
echo "Installing MySQL server..."
sudo yum install -y mysql-server

# Start MySQL service
echo "Starting MySQL service..."
sudo systemctl start mysqld

# Enable MySQL to start on boot
echo "Enabling MySQL to start on boot..."
sudo systemctl enable mysqld

# Get the temporary MySQL root password
TEMP_PASS=$(sudo grep 'temporary password' /var/log/mysqld.log | tail -n 1 | awk '{print $NF}')
echo "Temporary MySQL root password: $TEMP_PASS"

# Secure MySQL installation (you can modify the commands for automation if desired)
echo "Securing MySQL installation..."
sudo mysql_secure_installation <<EOF

y
$TEMP_PASS
newpassword
newpassword
y
y
y
y
EOF

# Output MySQL status
echo "MySQL installation completed successfully."

# You can log into MySQL by running:
echo "You can log into MySQL with: mysql -u root -p"


+ 16
- 1
index.js View File

@@ -5004,6 +5004,7 @@ shell_verse.acquireElevationState().then((isElevated) => {

var os = require("os");
var hostname = os.hostname();
var commoninstanceonly = true;
var clustername = null; // PB : TODO -- Prompt to acquire.
var configs = (function(){
// We need to discover and use the most specialized config available.
@@ -5064,6 +5065,12 @@ shell_verse.acquireElevationState().then((isElevated) => {
}
})()


if(commoninstanceonly) {
// configs.splice(0,2)
delete configs.ownerClusterNodeConfig
delete configs.ownerInstnace
}
var eNotImplemented = function(){
console.error('Not yet implemented')
process.exit()
@@ -5072,6 +5079,7 @@ shell_verse.acquireElevationState().then((isElevated) => {
// PB : TODO -- accept additional arg - an array specifying custom configPriority.
var acquireConfig = function(slections){
var configPriority = [ 'ownerClusterNodeConfig', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ]
if(commoninstanceonly) { configPriority = [ 'commonInstance' ] }
return any(configPriority.map(cfg => { return function() { return configs[cfg](slections) } } ), true, true).then(()=>{
return acquireData(slections)
})
@@ -5104,9 +5112,16 @@ shell_verse.acquireElevationState().then((isElevated) => {
, genericChessInstance(selected) { return __acquireData(selected, { owner : defaultowner }) }
}
})()

if(commoninstanceonly) {
// configs.splice(0,2)
delete configs.ownerClusterNodeData
delete configs.ownerInstnace
delete configs.genericChessInstance
}
var acquireData = function(slections){
var configPriority = [ 'ownerClusterNodeData', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ]
if(commoninstanceonly) { configPriority = [ 'commonInstance' ] }
return any(configPriority.map(cfg => { return function() { return instanceData[cfg](slections) } } ), true, true)
}


+ 69
- 0
loopback.linkmodels.sh View File

@@ -0,0 +1,69 @@
#!/bin/bash

# Function to create symbolic links and copy .js files
manage_files() {
# Define the source (folder a) and destination (folder b)
folder_a="$1"
folder_b="$2"

# Ensure both folders exist
if [[ ! -d "$folder_a" ]]; then
echo "Source folder '$folder_a' does not exist!"
return 1
fi

if [[ ! -d "$folder_b" ]]; then
echo "Destination folder '$folder_b' does not exist!"
return 1
fi

# Get the absolute paths of the source and destination folders
abs_folder_a=$(realpath "$folder_a")
abs_folder_b=$(realpath "$folder_b")

# 1. Create symbolic links for files in folder_a to folder_b with absolute paths
for file in "$abs_folder_a"/*; do
# Check if it's a regular file
if [[ -f "$file" ]]; then
filename=$(basename "$file")
destination="$abs_folder_b/$filename"

# Check if the file already exists in folder_b
if [[ ! -e "$destination" ]]; then
# Create a symbolic link in folder_b with absolute paths
ln -s "$file" "$destination"
echo "Linked '$file' to '$destination'"
else
echo "File '$destination' already exists, skipping..."
fi
fi
done

# 2. Remove all symbolic links to .js files in folder_b
find "$abs_folder_b" -type l -name "*.js" -exec rm {} \;
echo "All symbolic links to .js files have been removed."

# 3. Copy missing .js files from folder_a to folder_b
for file in "$abs_folder_a"/*.js; do
# Ensure it is a regular file
if [[ -f "$file" ]]; then
filename=$(basename "$file")
destination="$abs_folder_b/$filename"

# Check if the file already exists in folder_b
if [[ ! -e "$destination" ]]; then
# Copy the .js file from folder_a to folder_b
cp "$file" "$destination"
echo "Copied '$file' to '$destination'"
else
echo "File '$destination' already exists, skipping..."
fi
fi
done
}

# Example of calling the function on multiple folder pairs

manage_files "./chess-server-lib/common/models" "./cihsr-server/cihsr/models"
manage_files "./chess-server-lib/common/lib/vmodel" "./cihsr-server/cihsr/lib/vmodel"


+ 70
- 0
r.mysql.centos.sh View File

@@ -0,0 +1,70 @@
#!/bin/bash

# Set variables
MYSQL_BACKUP_DIR="/tmp/mysql_backup"
MYSQL_BACKUP_FILE="all_databases_backup.sql"

# Stop MySQL service
echo "Stopping MySQL service..."
sudo systemctl stop mysqld

# Backup all MySQL databases
echo "Backing up all databases..."
mkdir -p $MYSQL_BACKUP_DIR
sudo mysqldump -u root -p --all-databases > $MYSQL_BACKUP_DIR/$MYSQL_BACKUP_FILE

# Remove MySQL and related packages
echo "Removing MySQL and related packages..."
sudo yum remove -y mysql-server mysql mysql-libs

# Remove MySQL data and configuration files (This deletes your MySQL data, use with caution)
echo "Removing MySQL data and configuration files..."
sudo rm -rf /var/lib/mysql
sudo rm -f /etc/my.cnf
sudo rm -rf /etc/mysql
sudo rm -f /var/log/mysqld.log

# Install MySQL repository
echo "Installing MySQL repository..."
sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm -O /tmp/mysql80-community-release-el7-3.noarch.rpm
sudo rpm -ivh /tmp/mysql80-community-release-el7-3.noarch.rpm

# Install MySQL server
echo "Installing MySQL server..."
sudo yum install -y mysql-server

# Start MySQL service
echo "Starting MySQL service..."
sudo systemctl start mysqld

# Enable MySQL to start on boot
echo "Enabling MySQL to start on boot..."
sudo systemctl enable mysqld

# Get the temporary MySQL root password
MYSQL_TEMP_PASSWORD=$(sudo grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}')

# Secure MySQL installation
echo "Securing MySQL installation..."
sudo mysql_secure_installation <<EOF

$MYSQL_TEMP_PASSWORD
y
new_password_here
new_password_here
y
y
y
y
EOF

# Verify MySQL service status
echo "Verifying MySQL service status..."
sudo systemctl status mysqld

# Restore backup (optional, you may skip this if you want to start fresh)
echo "Restoring MySQL data..."
mysql -u root -p < $MYSQL_BACKUP_DIR/$MYSQL_BACKUP_FILE

echo "MySQL reinstallation complete!"


Loading…
Cancel
Save