jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 1 | #!/usr/bin/python2 |
| 2 | import os |
| 3 | import sys |
| 4 | import inspect |
| 5 | from sets import Set |
| 6 | |
| 7 | def usage(): |
| 8 | print "\nUSAGE:" |
| 9 | print " ./install_apps.py [OPTIONS]\n" |
| 10 | print " Install NDN applications" |
| 11 | print " Latest source codes will be downloaded from their GitHub" |
| 12 | print " named-data repositories (https://github.com/named-data)" |
| 13 | print "\nOPTIONS:" |
jeraldabraham | 5fdeecd | 2014-04-25 15:56:03 -0700 | [diff] [blame] | 14 | print " install_ndncxx - install ndn-cxx (named-data/ndn-cxx)" |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 15 | print " setup_security - create an identity using ndnsec (/tmp/nfd_integration)" |
| 16 | print " install_NFD - install NFD (named-data/NFD)" |
| 17 | print " install_ndntraffic - install ndn-traffic-generator (named-data/ndn-traffic-generator)" |
| 18 | print " install_ndntlvping - install ndn-tlv-ping (named-data/ndn-tlv-ping)" |
| 19 | print " install_all - do all of the above" |
| 20 | print " help - print this message and exit\n" |
| 21 | |
| 22 | |
| 23 | def main(): |
| 24 | cmd_subfolder = os.path.realpath( |
| 25 | os.path.abspath(os.path.join(os.path.split( |
| 26 | inspect.getfile(inspect.currentframe()))[0], "install_helpers"))) |
| 27 | if cmd_subfolder not in sys.path: |
| 28 | sys.path.insert(0, cmd_subfolder) |
jeraldabraham | 5fdeecd | 2014-04-25 15:56:03 -0700 | [diff] [blame] | 29 | validOptions = [ "install_ndncxx", |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 30 | "setup_security", |
| 31 | "install_NFD", |
| 32 | "install_ndntraffic", |
| 33 | "install_ndntlvping", |
| 34 | "install_all", |
| 35 | "help" ] |
| 36 | |
| 37 | if len(sys.argv) > 1: |
| 38 | actionList = Set(sys.argv[1:]) |
| 39 | optionsStatus = 0 |
| 40 | for option in actionList: |
| 41 | if option not in validOptions: |
| 42 | print "Invalid option provided - " + option |
| 43 | optionsStatus = -1 |
| 44 | break |
| 45 | if optionsStatus == 0 and "help" not in actionList: |
| 46 | if "install_all" in actionList: |
jeraldabraham | 5fdeecd | 2014-04-25 15:56:03 -0700 | [diff] [blame] | 47 | actionList.add("install_ndncxx") |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 48 | actionList.add("setup_security") |
| 49 | actionList.add("install_NFD") |
| 50 | actionList.add("install_ndntraffic") |
| 51 | actionList.add("install_ndntlvping") |
| 52 | module = __import__("setup_preparation_folder") |
| 53 | module.run() |
| 54 | module = __import__("install_dependencies") |
| 55 | module.run() |
jeraldabraham | 5fdeecd | 2014-04-25 15:56:03 -0700 | [diff] [blame] | 56 | if "install_ndncxx" in actionList: |
| 57 | module = __import__("install_ndncxx") |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 58 | module.run() |
| 59 | if "setup_security" in actionList: |
| 60 | module = __import__("setup_security") |
| 61 | module.run() |
| 62 | if "install_NFD" in actionList: |
| 63 | module = __import__("install_NFD") |
| 64 | module.run() |
| 65 | if "install_ndntraffic" in actionList: |
| 66 | module = __import__("install_ndntraffic") |
| 67 | module.run() |
| 68 | if "install_ndntlvping" in actionList: |
| 69 | module = __import__("install_ndntlvping") |
| 70 | module.run() |
| 71 | print "" |
| 72 | else: |
| 73 | usage() |
| 74 | else: |
| 75 | usage() |
| 76 | |
| 77 | |
| 78 | if __name__ == "__main__": |
| 79 | main() |