Skip to content

Commit c76bf67

Browse files
authored
Merge pull request #2385 from sebkuf/fix_default_parameters
Added parameter for outputfile in initdb script
2 parents c1407e6 + 7d7d13c commit c76bf67

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ CHANGELOG
6868
### Tools
6969
- `intelmqsetup`:
7070
- SECURITY: fixed a low-risk bug causing the tool to change owner of `/` if run with the `INTELMQ_PATHS_NO_OPT` environment variable set. This affects only the PIP package as the DEB/RPM packages don't contain this tool. (PR#2355 by Kamil Mańkowski, fixes #2354)
71+
- `intelmq_psql_initdb`:
72+
- Added parameter `-o` to set the output file destination. (by Sebastian Kufner)
7173

7274
### Known Errors
7375
- `intelmq.parsers.html_table` may not process invalid URLs in patched Python version due to changes in `urllib`. See #2382

intelmq/bin/intelmq_psql_initdb.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os
1515
import sys
1616
import tempfile
17+
import argparse
1718

1819
from intelmq import HARMONIZATION_CONF_FILE
1920

@@ -22,6 +23,14 @@
2223
'source.abuse_contact', 'source.asn', 'source.ip', 'source.fqdn',
2324
'time.observation', 'time.source']
2425

26+
DESCRIPTION = """
27+
Generates a SQL command file with commands to create the events table.
28+
29+
Reads the harmonization configuration and generates an SQL command from it.
30+
The SQL file is saved by default in `/tmp/initdb.sql` or a temporary name
31+
if the other one exists.
32+
"""
33+
2534

2635
def generate(harmonization_file=HARMONIZATION_CONF_FILE):
2736
FIELDS = {}
@@ -80,7 +89,17 @@ def generate(harmonization_file=HARMONIZATION_CONF_FILE):
8089

8190

8291
def main():
83-
OUTPUTFILE = "/tmp/initdb.sql"
92+
parser = argparse.ArgumentParser(
93+
description=DESCRIPTION,
94+
formatter_class=argparse.RawDescriptionHelpFormatter
95+
)
96+
parser.add_argument('-o', '--outputfile',
97+
help='Defines the Ouputfile',
98+
default='/tmp/initdb.sql'
99+
)
100+
args = parser.parse_args()
101+
102+
OUTPUTFILE = args.outputfile
84103
fp = None
85104
try:
86105
if os.path.exists(OUTPUTFILE):

0 commit comments

Comments
 (0)