Compare commits

..

3 Commits

Author SHA1 Message Date
Tobias
7bce8fe55b tracktor: add: mechanic to update envfile 2025-10-29 10:52:00 +01:00
Tobias
3f08fa9435 tracktor: fix: update links 2025-10-29 10:50:25 +01:00
Tobias
7170563271 tracktor: refactor enfile 2025-10-29 10:45:31 +01:00
8 changed files with 121 additions and 44 deletions

View File

@@ -24,9 +24,12 @@ function update_script() {
check_container_storage check_container_storage
check_container_resources check_container_resources
if ! dpkg-query -W -f='${Status}' mariadb-server 2>/dev/null | grep -q "install ok installed"; then
setup_mysql
fi
NODE_VERSION="22" setup_nodejs NODE_VERSION="22" setup_nodejs
msg_info "Updating Ghost" msg_info "Updating ${APP} LXC"
if command -v ghost &>/dev/null; then if command -v ghost &>/dev/null; then
current_version=$(ghost version | grep 'Ghost-CLI version' | awk '{print $3}') current_version=$(ghost version | grep 'Ghost-CLI version' | awk '{print $3}')
latest_version=$(npm show ghost-cli version) latest_version=$(npm show ghost-cli version)

View File

@@ -23,21 +23,32 @@ function update_script() {
header_info header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if ! command -v lsb_release; then
apt install -y lsb-release
fi
if [[ ! -d /opt/kimai ]]; then if [[ ! -d /opt/kimai ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2) CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
if [[ "$CURRENT_PHP" != "8.4" ]]; then if [[ "$CURRENT_PHP" != "8.4" ]]; then
msg_info "Migrating PHP $CURRENT_PHP to 8.4" msg_info "Migrating PHP $CURRENT_PHP to 8.4"
PHP_VERSION="8.4" PHP_MODULE="gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm" PHP_APACHE="YES" setup_php $STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
$STD sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
$STD apt-get update
$STD apt-get remove -y php"${CURRENT_PHP//./}"*
$STD apt-get install -y \
php8.4 composer \
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm} \
libapache2-mod-php8.4
msg_ok "Migrated PHP $CURRENT_PHP to 8.4" msg_ok "Migrated PHP $CURRENT_PHP to 8.4"
fi fi
if check_for_gh_release "Kimai" "kimai/kimai"; then RELEASE=$(curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
BACKUP_DIR="/opt/kimai_backup" BACKUP_DIR="/opt/kimai_backup"
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping Apache2" msg_info "Stopping Apache2"
systemctl stop apache2 systemctl stop apache2
msg_ok "Stopped Apache2" msg_ok "Stopped Apache2"
@@ -49,9 +60,15 @@ function update_script() {
[ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml "$BACKUP_DIR/" [ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml "$BACKUP_DIR/"
msg_ok "Backup completed" msg_ok "Backup completed"
fetch_and_deploy_gh_release "Kimai" "kimai/kimai" "prebuild" "latest" "/opt/kimai" "kimai-release-*.zip" msg_info "Updating ${APP} to ${RELEASE}"
trap "echo Unable to download release file for version ${RELEASE}; try again later" ERR
msg_info "Updating Kimai" set -e
curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip")
$STD unzip "${RELEASE}".zip
set +e
trap - ERR
rm -rf /opt/kimai
mv kimai-"${RELEASE}" /opt/kimai
[ -d "$BACKUP_DIR/var" ] && cp -r "$BACKUP_DIR/var" /opt/kimai/ [ -d "$BACKUP_DIR/var" ] && cp -r "$BACKUP_DIR/var" /opt/kimai/
[ -f "$BACKUP_DIR/.env" ] && cp "$BACKUP_DIR/.env" /opt/kimai/ [ -f "$BACKUP_DIR/.env" ] && cp "$BACKUP_DIR/.env" /opt/kimai/
[ -f "$BACKUP_DIR/local.yaml" ] && cp "$BACKUP_DIR/local.yaml" /opt/kimai/config/packages/ [ -f "$BACKUP_DIR/local.yaml" ] && cp "$BACKUP_DIR/local.yaml" /opt/kimai/config/packages/
@@ -59,7 +76,8 @@ function update_script() {
cd /opt/kimai cd /opt/kimai
$STD composer install --no-dev --optimize-autoloader $STD composer install --no-dev --optimize-autoloader
$STD bin/console kimai:update $STD bin/console kimai:update
msg_ok "Updated Kimai" echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to ${RELEASE}"
msg_info "Starting Apache2" msg_info "Starting Apache2"
systemctl start apache2 systemctl start apache2
@@ -72,7 +90,14 @@ function update_script() {
chown -R www-data:www-data /opt/* chown -R www-data:www-data /opt/*
chmod -R 777 /opt/* chmod -R 777 /opt/*
msg_ok "Setup Permissions" msg_ok "Setup Permissions"
msg_ok "Updated Successfully!"
msg_info "Cleaning Up"
rm -rf "${RELEASE}".zip
rm -rf "$BACKUP_DIR"
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi fi
exit exit
} }

View File

@@ -40,6 +40,29 @@ function update_script() {
sed -i 's|^EnvironmentFile=.*|EnvironmentFile=/opt/tracktor.env|' /etc/systemd/system/tracktor.service sed -i 's|^EnvironmentFile=.*|EnvironmentFile=/opt/tracktor.env|' /etc/systemd/system/tracktor.service
systemctl daemon-reload systemctl daemon-reload
fi 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" msg_ok "Corrected Services"
setup_nodejs setup_nodejs

View File

@@ -9,9 +9,9 @@
"updateable": true, "updateable": true,
"privileged": false, "privileged": false,
"interface_port": 3000, "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", "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", "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.", "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": [ "install_methods": [

View File

@@ -20,22 +20,22 @@ $STD apt-get install -y \
libjemalloc2 libjemalloc2
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_mariadb setup_mysql
msg_info "Configuring Database" msg_info "Configuring Database"
DB_NAME=ghost DB_NAME=ghost
DB_USER=ghostuser DB_USER=ghostuser
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" $STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" $STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" $STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{ {
echo "Ghost-Credentials" echo "Ghost-Credentials"
echo "Ghost Database User: $DB_USER" echo "Ghost Database User: $DB_USER"
echo "Ghost Database Password: $DB_PASS" echo "Ghost Database Password: $DB_PASS"
echo "Ghost Database Name: $DB_NAME" echo "Ghost Database Name: $DB_NAME"
} >>~/ghost.creds } >>~/ghost.creds
msg_ok "Configured MariaDB" msg_ok "Configured MySQL"
NODE_VERSION="22" setup_nodejs NODE_VERSION="22" setup_nodejs
@@ -60,5 +60,4 @@ customize
msg_info "Cleaning up" msg_info "Cleaning up"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
$STD apt-get -y clean
msg_ok "Cleaned" msg_ok "Cleaned"

View File

@@ -18,21 +18,36 @@ $STD apt-get install -y \
apt-transport-https \ apt-transport-https \
apache2 \ apache2 \
git \ git \
expect expect \
composer \
lsb-release
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_mariadb setup_mysql
PHP_VERSION="8.4" PHP_MODULE="gd,mysql,mbstring,bcmath,xml,curl,zip,intl" PHP_APACHE="YES" setup_php
setup_composer msg_info "Adding PHP8.4 Repository"
$STD curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
$STD sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
$STD apt-get update
msg_ok "Added PHP8.4 Repository"
msg_info "Installing PHP"
$STD apt-get remove -y php8.2*
$STD apt-get install -y \
php8.4 \
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl} \
libapache2-mod-php8.4
msg_ok "Installed PHP"
msg_info "Setting up database" msg_info "Setting up database"
DB_NAME=kimai_db DB_NAME=kimai_db
DB_USER=kimai DB_USER=kimai
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
MYSQL_VERSION=$(mariadb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') MYSQL_VERSION=$(mysql --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" $STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" $STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" $STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{ {
echo "Kimai-Credentials" echo "Kimai-Credentials"
echo "Kimai Database User: $DB_USER" echo "Kimai Database User: $DB_USER"
@@ -41,9 +56,11 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS
} >>~/kimai.creds } >>~/kimai.creds
msg_ok "Set up database" msg_ok "Set up database"
fetch_and_deploy_gh_release "Kimai" "kimai/kimai" "prebuild" "latest" "/opt/kimai" "kimai-release-*.zip" msg_info "Installing Kimai (Patience)"
RELEASE=$(curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
msg_info "Installing Kimai" curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o "${RELEASE}".zip
$STD unzip "${RELEASE}".zip
mv kimai-"${RELEASE}" /opt/kimai
cd /opt/kimai cd /opt/kimai
echo "export COMPOSER_ALLOW_SUPERUSER=1" >>~/.bashrc echo "export COMPOSER_ALLOW_SUPERUSER=1" >>~/.bashrc
source ~/.bashrc source ~/.bashrc
@@ -75,6 +92,8 @@ admin_lte:
options: options:
default_avatar: build/apple-touch-icon.png default_avatar: build/apple-touch-icon.png
EOF EOF
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed Kimai" msg_ok "Installed Kimai"
msg_info "Creating Service" msg_info "Creating Service"
@@ -111,7 +130,7 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
$STD apt -y autoremove rm -rf "${RELEASE}".zip
$STD apt -y autoclean $STD apt-get -y autoremove
$STD apt -y clean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"

View File

@@ -14,19 +14,19 @@ network_check
update_os update_os
msg_info "Installing dependencies" msg_info "Installing dependencies"
$STD apt install -y build-essential $STD apt install --no-install-recommends -y build-essential
msg_ok "Installed dependencies" msg_ok "Installed dependencies"
NODE_VERSION="22" setup_nodejs NODE_VERSION="22" setup_nodejs
setup_mariadb MYSQL_VERSION="8.0" setup_mysql
msg_info "Setting up Database" msg_info "Setting up Database"
DB_NAME="mmdl" DB_NAME="mmdl"
DB_USER="mmdl" DB_USER="mmdl"
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" $STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';" $STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';"
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" $STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{ {
echo "Manage My Damn Life Credentials" echo "Manage My Damn Life Credentials"
echo "Database User: $DB_USER" echo "Database User: $DB_USER"
@@ -59,7 +59,7 @@ msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/mmdl.service cat <<EOF >/etc/systemd/system/mmdl.service
[Unit] [Unit]
Description=${APPLICATION} Service Description=${APPLICATION} Service
After=network.target mariadb.service After=network.target mysql.service
[Service] [Service]
WorkingDirectory=/opt/mmdl WorkingDirectory=/opt/mmdl

View File

@@ -20,18 +20,26 @@ msg_info "Configuring Tracktor"
cd /opt/tracktor cd /opt/tracktor
$STD npm install $STD npm install
$STD npm run build $STD npm run build
mkdir /opt/tracktor-data mkdir -p /opt/tracktor-data/{uploads,logs}
HOST_IP=$(hostname -I | awk '{print $1}') HOST_IP=$(hostname -I | awk '{print $1}')
cat <<EOF >/opt/tracktor.env cat <<EOF >/opt/tracktor.env
NODE_ENV=production NODE_ENV=production
PUBLIC_DEMO_MODE=false
DB_PATH=/opt/tracktor-data/tracktor.db 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 UPLOADS_DIR="/opt/tracktor-data/uploads"
PUBLIC_API_BASE_URL=http://$HOST_IP:3000 LOG_DIR="/opt/tracktor-data/logs"
# Here add the reverse proxy url as well to avoid cross errors from the app. # If server host is not set by default it will run on all interfaces - 0.0.0.0
CORS_ORIGINS=http://$HOST_IP:3000 # SERVER_HOST=""
SERVER_PORT=3000
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 AUTH_PIN=123456
# PUBLIC_DEMO_MODE=false
# FORCE_DATA_SEED=false
EOF EOF
msg_ok "Configured Tracktor" msg_ok "Configured Tracktor"