Version 2.3.1, Bug fix paramater handling
This commit is contained in:
parent
9ab5b93fb8
commit
881c767571
@ -6,6 +6,7 @@ Version History:
|
||||
--
|
||||
|Date|Version|Changes|
|
||||
|----|-------|-------|
|
||||
|2023/03/27|2.3.1|Fixed bugs in parameter handling|
|
||||
|2023/03/23|2.2.1|Adjusted parameter handling|
|
||||
|||Added check for "free space on disk" (incl. adjustable levels)|
|
||||
|||Added adjustable levels for "number of files"|
|
||||
|
@ -19,18 +19,20 @@ USAGE: agent_nextcloud_info -u [username] -p [password]
|
||||
agent_nextcloud_info -h
|
||||
|
||||
OPTIONS:
|
||||
-H, --hostname Hostname (FQDN or IP) of Nextcloud server
|
||||
-u, --username Username
|
||||
-p, --password Password
|
||||
-P, --port Port
|
||||
-f, --folder Subfolder if not installed in web root
|
||||
-t, --token Token (recommended)
|
||||
--no-https Disable HTTPS, use HTTP (not recommended!)
|
||||
--no-cert-check Disable TLS certificate check (not recommended!)
|
||||
-h, --help Show this help message and exit
|
||||
-H, --hostname Hostname (FQDN or IP) of Nextcloud server
|
||||
-u, --username Username
|
||||
-p, --password Password
|
||||
-P, --port Port
|
||||
-f, --folder Subfolder if not installed in web root
|
||||
-t, --token Token (recommended)
|
||||
--no-https True|False If "True": Disable HTTPS, use HTTP (not recommended!)
|
||||
--no-cert-check True|False If "True": Disable TLS certificate check (not recommended!)
|
||||
-h, --help Show this help message and exit
|
||||
""")
|
||||
|
||||
# set this to true to produce debug output (this clutters the agent output)
|
||||
# be aware: activating this logs very sensitive information to debug files in ~/tmp
|
||||
# !!DO NOT FORGET to delete these files after debugging is done!!
|
||||
DEBUG = False
|
||||
|
||||
nc_api_endpoint = "ocs/v2.php/apps/serverinfo/api/v1/info?format=json"
|
||||
@ -48,7 +50,7 @@ opt_no_cert_check = False
|
||||
|
||||
short_options = 'hH:u:p:P:f:t:'
|
||||
long_options = [
|
||||
'hostname=', 'username=', 'password=', 'port=', 'token=', 'folder=', 'no-https', 'no-cert-check', 'help'
|
||||
'hostname=', 'username=', 'password=', 'port=', 'token=', 'folder=', 'no-https=', 'no-cert-check=', 'help'
|
||||
]
|
||||
|
||||
def getOptions():
|
||||
@ -65,7 +67,7 @@ def getOptions():
|
||||
for opt, arg in opts:
|
||||
if opt in ['-H', '--hostname']:
|
||||
opt_hostname = arg
|
||||
if opt in ['-u', '--username']:
|
||||
elif opt in ['-u', '--username']:
|
||||
opt_username = arg
|
||||
elif opt in ['-p', '--password']:
|
||||
opt_password = arg
|
||||
@ -76,28 +78,39 @@ def getOptions():
|
||||
elif opt in ['-t', '--token']:
|
||||
opt_token = arg
|
||||
elif opt in ['--no-https']:
|
||||
opt_no_https = True
|
||||
if arg == 'True':
|
||||
opt_no_https = True
|
||||
else:
|
||||
opt_no_https = False
|
||||
elif opt in ['--no-cert-check']:
|
||||
opt_no_cert_check = True
|
||||
if arg == 'True':
|
||||
opt_no_cert_check = True
|
||||
else:
|
||||
opt_no_cert_check = False
|
||||
elif opt in ['-h', '--help']:
|
||||
showUsage()
|
||||
sys.exit(0)
|
||||
|
||||
def showOptions():
|
||||
print(f"Hostname: {opt_hostname}")
|
||||
print(f"Username: {opt_username}")
|
||||
#print(f"Password: {opt_password}")
|
||||
print(f"Port: {opt_port}")
|
||||
print(f"Folder: {opt_folder}")
|
||||
#print(f"Token: {opt_token}")
|
||||
print(f"No HTTPS: {opt_no_https}")
|
||||
print(f"No TLS Check: {opt_no_cert_check}")
|
||||
if DEBUG:
|
||||
home_path = os.getenv("HOME")
|
||||
tmp_path = f"{home_path}/tmp"
|
||||
help_file = f"{tmp_path}/nextcloud_{opt_hostname}_debug.txt"
|
||||
with open(help_file, "a") as file:
|
||||
file.write(f"Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https} \n")
|
||||
file.write(f"Number of Arguments: {len(sys.argv)}, Argument List: {str(sys.argv)}\n")
|
||||
|
||||
def showOptions():
|
||||
print(f"Hostname: {opt_hostname}")
|
||||
print(f"Username: {opt_username}")
|
||||
print(f"Password: {opt_password}")
|
||||
print(f"Port: {opt_port}")
|
||||
print(f"Folder: {opt_folder}")
|
||||
print(f"Token: {opt_token}")
|
||||
print(f"No HTTPS: {opt_no_https}")
|
||||
print(f"No TLS Check: {opt_no_cert_check}")
|
||||
home_path = os.getenv("HOME")
|
||||
tmp_path = f"{home_path}/tmp"
|
||||
help_file = f"{tmp_path}/nextcloud_{opt_hostname}_debug.txt"
|
||||
with open(help_file, "a") as file:
|
||||
file.write(f"Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https}, No Cert Check: {opt_no_cert_check}\n")
|
||||
|
||||
def createUrl(endpoint, hostname, protocol, port, folder):
|
||||
if folder == "":
|
||||
@ -242,8 +255,6 @@ def doCmkOutputAllUsers(data, verify, hostname, protocol, port, folder):
|
||||
|
||||
def main():
|
||||
getOptions()
|
||||
if DEBUG:
|
||||
showOptions()
|
||||
if (opt_hostname == ""):
|
||||
sys.stderr.write(f"No hostname given.\n")
|
||||
showUsage()
|
||||
@ -266,6 +277,8 @@ def main():
|
||||
else:
|
||||
protocol = "https"
|
||||
port = opt_port
|
||||
if DEBUG:
|
||||
showOptions()
|
||||
if (protocol == "http" and port == "443"):
|
||||
sys.stderr.write(f"Combining HTTP with port 443 is not supported.\n")
|
||||
sys.exit(1)
|
||||
|
BIN
mkp/Nextcloud-2.3.1.mkp
Executable file
BIN
mkp/Nextcloud-2.3.1.mkp
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user