Skip to content

Instantly share code, notes, and snippets.

@toriato
Last active October 20, 2024 03:41
Show Gist options
  • Save toriato/8c54e33e6538e99aee63ce590af209ff to your computer and use it in GitHub Desktop.
Save toriato/8c54e33e6538e99aee63ce590af209ff to your computer and use it in GitHub Desktop.
podman exec macro for quadlet containers
#!/bin/sh
# simple podman exec macro for quadlet containers
# locate this script into ~/.profile
# $ crontab -l
# */5 * * * * . ~/.profile && XDG_RUNTIME_DIR="/run/user/$(id -u)" nextcloud_cron
# 0 * * * * . ~/.profile && XDG_RUNTIME_DIR="/run/user/$(id -u)" nextcloud_occ files:scan --path=user/files
quadlet () {
local container=$1
if [ -z "$container" ]; then
echo 'container name is required'
return 1
fi
shift
if ! podman container exists "systemd-${container}"; then
echo 'unable to exec from invalid container'
return 1
fi
if ! systemctl --user is-active --quiet "$container"; then
echo 'unable to exec from inactive container'
return 1
fi
podman exec "systemd-${container}" "$@"
}
php () {
quadlet php-fpm php "$@"
}
nextcloud_occ () {
php /path/to/nextcloud/occ "$@"
}
nextcloud_cron () {
php /path/to/nextcloud/cron.php "$@"
}
nextcloud_updater () {
php /path/to/nextcloud/updater/updater.phar "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment