mirror of
https://gitpot.dev/LogolicusZ/user-management.git
synced 2024-11-01 03:05:43 +00:00
31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Step 1: Set Configuration using Environment Variables
|
||
|
source config.cfg
|
||
|
|
||
|
# Step 2: Retrieve User Data from a CSV File
|
||
|
while IFS=',' read -r username password email
|
||
|
do
|
||
|
# Step 3: Process User Data
|
||
|
# Create a new user
|
||
|
sudo dscl . -create "/Users/$username"
|
||
|
sudo dscl . -create "/Users/$username" UserShell "/bin/bash"
|
||
|
sudo dscl . -create "/Users/$username" RealName "$username"
|
||
|
sudo dscl . -create "/Users/$username" UniqueID "<userID>"
|
||
|
sudo dscl . -create "/Users/$username" PrimaryGroupID "<groupID>"
|
||
|
sudo dscl . -create "/Users/$username" NFSHomeDirectory "/Users/$username"
|
||
|
sudo dscl . -passwd "/Users/$username" "$password"
|
||
|
sudo dscl . -append /Groups/admin GroupMembership "$username"
|
||
|
|
||
|
# Step 4: Provide Additional Details to the User
|
||
|
echo "Welcome, $username! Here are some additional details." > "/Users/$username/details.txt"
|
||
|
# Include more information as needed
|
||
|
|
||
|
# Step 5: Create Output File
|
||
|
echo "User $username has been created successfully." >> output.txt
|
||
|
|
||
|
done < userdata.csv
|
||
|
|
||
|
# Step 6: Add Cronjob
|
||
|
echo "0 8 * * 0 /path/to/script.sh" | crontab -
|