#!/usr/bin/python

# Use this file to add SCION ISD entries to the whois database

import os

# Ensure the ISD database directory exists
os.system("mkdir -p db/isd")

isd = input("Enter ISD number: ")

# Validate ISD number
if not isd.isdigit():
    print("Invalid ISD number. Expected a numeric value.")
    exit(1)

# Get ISD details
name = input("Enter ISD Name: ")
comment = input("Enter Comment: ")
trc_bundle = input("Enter TRC Bundle: ")

# Prepare ISD data
n = "\r\n"
body = "% SCION ISD WHOIS Information" + n + n
body += "ISD:           " + isd + n
body += "Name:          " + name + n
body += "Comment:       " + comment + n
body += "TRC Bundle:    " + trc_bundle + n

# Save to file
d = open("db/isd/" + isd, "w+")
d.write(body)
d.close()
print("Done! SCION ISD record added successfully.")
