commit ef9e477532973360691b48015853a845b37d66a8 Author: LogolicusYZ Date: Fri Jul 14 10:08:33 2023 +0200 New changes and Files diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..fb67b5c Binary files /dev/null and b/.DS_Store differ diff --git a/M122_Vorlage_Anforderung_V1.0 .pdf b/M122_Vorlage_Anforderung_V1.0 .pdf new file mode 100644 index 0000000..226cf97 Binary files /dev/null and b/M122_Vorlage_Anforderung_V1.0 .pdf differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..cfe4c0a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +This is the Repository for the User Managment Project of the Modul M122 \ No newline at end of file diff --git a/config.cfg b/config.cfg new file mode 100644 index 0000000..a64ee06 --- /dev/null +++ b/config.cfg @@ -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" diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..b64d7c8 --- /dev/null +++ b/output.txt @@ -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. diff --git a/user_management.sh b/user_management.sh new file mode 100755 index 0000000..048b65c --- /dev/null +++ b/user_management.sh @@ -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 "" + sudo dscl . -create "/Users/$username" PrimaryGroupID "" + 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 - diff --git a/userdata.csv b/userdata.csv new file mode 100644 index 0000000..9b4b7c4 --- /dev/null +++ b/userdata.csv @@ -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