-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to join rocky 8 to domain with winbind
- Loading branch information
1 parent
6a43655
commit 1bb01e9
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#/bin/bash | ||
|
||
# Function to display usage | ||
usage() { | ||
echo "Usage: $0 --hostname HOSTNAME --user USERNAME --realm REALM" | ||
echo | ||
echo "Options:" | ||
echo " --hostname Specify the server hostname" | ||
echo " --user Specify the username" | ||
echo " --realm Specify the realm (e.g., 45drives.local)" | ||
exit 1 | ||
} | ||
|
||
# If no arguments passed, show usage | ||
[[ $# -eq 0 ]] && usage | ||
|
||
# Parse arguments | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
--hostname) | ||
HOSTNAME="$2" | ||
shift 2 | ||
;; | ||
--user) | ||
USERNAME="$2" | ||
shift 2 | ||
;; | ||
--realm) | ||
REALM="$2" | ||
shift 2 | ||
;; | ||
*) | ||
echo "Unknown option: $1" | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
# Validate required variables | ||
if [[ -z "$HOSTNAME" || -z "$USERNAME" || -z "$REALM" ]]; then | ||
echo "Error: --user and --realm arguments are required." | ||
usage | ||
fi | ||
|
||
# Force the realm to uppercase | ||
REALM="${REALM^^}" | ||
|
||
# Now do something with $USERNAME and $REALM | ||
echo "Username: $USERNAME" | ||
echo "Realm: $REALM" | ||
|
||
dnf install realmd oddjob-mkhomedir oddjob samba-winbind-clients samba-winbind samba-common-tools samba-winbind-krb5-locator samba | ||
hostnamectl set-hostname hostname.45service.local | ||
currentTimestamp=`date +%y-%m-%d-%H:%M:%S` | ||
mv /etc/samba/smb.conf /etc/samba/smb.conf.$currentTimestamp.bak | ||
realm join --user=ballison --membership-software=samba --client-software=winbind --server-software=active-directory 45SERVICE.LOCAL | ||
echo include = registry >> smb.conf | ||
systemctl enable --now smb |