Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
10 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 |
---|---|---|
@@ -1,29 +1,51 @@ | ||
#!/bin/sh | ||
|
||
PASSWORD=$1 | ||
if [ -z $PASSWORD ]; then | ||
echo "Usage: principles.sh <password>" | ||
exit 1 | ||
fi | ||
|
||
if [ -z $HOSTNAME ]; then | ||
HOSTNAME=`hostname -f` | ||
fi | ||
echo $HOSTNAME | ||
echo "using hostname: $HOSTNAME for server component of server principals." | ||
|
||
PASSWORD=$1 | ||
KADMIN_LOCAL="sudo kadmin.local" | ||
NORMAL_USER=`whoami` | ||
|
||
#This script is idempotent: deletes existing principles and keytabs, if any, | ||
#before recreating. | ||
#This script is idempotent: running it multiple times: re-running it | ||
#results in the same state. Currently accomplished by deleting existing | ||
#principles and keytabs, if any, and then (re-)creating. | ||
|
||
#1. services | ||
SERVICE_KEYTAB=services.keytab | ||
|
||
rm -f `pwd`/$SERVICE_KEYTAB | ||
|
||
#zookeeper | ||
echo "delprinc -force zookeeper/$HOSTNAME" | $KADMIN_LOCAL | ||
echo "addprinc -randkey zookeeper/$HOSTNAME" | $KADMIN_LOCAL | ||
rm -f `pwd`/zookeeper.keytab | ||
echo "ktadd -k `pwd`/zookeeper.keytab zookeeper/$HOSTNAME" | $KADMIN_LOCAL | ||
sudo chown $NORMAL_USER `pwd`/zookeeper.keytab | ||
echo "ktadd -k `pwd`/$SERVICE_KEYTAB zookeeper/$HOSTNAME" | $KADMIN_LOCAL | ||
|
||
#hdfs | ||
echo "delprinc -force hdfs/$HOSTNAME" | $KADMIN_LOCAL | ||
echo "addprinc -randkey hdfs/$HOSTNAME" | $KADMIN_LOCAL | ||
echo "ktadd -k `pwd`/$SERVICE_KEYTAB hdfs/$HOSTNAME" | $KADMIN_LOCAL | ||
|
||
#host | ||
echo "delprinc -force host/$HOSTNAME" | $KADMIN_LOCAL | ||
echo "addprinc -randkey host/$HOSTNAME" | $KADMIN_LOCAL | ||
echo "ktadd -k `pwd`/$SERVICE_KEYTAB host/$HOSTNAME" | $KADMIN_LOCAL | ||
|
||
sudo chown $NORMAL_USER `pwd`/$SERVICE_KEYTAB | ||
|
||
#2. users | ||
echo "delprinc -force zkclient" | $KADMIN_LOCAL | ||
echo "addprinc -pw $PASSWORD zkclient" | $KADMIN_LOCAL | ||
|
||
# only uncomment this if you want to use keytabs with client (rather | ||
# than password). | ||
rm -f `pwd`/zkclient.keytab | ||
echo "ktadd -k `pwd`/zkclient.keytab zkclient" | $KADMIN_LOCAL | ||
sudo chown $NORMAL_USER `pwd`/zkclient.keytab | ||
#rm -f `pwd`/zkclient.keytab | ||
#echo "ktadd -k `pwd`/zkclient.keytab zkclient" | $KADMIN_LOCAL | ||
#sudo chown $NORMAL_USER `pwd`/zkclient.keytab |