浏览代码

fixed copy

pull/21/head
pb 5 天前
父节点
当前提交
1a6c8d5695
共有 1 个文件被更改,包括 2 次插入40 次删除
  1. 2
    40
      i.lin.sh

+ 2
- 40
i.lin.sh 查看文件

@@ -9,45 +9,6 @@ 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

# 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!"
@@ -72,7 +33,7 @@ else
fi

# cd /home/$username
#wget -q -O - http://git.bbh.org.in/chess/elxr/raw/branch/master/$script_to_run > $script_to_run
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

@@ -314,6 +275,7 @@ 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

正在加载...
取消
保存