Browse Source

updates

pull/21/head
pb 4 days ago
parent
commit
8559b59a25
1 changed files with 72 additions and 3 deletions
  1. 72
    3
      i.lin.sh

+ 72
- 3
i.lin.sh View File

@@ -1,5 +1,49 @@
#!/bin/bash

# Get user input for username and script to run
# read -p "Enter the username to create: " username
# read -p "Enter the full path to the shell script to run: " script_to_run
username=elxrprod
script_to_run=i.lin.sh

# Get the current user (who is running this script)
current_user=$(whoami)

# 1. Check if the current user is the same as the username to create
if [ "$current_user" == "$username" ]; then
echo "Script launched from same user!"
else

if id "$username" &>/dev/null; then
echo "User $username already exists, skipping user creation and password set."
else

# 1. Add user
echo "Adding user $username..."
useradd -m -s /bin/bash "$username"

read -sp "Enter password for the new user: " user_password
echo
echo "Setting password for user $username..."
echo "$username:$user_password" | sudo chpasswd

# 2. Add user to the sudoers group (usually 'wheel' on CentOS)
echo "Adding $username to the 'wheel' group for sudo access..."
usermod -aG wheel "$username"
fi

# cd /home/$username
#wget -q -O - http://git.bbh.org.in/chess/elxr/raw/branch/master/$script_to_run > $script_to_run
sudo cp ./$script_to_run /home/$username
sudo chmod u+x /home/$username/i.lin.sh

# 3. Switch to the user and run the script
echo "Switching to user $username and executing the script..."
sudo -u "$username" bash -c "sh /home/$username/$script_to_run"
exit 0
fi

# Default values
DEFAULT_REPOSERVER="http://git.bbh"
DEFAULT_DEFAULTREPOOWNER="chess"
@@ -44,9 +88,9 @@ echo "Do you want to skip development prerequisite installations? (yes/no, defau
read skipdevprereqs
SKIPDEVPREREQS=${skipdevprereqs:-"no"}

# Prompt for ROOT folder, with two options: current directory or /var/chess/$INSTANCENAME/$INSTANCETYPE
echo "Enter the ROOT folder location (default: current directory):"
echo "1) Current directory"
# Prompt for ROOT folder, with two options: ./chess/production_A or /var/chess/$INSTANCENAME/$INSTANCETYPE
echo "Enter the ROOT folder location (default: ./chess/production_A):"
echo "1) ./chess/production_A"
echo "2) /var/chess/$INSTANCENAME/$INSTANCETYPE"
read rootfolder
if [ "$rootfolder" == "2" ]; then
@@ -54,6 +98,13 @@ if [ "$rootfolder" == "2" ]; then
else
ROOT=$(pwd) # Default to current directory if user chooses 1
fi
mkdir -p $ROOT
cd $ROOT

wget -q -O - http://git.bbh/chess/elxr/raw/branch/master/centosinit.sh > $ROOT/centosinit.sh
sudo chmod u+x $ROOT/centosinit.sh
sh $ROOT/centosinit.sh


# If ROOT is not the current directory, create the necessary directories and change to ROOT
if [ "$ROOT" != "$(pwd)" ]; then
@@ -224,3 +275,21 @@ echo "module.exports = { instanceName : '$INSTANCENAME', reposerver: '$REPOSERVE

echo "Setup completed successfully!"


if [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then
sudo dnf install redis -y
else
sudo apt install redis -y
fi
sudo systemctl start redis
sudo systemctl enable redis
sudo systemctl status redis

echo "Setup completed successfully!"


# USE mysql;
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'cihsr';
# FLUSH PRIVILEGES;

mysql -u root -p cihsr < cihsr_prod.sql

Loading…
Cancel
Save