From 3b00c160ae439a1b86ed98622b298145f2b42c8f Mon Sep 17 00:00:00 2001 From: cdhigh Date: Sun, 7 Jul 2024 11:47:59 -0300 Subject: [PATCH] 3.1.5 --- docker/Dockerfile | 5 +++-- docker/run_docker.sh | 18 ++++++++++++++++- main.py | 2 +- tools/serv00_deploy.sh | 44 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 tools/serv00_deploy.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 923c8826..3c43dd60 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -26,15 +26,16 @@ RUN mkdir -p /usr/kindleear /data WORKDIR /usr/kindleear COPY --from=builder /usr/kindleear/config.py /usr/kindleear/requirements.txt ./ COPY --from=builder /usr/kindleear/tools/mp3cat /usr/local/bin/mp3cat +COPY ./docker/run_docker.sh /usr/local/bin/run_docker.sh COPY ./docker/gunicorn.conf.py ./main.py ./ #apk add libstdc++ && \ RUN pip install --upgrade pip && \ pip install --no-cache-dir -r requirements.txt && \ - chmod +x /usr/local/bin/mp3cat + chmod +x /usr/local/bin/mp3cat /usr/local/bin/run_docker.sh COPY ./application/ ./application/ EXPOSE 8000 -CMD ["/usr/local/bin/gunicorn", "-c", "/usr/kindleear/gunicorn.conf.py", "main:app"] +CMD ["/usr/local/bin/run_docker.sh"] diff --git a/docker/run_docker.sh b/docker/run_docker.sh index ec55f443..d44390bb 100644 --- a/docker/run_docker.sh +++ b/docker/run_docker.sh @@ -1 +1,17 @@ -sudo docker run -d -p 80:8000 -v /data:/data --restart always kindleear/kindleear +#!/bin/sh + +if command -v hexdump > /dev/null 2>&1; then + export SECRET_KEY=$(hexdump -n 12 -v -e '/1 "%02x"' /dev/urandom) +elif command -v od > /dev/null 2>&1; then + export SECRET_KEY=$(od -N 12 -A n -t x1 /dev/urandom | tr -d ' \n') +elif command -v xxd > /dev/null 2>&1; then + export SECRET_KEY=$(xxd -l 12 -p /dev/urandom) +else + echo "No command found for SECRET_KEY, using default." +fi + +if [ -z "$TZ" ]; then + export TZ=Etc/GMT+0 +fi + +exec /usr/local/bin/gunicorn -c /usr/kindleear/gunicorn.conf.py main:app diff --git a/main.py b/main.py index db465b6c..a1d988d5 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ # Visit for the latest version # Author: cdhigh -__Version__ = '3.1.4' +__Version__ = '3.1.5' import os, sys, builtins, logging from application.lib import clogging diff --git a/tools/serv00_deploy.sh b/tools/serv00_deploy.sh new file mode 100644 index 00000000..b62f026b --- /dev/null +++ b/tools/serv00_deploy.sh @@ -0,0 +1,44 @@ +#!/bin/bash +echo "" +read -p "Please input your serv00 id: " SERV00_USER +if [ -z "$SERV00_USER" ]; then + echo "Error: Project ID cannot be empty." + exit 1 +fi + +DOMAIN="${SERV00_USER}.serv00.net" +VENV_DIR="/usr/home/${SERV00_USER}/.virtualenvs" +SITE_DIR="/usr/home/${SERV00_USER}/domains/${DOMAIN}/public_python" +export SERV00_USER +export VENV_DIR +export SITE_DIR + +echo "Creating virtual env..." +mkdir $VENV_DIR +cd $VENV_DIR +virtualenv ke +source ${VENV_DIR}/ke/bin/activate + +#split into small batches to avoid serv00 memory limit +pip install lxml~=5.2.0 #failed +pip install requests~=2.32.0 chardet~=5.2.0 pillow~=10.3.0 lxml_html_clean~=0.1.1 +pip install sendgrid~=6.11.0 mailjet_rest~=1.3.4 python-dateutil~=2.9.0 css_parser~=1.0.10 +pip install beautifulsoup4~=4.12.2 html2text~=2024.2.26 html5lib~=1.1 Flask~=3.0.3 flask-babel~=4.0.0 +pip install six~=1.16.0 feedparser~=6.0.11 qrcode~=7.4.2 gtts~=2.5.1 edge-tts~=6.1.11 justext~=3.0.1 +pip install peewee~=3.17.1 flask-apscheduler~=1.13.1 marisa_trie~=1.2.0 indexed-gzip~=1.8.7 +wget https://github.com/cdhigh/chunspell/releases/download/2.0.4/chunspell-2.0.4-freebsd-amd64.zip +unzip -y -d ./chunspell_whl/ chunspell-2.0.4-freebsd-amd64.zip +pip install chunspell --no-index --find-links=./chunspell_whl/. +rm -rf ./chunspell_whl + +devil www add $DOMAIN python ${VENV_DIR}/ke/bin/python production +cd ${SITE_DIR} +echo "import sys, os\nsys.path.append(os.getcwd())\nfrom kindleear import app as application" > ${SITE_DIR}/passenger_wsgi.py +rm -f ${SITE_DIR}/public/index.html +rm -rf ${SITE_DIR}/kindleear +git clone --depth 1 https://github.com/cdhigh/kindleear.git + +#TODO: change config.py +#TODO: add cron + +devil www restart $DOMAIN