dockerFiles/kerberos/start.sh

44 lines
1.1 KiB
Bash
Raw Normal View History

2022-07-15 13:19:10 +00:00
#!/bin/bash
2022-07-15 15:42:47 +00:00
FQDN="test.com"
2022-07-15 13:19:10 +00:00
ADMIN="admin"
2022-07-15 15:42:47 +00:00
PASS="Admin12!"
2022-07-15 13:19:10 +00:00
KRB5_KTNAME=/etc/admin.keytab
cat /etc/hosts
echo "hostname: ${FQDN}"
2022-07-15 15:42:47 +00:00
inited="/app/inited"
function init_user() {
if [ -f "${inited}" ];then
echo "user inited"
2022-07-16 06:16:51 +00:00
kadmin.local -q "xst -k /app/hadoop.keytab -norandkey server/hadoop.${FQDN}"
kadmin.local -q "xst -k /app/cli.keytab -norandkey cli"
2022-07-15 15:42:47 +00:00
return;
fi
echo "begin init user"
# create kerberos database
echo -e "${PASS}\n${PASS}" | kdb5_util create -s
# create admin
echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc ${ADMIN}/admin"
# create hadoop
2022-07-16 06:16:51 +00:00
echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc cli"
echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc server/hadoop.${FQDN}"
kadmin.local -q "ktadd -norandkey -k ${KRB5_KTNAME} cli"
kadmin.local -q "ktadd -norandkey -k ${KRB5_KTNAME} server/hadoop.${FQDN}"
kadmin.local -q "xst -k /app/hadoop.keytab -norandkey server/hadoop.${FQDN}"
kadmin.local -q "xst -k /app/cli.keytab -norandkey cli"
2022-07-15 15:42:47 +00:00
touch "${inited}"
echo "user inite success"
}
function main() {
init_user
/usr/local/bin/supervisord -n -c /etc/supervisord.conf
}
main