Update check-nextcloud

This commit is contained in:
Thorsten Spille 2022-01-31 00:02:14 +01:00 committed by GitHub
parent aaf5764f6a
commit 7df0b538f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):
@ -90,6 +92,7 @@ def occ (command:str, nc_www_user:str, nc_path:str, nc_php_version:str="", outpu
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: