make container persistent
This commit is contained in:
28
serve.sh
Executable file
28
serve.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
WEB_CONTAINER="gentoo_binhost_server"
|
||||
WEB_PORT="8080"
|
||||
|
||||
echo "Checking Web Server..."
|
||||
|
||||
if ! podman container exists "$WEB_CONTAINER"; then
|
||||
echo "Starting Nginx binhost server on port $WEB_PORT..."
|
||||
|
||||
podman run -d \
|
||||
--name "$WEB_CONTAINER" \
|
||||
--restart always \
|
||||
-p "$WEB_PORT":80 \
|
||||
-v binpkgs:/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
|
||||
podman start "$WEB_CONTAINER" >/dev/null 2>&1
|
||||
echo "Server is running at http://localhost:$WEB_PORT"
|
||||
fi
|
||||
Reference in New Issue
Block a user