Cleanup how variables are specified and loaded:
[monkeysphere.git] / src / transition_0.22_0.23
1 #!/bin/bash
2
3 # This is a post-install script for monkeysphere, to transition an old
4 # (<=0.22) setup to the new (>0.22) setup
5
6 SYSDATADIR=${MONKEYSPHERE_SYSDATADIR:-"/var/lib/monkeysphere"}
7
8 MADATADIR="${SYSDATADIR}/authentication"
9 MHDATADIR="${SYSDATADIR}/host"
10
11 ############################################################
12 ### transfer host setup
13
14 if [ -d "$SYSDATADIR"/gnupg-host ] ; then
15
16     if [ -s "$SYSDATADIR"/ssh_host_rsa_key ] ; then
17
18         # This would be simple, but it would generate a new pgp key,
19         #and we don't want that, right?
20         #monkeysphere-host expert import_key "$SYSDATADIR"/ssh_host_rsa_key
21
22         # create host home
23         mkdir -p "${MHDATADIR}"
24         mkdir -p "${MHTMPDIR}"
25         mkdir -p "${GNUPGHOME_HOST}"
26         chmod 700 "${GNUPGHOME_HOST}"
27
28         # transfer the host secret key from the old home to the new
29         GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --export-secret-keys \
30             GNUPGHOME="$MHDATADIR" gpg --import
31
32         # make sure the ssh_host_rsa_key.pub and ssh_host_rsa_key.pub.gpg
33         # files exist
34
35         # anything else?
36
37     fi
38
39     #rm -rf "$SYSDATADIR"/gnupg-host
40
41 fi
42
43 ############################################################
44 ### transfer authentication setup
45
46 # should we test for something else/better than the existence of this
47 # directory to know that we should go through the setup?
48 if [ -d "$SYSDATADIR"/gnupg-authentication ] ; then
49
50     # run the authentication setup
51     monkeysphere-authentication setup
52
53     # transfer certifiers
54     # FIXME: how?
55     # i think we'll need to run something like
56     # gpg_core_sphere_sig_transfer after transfering certifiers ltsigs
57
58     # do we need to do some sort of transfer of ownertrust?
59
60     # move the authorized_keys directory
61     mv "$SYSDATADIR"/authorized_keys "$MADATADIR"/
62
63     # do we need to transfer anything else?  running update-users will
64     # regenerate everything else in the sphere keyring, right?
65
66     #rm -rf "$SYSDATADIR"/gnupg-authentication
67
68 fi
69