Browse Source

Update 'i.lin.sh'

user add
pull/21/head
pb 5 days ago
parent
commit
a6b9f9b29f
1 changed files with 39 additions and 1 deletions
  1. 39
    1
      i.lin.sh

+ 39
- 1
i.lin.sh View File

@@ -1,5 +1,44 @@
#!/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_REPOSERVER="http://git.bbh"
DEFAULT_DEFAULTREPOOWNER="chess"
@@ -223,4 +262,3 @@ echo "Module configuration generated for: $INSTANCENAME"
echo "module.exports = { instanceName : '$INSTANCENAME', reposerver: '$REPOSERVER', gitUser: '$GITUSER', gitEmail: '$GITEMAIL' }" > installchoices.js

echo "Setup completed successfully!"


Loading…
Cancel
Save