#!/bin/bash
set -euo pipefail
apt-get update
apt-get install -y python3
install -d -m 755 /opt/jws-example/site
cat > /opt/jws-example/site/index.html <<'HTML'
<!doctype html><html lang="ru"><meta charset="utf-8"><title>Мой сервер</title><h1>Приложение работает</h1></html>
HTML
cat > /etc/systemd/system/jws-example.service <<'UNIT'
[Unit]
Description=JWS example local website
After=network.target
[Service]
User=ubuntu
ExecStart=/usr/bin/python3 -m http.server 8080 --bind 127.0.0.1 --directory /opt/jws-example/site
Restart=on-failure
[Install]
WantedBy=multi-user.target
UNIT
systemctl daemon-reload
systemctl enable --now jws-example.service
