source: trunk/athena/etc/ktconvert/ktconvert.sh @ 22897

Revision 22897, 1.2 KB checked in by tabbott, 16 years ago (diff)
Initial checkin of ktconvert Debian packaging. * athena/etc/ktconvert/ktconvert.sh: Remove athena from paths.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2# $Id: ktconvert.sh,v 1.1 2004-03-14 22:39:24 zacheiss Exp $
3#
4# Convert /etc/srvtab to /etc/krb5.keytab, removing the srvtab
5# when we're done.
6
7usage="Usage: ktconvert [ -r ]
8       -r indicates /etc/krb5.keytab should be converted back into /etc/srvtab."
9
10fromfile=/etc/srvtab
11tofile=/etc/krb5.keytab
12readop=rst
13writeop=wkt
14
15while getopts r opt; do
16  case "$opt" in
17  r)
18    fromfile=/etc/krb5.keytab
19    tofile=/etc/srvtab
20    readop=rkt
21    writeop=wst
22    ;;
23  \?)
24    echo "$usage" >&2
25    exit 1
26    ;;
27  esac
28done
29
30case `id` in
31"uid=0("*)
32  ;;
33*)
34  echo "You are not root.  This script must be run as root."
35  exit 1
36  ;;
37esac
38
39if [ ! -f $fromfile ]; then
40  echo "$fromfile does not exist."
41  exit 1
42fi
43
44if [ -f $tofile ]; then
45  echo "$tofile already exists."
46  exit 1
47fi
48
49# We redirect stderr below because libreadline spews warnings
50# we don't care about.
51/usr/sbin/ktutil <<EOF >/dev/null 2>&1
52$readop $fromfile
53$writeop $tofile
54quit
55EOF
56
57if [ $? != 0 ]; then
58  echo "Failed to run ktutil."
59  exit 1
60fi
61
62# Ensure file we're removing is writable so saferm will remove it.
63chmod 600 $fromfile
64/bin/saferm -z $fromfile
65
66if [ $? != 0 ]; then
67  echo "saferm failed to remove $fromfile."
68  exit 1
69fi
70
71echo "Converted $fromfile to $tofile."
72exit 0
Note: See TracBrowser for help on using the repository browser.