This file is indexed.

/usr/bin/zabbix-cli-init is in zabbix-cli 1.7.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /usr/bin/python
#
# Authors:
# Mustafa Ocak
# muo@uio.no
#
# Copyright (c) 2015 USIT-University of Oslo
#
# This script initialize zabbix-cli environment. it will copy
# /etc/zabbix-cli/zabbix-cli.conf to $HOME/.zabbix-cli/ and change log
# configuration in zabbix-cli.conf so that zabbix-cli logs to
# $HOME/.zabbix-cli/
#
###########################################################################################

from os import getenv,path,remove,close,makedirs
from tempfile import mkstemp
from shutil import move, copy2
import sys
import os
import argparse

def replace(file_path, pattern, subst):

    #
    #  changing the line having log configuration option 
    #  replacing 
    #  log_file=/var/log/zabbix-cli/zabbix-cli.log
    #  to log_file=~/.zabbix-cli/zabbix-cli.log
    
    try:

        #Create temp file
        fh, abs_path = mkstemp()
        with open(abs_path,'w') as new_file:
            with open(file_path) as old_file:
                for line in old_file:
                    new_file.write(line.replace(pattern, subst))
        close(fh)
        #Remove original file
        remove(file_path)
        #Move new file
        move(abs_path, file_path)

    except Exception as e:
        print '\n[ERROR]: %s\n',e

if __name__ == "__main__":

    if os.getenv('HOME') is not None:
        zabbixconfdir = getenv('HOME')+"/.zabbix-cli/"

    else:
        print '\n[ERROR]: The $HOME environment variable is not defined. zabbix-cli-init cannot generate the configuration file in your home directory.'
        sys.exit(1)

    defconf="/usr/share/zabbix-cli/zabbix-cli.conf"
    filename="zabbix-cli.conf"

    file_path=path.join(zabbixconfdir,filename)

    try:

        parser = argparse.ArgumentParser(prog=sys.argv[0],description='zabbix-cli-init - Zabbix-cli initialization program')

        parser.add_argument('--zabbix-url','-z',  metavar='<zabbix URL>', required=True, dest='zabbix_api_url')        
        args = parser.parse_args()  

        if args.zabbix_api_url:
            zabbix_api_url = args.zabbix_api_url
        
    except Exception as e:
        print e
        sys.exit(1)

    #
    # creating ~/.zabbix-cli folder if not exists
    #

    if not path.exists(zabbixconfdir):

        try:
            makedirs(zabbixconfdir)
        except Exception as e:
            print '\n[ERROR]: %s\n',e

    #
    # /etc/zabbix-cli.conf will be created under installation of
    # zabbix-cli package.  copying /etc/zabbix-cli.conf file to
    # ~/.zabbix-cli/zabbix-cli.conf
    # 

    if path.isfile(defconf):
        try:
            copy2(defconf,zabbixconfdir)

        except Exception as e:
            print '\n[ERROR]: %s\n',e
    else:
        print "Cannot find /etc/zabbix-cli/zabbix-cli.conf file. ERROR with zabbix-cli installation."
        sys.exit(1)
    
    #
    #  changing the line having log configuration option 
    #  replacing log file option 
    #  log_file=/var/log/zabbix-cli/zabbix-cli.log
    #  to log_file=~/.zabbix-cli/zabbix-cli.log
    #
    replace(file_path,'log_file=/var/log/zabbix-cli/zabbix-cli.log','log_file=' + getenv('HOME') + '/.zabbix-cli/zabbix-cli.log')

    #
    #  Changing the line having the zabbix API url example with real
    #  URL.
    #
    replace(file_path,';zabbix_api_url=https://zabbix.example.net/zabbix','zabbix_api_url=' + zabbix_api_url)