#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive

apt-get update -qq
apt-get install -y -qq python3 nginx

mkdir -p /var/www/zhifufuke/data
chown -R root:root /var/www/zhifufuke

cp /var/www/zhifufuke/deploy/zhifufuke.service /etc/systemd/system/zhifufuke.service
cp /var/www/zhifufuke/deploy/nginx.conf /etc/nginx/sites-available/zhifufuke
ln -sf /etc/nginx/sites-available/zhifufuke /etc/nginx/sites-enabled/zhifufuke
rm -f /etc/nginx/sites-enabled/default

systemctl daemon-reload
systemctl enable zhifufuke
systemctl restart zhifufuke
nginx -t
systemctl restart nginx

echo "DEPLOY_OK"
