mirror of
https://github.com/bashclub/check-nextcloud.git
synced 2024-11-07 23:01:58 +01:00
Update check-nextcloud
This commit is contained in:
parent
aaf5764f6a
commit
7df0b538f6
@ -16,7 +16,7 @@
|
||||
## GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
VERSION="0.01"
|
||||
VERSION="0.02"
|
||||
|
||||
from operator import truediv
|
||||
import os
|
||||
@ -55,7 +55,7 @@ def update_check(conf:dict):
|
||||
|
||||
def status(conf:dict):
|
||||
if 'docker_container' in conf.keys() and (conf['docker_container'] != None or conf['docker_container'] != ""):
|
||||
result = occ("status", conf['nc_www_user'],conf['nc_path'], conf['nc_php_version'], output="json", docker_container=conf['docker_container'])
|
||||
result = json.loads(occ("status", conf['nc_www_user'],conf['nc_path'], conf['nc_php_version'], output="json", docker_container=conf['docker_container']))
|
||||
else:
|
||||
result = json.loads(occ("status", conf['nc_www_user'],conf['nc_path'], conf['nc_php_version'], output="json"))
|
||||
if result.get('installed') == False:
|
||||
@ -72,13 +72,15 @@ def printout(name:str,function:str, result:str):
|
||||
def occ (command:str, nc_www_user:str, nc_path:str, nc_php_version:str="", output:str="", return_stderr:bool=False, docker_container:str=None):
|
||||
if docker_container != None:
|
||||
cmd = f"docker exec --user {nc_www_user} --workdir {nc_path} {docker_container} php{nc_php_version} occ {command}"
|
||||
cwd = None
|
||||
else:
|
||||
cmd = f"sudo --user={nc_www_user} php{nc_php_version} occ {command}"
|
||||
cwd = nc_path
|
||||
|
||||
if output != "":
|
||||
cmd = cmd + f" --output {output}"
|
||||
|
||||
_proc = subprocess.Popen([ cmd ], shell=True, cwd=nc_path if docker_container is not None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
_proc = subprocess.Popen([ cmd ], shell=True,cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
stdout, stderr = _proc.communicate()
|
||||
if (stderr):
|
||||
@ -89,24 +91,25 @@ def occ (command:str, nc_www_user:str, nc_path:str, nc_php_version:str="", outpu
|
||||
return stdout.decode('utf-8')
|
||||
|
||||
def occ_check(name:str, conf:dict):
|
||||
|
||||
if 'docker_container' in conf.keys() and (conf['docker_container'] == None or conf['docker_container'] == ""):
|
||||
try:
|
||||
subprocess.run(["which sudo > /dev/null"], shell=True, check=True)
|
||||
except:
|
||||
print (f'2 "{name}" - Dependecy failed: Please install sudo')
|
||||
os._exit(1)
|
||||
|
||||
try:
|
||||
subprocess.run(["which sudo > /dev/null"], shell=True, check=True)
|
||||
except:
|
||||
print (f'2 "{name}" - Dependecy failed: Please install sudo')
|
||||
os._exit(1)
|
||||
try:
|
||||
subprocess.run([f"which php{conf['nc_php_version']} > /dev/null"], shell=True, check=True)
|
||||
except:
|
||||
print (f'2 "{name}" - Dependency failed: php{conf["nc_php_version"]} - Please check if php version is configured correctly in /etc/checkmk/nextcloud.conf')
|
||||
return False
|
||||
|
||||
try:
|
||||
subprocess.run([f"which php{conf['nc_php_version']} > /dev/null"], shell=True, check=True)
|
||||
except:
|
||||
print (f'2 "{name}" - Dependency failed: php{conf["nc_php_version"]} - Please check if php version is configured correctly in /etc/checkmk/nextcloud.conf')
|
||||
return False
|
||||
|
||||
try:
|
||||
subprocess.run([f"sudo -u {conf['nc_www_user']} php{conf['nc_php_version']} occ --quiet"], cwd=conf['nc_path'], shell=True, check=True)
|
||||
except:
|
||||
print (f'2 "{name}" - Dependency failed: Please check if nc_path is configured correctly in /etc/checkmk/nextcloud.conf')
|
||||
return False
|
||||
try:
|
||||
subprocess.run([f"sudo -u {conf['nc_www_user']} php{conf['nc_php_version']} occ --quiet"], cwd=conf['nc_path'], shell=True, check=True)
|
||||
except:
|
||||
print (f'2 "{name}" - Dependency failed: Please check if nc_path is configured correctly in /etc/checkmk/nextcloud.conf')
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user