34 lines
1004 B
Bash
Executable File
34 lines
1004 B
Bash
Executable File
#!/bin/sh
|
|
|
|
WEB_CONTAINER="gentoo_binhost_server"
|
|
WEB_PORT="8080"
|
|
VOLUME_NAME="binpkgs"
|
|
|
|
podman volume inspect "$VOLUME_NAME" >/dev/null 2>&1 || podman volume create "$VOLUME_NAME"
|
|
|
|
if ! podman container exists "$WEB_CONTAINER"; then
|
|
echo "Creating Nginx binhost server on port $WEB_PORT..."
|
|
podman run -d \
|
|
--name "$WEB_CONTAINER" \
|
|
--restart always \
|
|
-p "$WEB_PORT":80 \
|
|
-v "$VOLUME_NAME":/usr/share/nginx/html:ro \
|
|
nginx:alpine \
|
|
/bin/sh -c '
|
|
echo "server {
|
|
listen 80;
|
|
root /usr/share/nginx/html;
|
|
location / {
|
|
autoindex on;
|
|
}
|
|
}" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'
|
|
else
|
|
if [ "$(podman container inspect -f '{{.State.Running}}' "$WEB_CONTAINER")" != "true" ]; then
|
|
echo "Starting existing server..."
|
|
podman start "$WEB_CONTAINER"
|
|
fi
|
|
fi
|
|
|
|
echo "Binhost serving at http://localhost:$WEB_PORT"
|
|
|