#!/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" | |||||
var os = require("os"); | var os = require("os"); | ||||
var hostname = os.hostname(); | var hostname = os.hostname(); | ||||
var commoninstanceonly = true; | |||||
var clustername = null; // PB : TODO -- Prompt to acquire. | var clustername = null; // PB : TODO -- Prompt to acquire. | ||||
var configs = (function(){ | var configs = (function(){ | ||||
// We need to discover and use the most specialized config available. | // We need to discover and use the most specialized config available. | ||||
} | } | ||||
})() | })() | ||||
if(commoninstanceonly) { | |||||
// configs.splice(0,2) | |||||
delete configs.ownerClusterNodeConfig | |||||
delete configs.ownerInstnace | |||||
} | |||||
var eNotImplemented = function(){ | var eNotImplemented = function(){ | ||||
console.error('Not yet implemented') | console.error('Not yet implemented') | ||||
process.exit() | process.exit() | ||||
// PB : TODO -- accept additional arg - an array specifying custom configPriority. | // PB : TODO -- accept additional arg - an array specifying custom configPriority. | ||||
var acquireConfig = function(slections){ | var acquireConfig = function(slections){ | ||||
var configPriority = [ 'ownerClusterNodeConfig', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] | 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 any(configPriority.map(cfg => { return function() { return configs[cfg](slections) } } ), true, true).then(()=>{ | ||||
return acquireData(slections) | return acquireData(slections) | ||||
}) | }) | ||||
, genericChessInstance(selected) { return __acquireData(selected, { owner : defaultowner }) } | , 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 acquireData = function(slections){ | ||||
var configPriority = [ 'ownerClusterNodeData', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] | var configPriority = [ 'ownerClusterNodeData', 'ownerInstnace', 'commonInstance' /*, 'genericChessInstance'*/ ] | ||||
if(commoninstanceonly) { configPriority = [ 'commonInstance' ] } | |||||
return any(configPriority.map(cfg => { return function() { return instanceData[cfg](slections) } } ), true, true) | return any(configPriority.map(cfg => { return function() { return instanceData[cfg](slections) } } ), true, true) | ||||
} | } | ||||
#!/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" | |||||
#!/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!" | |||||