Can now be installed to /opt and run as a openrc service

This commit is contained in:
2026-04-09 14:26:38 +03:00
parent 7f42c04977
commit 4f4fab9b26
5 changed files with 66 additions and 0 deletions

14
dyfi-openrc.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/sbin/openrc-run
log_file="/opt/dyfi/log"
command="/opt/dyfi/run.sh"
command_args="--log ${log_file} --auth /opt/dyfi/auth"
command_background=true
pidfile="/run/${RC_SVCNAME}.pid"
extra_commands="log"
log() {
cat "$log_file"
}

0
dyfi.py Normal file → Executable file
View File

32
install.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/env sh
dyfi_dir=$(dirname "$(realpath "$0")")
install_dir='/opt/dyfi/'
sudo -- sh -c "\
alias 'cp'='cp --verbose'; \
alias 'mkdir'='mkdir --verbose'; \
cd "$dyfi_dir"; \
mkdir -p /opt/dyfi; \
cp ./auth "$install_dir"; \
cp ./dyfi.py "$install_dir"; \
cp ./run.sh "$install_dir"; \
cp ./requirements.txt "$install_dir"; \
cp ./dyfi-openrc.sh /etc/init.d/dyfi; \
cd "$install_dir"; \
python -m venv ./venv; \
source ./venv/bin/activate; \
python -m ensurepip; \
pip install --upgrade pip; \
pip install -r ./requirements.txt; \
"
if [ $? != 0 ]; then
./uninstall.sh
fi

10
run.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/env sh
path=$(dirname "$(realpath "$0")")
cd $path
source ./venv/bin/activate
python ./dyfi.py $@

10
uninstall.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/env sh
install_dir=/opt/dyfi/
sudo -- sh -c "\
alias 'rm'='rm --verbose --preserve-root'; \
rm -rf ${install_dir}; \
rm -f /etc/init.d/dyfi; \
"