forked from StamusNetworks/Amsterdam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamsterdam
executable file
·56 lines (50 loc) · 2.27 KB
/
amsterdam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# Copyright (C) 2015 Stamus Networks
#
# You can copy, redistribute or modify this Program under the terms of
# the GNU General Public License version 3 as published by the Free
# Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# version 3 along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
import sys
import argparse
from amsterdam import Amsterdam
parser = argparse.ArgumentParser(description='Amsterdam, SELKS on docker')
parser.add_argument('-s', '--start', action='store_const', const=True, help='Start Amsterdam instance', default=False)
parser.add_argument('-S', '--stop', action='store_const', const=True, help='Stop Amsterdam instance', default=False)
parser.add_argument('-i', '--iface', default='eth0', help='Host iface to sniff')
parser.add_argument('-v', '--verbose', default=False, action="count", help="Show verbose output, use multiple times increase verbosity")
parser.add_argument('-d', '--data', default=None, help='Directory to store generated data into (default to ./data)')
parser.add_argument('-n', '--name', default="Amsterdam", help='Set project name')
parser.add_argument('command', metavar='command', nargs=1, help='Amsterdam command [setup|start|stop|restart|update])', default=None)
args = parser.parse_args()
if args.command[0] not in ['setup', 'start', 'stop', 'restart', 'update']:
sys.stderr.write("Invalid command: '%s'\n" % args.command)
sys.exit(-1)
basepath = './data'
if args.data:
basepath = args.data
ams = Amsterdam(args.name, args.iface, basepath)
if args.command[0] == 'setup':
if ams.setup(args) != 0:
sys.exit(-1)
if args.command[0] == 'start':
if ams.start(args) != 0:
sys.exit(-1)
elif args.command[0] == 'stop':
if ams.stop(args) != 0:
sys.exit(-1)
elif args.command[0] == 'restart':
if ams.restart(args) != 0:
sys.exit(-1)
elif args.command[0] == 'update':
if ams.update(args) != 0:
sys.exit(-1)