tracktor: refactor envfile (#8711)

* tracktor: refactor enfile

* tracktor: fix: update links

* tracktor: add: mechanic to update envfile
This commit is contained in:
Tobias
2025-10-29 15:44:10 +01:00
committed by GitHub
parent ee02bc1977
commit cbc2ba1832
3 changed files with 39 additions and 8 deletions

View File

@@ -40,6 +40,29 @@ function update_script() {
sed -i 's|^EnvironmentFile=.*|EnvironmentFile=/opt/tracktor.env|' /etc/systemd/system/tracktor.service
systemctl daemon-reload
fi
if [ ! -d "/opt/tracktor-data/uploads" ]; then
mkdir -p /opt/tracktor-data/{uploads,logs}
EXISTING_AUTH_PIN=$(grep '^AUTH_PIN=' /opt/tracktor.env 2>/dev/null | cut -d'=' -f2)
AUTH_PIN=${EXISTING_AUTH_PIN:-123456}
cat <<EOF >/opt/tracktor.env
NODE_ENV=production
DB_PATH=/opt/tracktor-data/tracktor.db
UPLOADS_DIR="/opt/tracktor-data/uploads"
LOG_DIR="/opt/tracktor-data/logs"
# If server host is not set by default it will run on all interfaces - 0.0.0.0
# SERVER_HOST=""
SERVER_PORT=3000
# Set this if you want to secure your endpoints otherwise default will be "*"
CORS_ORIGINS="*"
# Set this if you are using backend and frontend separately.
# PUBLIC_API_BASE_URL=""
LOG_REQUESTS=true
LOG_LEVEL="info"
AUTH_PIN=${AUTH_PIN}
# PUBLIC_DEMO_MODE=false
# FORCE_DATA_SEED=false
EOF
fi
msg_ok "Corrected Services"
setup_nodejs

View File

@@ -9,9 +9,9 @@
"updateable": true,
"privileged": false,
"interface_port": 3000,
"documentation": "https://tracktor.bytedge.in/introduction.html",
"documentation": "https://github.com/javedh-dev/tracktor/tree/main/docs",
"config_path": "/opt/tracktor.env",
"website": "https://tracktor.bytedge.in/",
"website": "https://github.com/javedh-dev/tracktor",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/tracktor.webp",
"description": "Tracktor is an open-source web application for comprehensive vehicle management.\nEasily track fuel consumption, maintenance, insurance, and regulatory documents for all your vehicles in one place.",
"install_methods": [

View File

@@ -20,18 +20,26 @@ msg_info "Configuring Tracktor"
cd /opt/tracktor
$STD npm install
$STD npm run build
mkdir /opt/tracktor-data
mkdir -p /opt/tracktor-data/{uploads,logs}
HOST_IP=$(hostname -I | awk '{print $1}')
cat <<EOF >/opt/tracktor.env
NODE_ENV=production
PUBLIC_DEMO_MODE=false
DB_PATH=/opt/tracktor-data/tracktor.db
# Replace this URL if using behind reverse proxy for https traffic. Though it is optional and should work without changing
PUBLIC_API_BASE_URL=http://$HOST_IP:3000
# Here add the reverse proxy url as well to avoid cross errors from the app.
CORS_ORIGINS=http://$HOST_IP:3000
UPLOADS_DIR="/opt/tracktor-data/uploads"
LOG_DIR="/opt/tracktor-data/logs"
# If server host is not set by default it will run on all interfaces - 0.0.0.0
# SERVER_HOST=""
SERVER_PORT=3000
PORT=3000
# Set this if you want to secure your endpoints otherwise default will be "*"
# CORS_ORIGINS="*"
# Set this if you are using backend and frontend separately. For lxc installation this is not needed
# PUBLIC_API_BASE_URL=""
LOG_REQUESTS=true
LOG_LEVEL="info"
AUTH_PIN=123456
# PUBLIC_DEMO_MODE=false
# FORCE_DATA_SEED=false
EOF
msg_ok "Configured Tracktor"