podmanctl is going to use podman ay

This commit is contained in:
Andrew Hurley 2023-05-25 15:04:20 +08:00
parent dda4dd3f22
commit 01a37f9372
1 changed files with 16 additions and 17 deletions

View File

@ -98,8 +98,8 @@ stop-pod () {
systemctl stop podman-${PODNAME}.service || return 1
fi
else
if "${RUNTIME}" pod exists "${PODNAME}"; then
"${RUNTIME}" pod stop -t 70 "${PODNAME}" || return 2
if podman pod exists "${PODNAME}"; then
podman pod stop -t 70 "${PODNAME}" || return 2
fi
fi
}
@ -139,7 +139,7 @@ remove-services () {
# sub ----------------------------------------------------- install services
install-services () {
(cd "${SYSTEMD}" && \
"${RUNTIME}" generate systemd \
podman generate systemd \
--name \
--new \
--stop-timeout=70 \
@ -177,7 +177,7 @@ backup-volumes () {
fi
fi
printf ":: ${COMMAND} ${SERVER} - rsync ${SOURCE} to ${TARGET} commencing\n"
if "${RUNTIME}" run \
if podman run \
--rm \
--env "SOURCE_DIR=/source" \
--env "TARGET_DIR=/target" \
@ -203,7 +203,7 @@ save-images () {
for IMAGE in $IMAGES; do
OUT="${BACKDIR}/${WEEKDAY}$(basename $IMAGE)"
printf ":: ${COMMAND} ${SERVER} - saving image ${IMAGE} to ${OUT}\n"
if "${RUNTIME}" image save \
if podman image save \
--compress \
--format docker-dir \
--output "${OUT}" \
@ -227,7 +227,7 @@ save-backups () {
for VOLUME in $VOLUMES; do
OUT="${BACKDIR}/${WEEKDAY}${VOLUME}.tar"
printf ":: ${COMMAND} ${SERVER} - exporting volume ${VOLUME} to ${OUT}.\n" > /dev/null
if "${RUNTIME}" volume export \
if podman volume export \
--output "${OUT}" \
"${VOLUME}" > /dev/null; then
printf ":: ${COMMAND} ${SERVER} - exporting ${VOLUME} successful\n"
@ -252,15 +252,14 @@ save-backups () {
# --------------------------------------------------------- system top
SYSTEMT="$(realpath /srv)"
SYSTEMT="$(realpath ~/Server)"
if [[ ! -d "${SYSTEMT}" ]]; then
printf "Error: /srv directory missing\n"
printf "Error: ~/Server directory missing\n"
exit 1
fi
# --------------------------------------------------------- system runtime
RUNTIME="podman"
RUNTDIR="${SYSTEMT}/${RUNTIME}"
RUNTDIR="${SYSTEMT}/podman"
mkdir -p "${RUNTDIR}"
chmod 755 "${RUNTDIR}"
@ -285,7 +284,7 @@ done
# --------------------------------------------------------- rsync build
IMG="cor.cherished.me/system/helper-rsync"
if ! podman image exists ${IMG}; then
"${RUNTIME}" build \
podman build \
-t "${IMG}" \
"${BUILDIR}/github/weikinhuang/rsync-backup"
fi
@ -306,7 +305,7 @@ for SERVER in $*; do
printf ":: ${COMMAND} ${SERVER}\n"
# --------------------------------------------------------- network
"${RUNTIME}" network exists ${NETWORK} \
podman network exists ${NETWORK} \
|| podman network create ${NETWORK}
SUBNET="$(podman network inspect ${NETWORK} \
|grep -w "\"subnet\":" |sed 's/[\":,a-z,A-Z ]//g')"
@ -314,7 +313,7 @@ for SERVER in $*; do
#printf "${SUBNET_PREFIX}" > "${SERVER}-subnet"
# --------------------------------------------------------- proxy network
"${RUNTIME}" network exists proxy-net \
podman network exists proxy-net \
|| podman network create proxy-net
PROXY_SUBNET="$(podman network inspect proxy-net \
|grep -w "\"subnet\":" |sed 's/[\":,a-z,A-Z ]//g')"
@ -325,7 +324,7 @@ for SERVER in $*; do
(ps)
# --------------------------------------------------------- ps
${RUNTIME} ps -a --filter "pod=${PODNAME}" --format '{{.Names}}\t\t{{.Image}}\t\t{{.ExitCode}}\t\t{{.Status}}'
podman ps -a --filter "pod=${PODNAME}" --format '{{.Names}}\t\t{{.Image}}\t\t{{.ExitCode}}\t\t{{.Status}}'
;;
(create|run)
@ -350,12 +349,12 @@ for SERVER in $*; do
SPEC_HOSTS=""
SPEC_PUBLISH="--publish"
SPEC_ALIAS="--network-alias "
SPEC_BUILD="${RUNTIME} build ${PULL}"
SPEC_CREATE="${RUNTIME} create ${SPEC_POD} ${SPEC_LABELS} ${SPEC_ENV}"
SPEC_BUILD="podman build ${PULL}"
SPEC_CREATE="podman create ${SPEC_POD} ${SPEC_LABELS} ${SPEC_ENV}"
# --------------------------------------------------------- recreate pod
stop-pod
"${RUNTIME}" pod create \
podman pod create \
${SPEC_NAME}-pod \
${SPEC_INFRA_NAME} \
--replace