First commit linux script
This commit is contained in:
29
setupScript.sh
Normal file
29
setupScript.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to create user if it doesn't exist
|
||||
create_user() {
|
||||
if ! id "$1" &>/dev/null; then
|
||||
echo "Creating user: $1"
|
||||
useradd -m "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to set password for user
|
||||
set_password() {
|
||||
echo "Setting password for $1"
|
||||
echo "$1:$2" | chpasswd
|
||||
}
|
||||
|
||||
# Check and create users
|
||||
create_user eleve
|
||||
create_user prof
|
||||
create_user admin
|
||||
|
||||
# Set passwords
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
set_password prof "IPRprof2398"
|
||||
set_password admin "Lprsnm4ehk26-"
|
||||
passwd -d eleve # Set empty password for eleve
|
||||
else
|
||||
echo "Password setting requires root privileges. Please run as root."
|
||||
fi
|
||||
Reference in New Issue
Block a user