fix alternc-slaves detection and warn the user if there's no key to authorize

This commit is contained in:
Antoine Beaupré 2009-08-04 19:29:01 +00:00
parent 049042dd87
commit 93dde12ee2
1 changed files with 15 additions and 8 deletions

View File

@ -158,19 +158,26 @@ EOF
# multi-server configuration: we create an alternc account with
# authorized keys. since this is the master, we do not give him a
# valid shell, but we still need the user for proper perms
if [ ! -z "$ALTERNC_SLAVES" && "$ALTERNC_SLAVES" != "localhost" ] ; then
if [ ! -z "$ALTERNC_SLAVES" ] && [ "$ALTERNC_SLAVES" != "localhost" ] ; then
if ! grep -q alternc /etc/passwd ; then
echo "Creating alternc account"
adduser --quiet --system --uid 342 --home $ALTERNC_LOC --shell /bin/false --ingroup adm alternc
fi
key=`cat ~root/.ssh/id_dsa.pub`
if ! grep -q "$key" $ALTERNC_LOC/.ssh/authorized_keys ; then
echo "Authorizing root ssh key to access the common alternc account"
mkdir -p $ALTERNC_LOC/.ssh
echo "$key" >> $ALTERNC_LOC/.ssh/authorized_keys
chown -R alternc:adm $ALTERNC_LOC/.ssh
chmod -R og-rwx $ALTERNC_LOC/.ssh
if [ -r ~root/.ssh/id_dsa.pub ]; then
key=`cat ~root/.ssh/id_dsa.pub`
if ! grep -q "$key" $ALTERNC_LOC/.ssh/authorized_keys ; then
echo "Authorizing root ssh key to access the common alternc account"
mkdir -p $ALTERNC_LOC/.ssh
echo "$key" >> $ALTERNC_LOC/.ssh/authorized_keys
chown -R alternc:adm $ALTERNC_LOC/.ssh
chmod -R og-rwx $ALTERNC_LOC/.ssh
fi
else
echo "No SSH key in "~root/.ssh/id_dsa.pub
echo "create one and reconfigure alternc to propagate SSH keys"
fi
else
echo "AlternC slaves not configured ($ALTERNC_SLAVES)"
fi
# /var/alternc/dns/d/www.example.com