Best way to run occ CLI in NextCloud (Official)?

Using the commands pasted by someone else on the old forums, I came up with a script to help me run the NextCloud php occ CLI:


# Script to easily enter into the NextCloud shell

echo ""
echo "*******NOTE*******"
echo ""
echo "To run occ - once within the NextCloud instance shell, run:"
echo "su"
echo "su -m www-data -c 'php occ'"
echo ""

# e.g., ix-nextcloud

NEXTCLOUD_POD_NAME=$(k3s kubectl get -n $NEXTCLOUD_NAMESPACE --no-headers pods | grep -v -e "postgres" -e "cron" -e "redis" | cut -d ' ' -f1|tr '\n' ' ')


k3s kubectl exec -n $NEXTCLOUD_NAMESPACE --stdin --tty $NEXTCLOUD_POD_NAME -- /bin/bash

The script makes it easier, but it is overall still a bit annoying in my opinion… anyone else have anything cleaner?