#!/bin/bash run_as() { if [ "$(id -u)" = 0 ]; then su -p www-data -s /bin/sh -c "$1" else sh -c "$1" fi } run_as ' \ php occ app:list ' echo $?