New changes and Files

This commit is contained in:
LogolicusYZ 2023-07-14 10:08:33 +02:00
commit ef9e477532
7 changed files with 57 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

1
README.md Normal file
View file

@ -0,0 +1 @@
This is the Repository for the User Managment Project of the Modul M122

6
config.cfg Normal file
View file

@ -0,0 +1,6 @@
# Configuration for User Management Script
# Set options for processing
export OPTION_1="value1"
export OPTION_2="value2"
export OPTION_3="value3"

10
output.txt Normal file
View file

@ -0,0 +1,10 @@
User username has been created successfully.
User john123 has been created successfully.
User jane456 has been created successfully.
User alice123 has been created successfully.
User bob456 has been created successfully.
User johndoe has been created successfully.
User janedoe has been created successfully.
User user1 has been created successfully.
User user2 has been created successfully.
User user3 has been created successfully.

30
user_management.sh Executable file
View file

@ -0,0 +1,30 @@
#!/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 -

10
userdata.csv Normal file
View file

@ -0,0 +1,10 @@
username,password,email
john123,pass123,john@example.com
jane456,pass456,jane@example.com
alice123,alicepass123,alice@example.com
bob456,bobpass456,bob@example.com
johndoe,password123,johndoe@example.com
janedoe,securepass789,janedoe@example.com
user1,pass123,user1@example.com
user2,pass456,user2@example.com
user3,pass789,user3@example.com
1 username password email
2 john123 pass123 john@example.com
3 jane456 pass456 jane@example.com
4 alice123 alicepass123 alice@example.com
5 bob456 bobpass456 bob@example.com
6 johndoe password123 johndoe@example.com
7 janedoe securepass789 janedoe@example.com
8 user1 pass123 user1@example.com
9 user2 pass456 user2@example.com
10 user3 pass789 user3@example.com