~ubuntu-branches/ubuntu/utopic/hockeypuck/utopic-proposed

« back to all changes in this revision

Viewing changes to build/src/github.com/hockeypuck/hockeypuck/cmd/hockeypuck/recover.go

  • Committer: Package Import Robot
  • Author(s): Casey Marshall
  • Date: 2014-04-13 20:06:01 UTC
  • Revision ID: package-import@ubuntu.com-20140413200601-oxdlqn1gy0x8m55u
Tags: 1.0~rel20140413+7a1892a~trusty
Hockeypuck 1.0 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   Hockeypuck - OpenPGP key server
 
3
   Copyright (C) 2012-2014  Casey Marshall
 
4
 
 
5
   This program is free software: you can redistribute it and/or modify
 
6
   it under the terms of the GNU Affero General Public License as published by
 
7
   the Free Software Foundation, version 3.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU Affero General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Affero General Public License
 
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
 
 
18
// hockeypuck is an OpenPGP keyserver.
 
19
package main
 
20
 
 
21
import (
 
22
        "log"
 
23
 
 
24
        . "github.com/hockeypuck/hockeypuck"
 
25
        "github.com/hockeypuck/hockeypuck/openpgp"
 
26
        "launchpad.net/gnuflag"
 
27
 
 
28
        "github.com/syndtr/goleveldb/leveldb"
 
29
        "github.com/syndtr/goleveldb/leveldb/storage"
 
30
)
 
31
 
 
32
type recoverCmd struct {
 
33
        configuredCmd
 
34
}
 
35
 
 
36
func (rc *recoverCmd) Name() string { return "recover" }
 
37
 
 
38
func (rc *recoverCmd) Desc() string { return "Recover prefix tree" }
 
39
 
 
40
func newRecoverCmd() *recoverCmd {
 
41
        cmd := new(recoverCmd)
 
42
        flags := gnuflag.NewFlagSet(cmd.Name(), gnuflag.ExitOnError)
 
43
        flags.StringVar(&cmd.configPath, "config", "", "Hockeypuck configuration file")
 
44
        cmd.flags = flags
 
45
        return cmd
 
46
}
 
47
 
 
48
func (ec *recoverCmd) Main() {
 
49
        ec.configuredCmd.Main()
 
50
        InitLog()
 
51
        path := openpgp.Config().Settings.TomlTree.Get("conflux.recon.leveldb.path").(string)
 
52
        stor, err := storage.OpenFile(path)
 
53
        if err != nil {
 
54
                die(err)
 
55
        }
 
56
        log.Println("database storage opened, recovering...")
 
57
        db, err := leveldb.Recover(stor, nil)
 
58
        if err != nil {
 
59
                die(err)
 
60
        }
 
61
        log.Println("recovery complete")
 
62
        db.Close()
 
63
}