openvpn: is-setup checks for non-empty dh.pem file

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-11-19 12:24:50 +05:30 committed by James Valleroy
parent d5a73aaac4
commit 3a579e2d72
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,7 @@ import subprocess
import augeas
from plinth import action_utils
from plinth import action_utils, utils
KEYS_DIRECTORY = '/etc/openvpn/freedombox-keys'
@ -120,7 +120,7 @@ def parse_arguments():
def subcommand_is_setup(_):
"""Return whether setup is complete."""
print('true' if os.path.isfile(DH_KEY) else 'false')
print('true' if utils.is_non_empty_file(DH_KEY) else 'false')
def subcommand_setup(_):

View File

@ -154,3 +154,7 @@ def gunzip(gzip_file, output_file):
with open(output_file, 'wb', opener=opener) as file_handle:
file_handle.write(contents)
def is_non_empty_file(file_path):
return os.path.isfile(file_path) and os.path.getsize(file_path) > 0