| #!/bin/bash | #!/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 "Same user!" | |||||
| 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" | 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" | |||||
| cd /home/$username | |||||
| wget -q -O - http://git.bbh.org.in/chess/elxr/raw/branch/master/$script_to_run > $script_to_run | |||||
| # 3. Switch to the user and run the script | |||||
| echo "Switching to user $username and executing the script..." | |||||
| sudo -u "$username" bash -c "sh ./$script_to_run" | |||||
| exit 0 | |||||
| fi | |||||
| #!/bin/bash | |||||
| # Default values | # Default values | ||||
| DEFAULT_REPOSERVER="http://git.bbh" | DEFAULT_REPOSERVER="http://git.bbh" | ||||
| DEFAULT_DEFAULTREPOOWNER="chess" | DEFAULT_DEFAULTREPOOWNER="chess" | ||||
| echo "module.exports = { instanceName : '$INSTANCENAME', reposerver: '$REPOSERVER', gitUser: '$GITUSER', gitEmail: '$GITEMAIL' }" > installchoices.js | echo "module.exports = { instanceName : '$INSTANCENAME', reposerver: '$REPOSERVER', gitUser: '$GITUSER', gitEmail: '$GITEMAIL' }" > installchoices.js | ||||
| echo "Setup completed successfully!" | echo "Setup completed successfully!" | ||||