aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2012-06-15 18:32:41 +0000
committerRob Austein <sra@hactrn.net>2012-06-15 18:32:41 +0000
commitcf16e9178be5612200b007749efacdf6db481616 (patch)
treec200b9269593a3178c695ec1254183eca8c8d90d /scripts
parent843f3a11c53cd9835ecce689bbf6e31ececfe3fd (diff)
Add warning and "Are you sure?" query.
svn path=/trunk/; revision=4543
Diffstat (limited to 'scripts')
-rw-r--r--scripts/convert-from-entitydb-to-sql.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/scripts/convert-from-entitydb-to-sql.py b/scripts/convert-from-entitydb-to-sql.py
index e1030ba9..57f7588b 100644
--- a/scripts/convert-from-entitydb-to-sql.py
+++ b/scripts/convert-from-entitydb-to-sql.py
@@ -26,24 +26,49 @@ import rpki.config, rpki.x509, rpki.relaxng, rpki.sundial
from rpki.mysql_import import MySQLdb
from lxml.etree import ElementTree
-if os.getlogin() != "sra":
- sys.exit("I //said// this was a work in progress")
-
cfg_file = "rpki.conf"
entitydb = "entitydb"
bpki = "bpki"
copy_csv_data = True
+force = False
-opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"])
+opts, argv = getopt.getopt(sys.argv[1:], "c:fh?", ["config=", "force", "help"])
for o, a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
sys.exit(0)
if o in ("-c", "--config"):
cfg_file = a
+ elif o in ("-f", "--force"):
+ force = True
if argv:
sys.exit("Unexpected arguments %s" % argv)
+if not force:
+ print """
+ WARNING WARNING WARNING
+
+ This script attempts to upgrade an existing rpkid instance to
+ work with the newer SQL-based back end code. It has worked in
+ the handful of cases where we've tested it, but it's dangerous
+ and relies heavily on guesses about how your existing instance
+ was originally set up. It may not work right. It may not
+ work at all. It may turn your cat blue.
+
+ Please back up all your data (MySQL databases, bpki/ and
+ entitydb/ directories) and configuration (rpki.conf file) before
+ running this script.
+ """
+ while True:
+ answer = raw_input("Are you SURE you want to proceed? (yes/NO) ").strip().lower()
+ if answer in ("", "n", "no"):
+ sys.exit("You have chosen wisely")
+ elif answer in ("y", "yes"):
+ print "You have been warned"
+ break
+ else:
+ print 'Please answer "yes" or "no"'
+
cfg = rpki.config.parser(cfg_file)
sql_database = cfg.get("sql-database", section = "irdbd")