2024-11-21 22:25:59 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
2025-01-01 13:37:29 +01:00
|
|
|
# Copyright (c) 2021-2025 community-scripts ORG
|
2024-11-21 22:25:59 +01:00
|
|
|
# Author: MickLesk (Canbiz)
|
2024-12-16 12:42:51 +01:00
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
|
|
# Source: https://www.kimai.org/
|
2024-11-21 22:25:59 +01:00
|
|
|
|
|
|
|
APP="Kimai"
|
2024-12-18 08:52:27 +01:00
|
|
|
var_tags="time-tracking"
|
2024-11-21 22:25:59 +01:00
|
|
|
var_cpu="2"
|
|
|
|
var_ram="2048"
|
2024-12-16 12:42:51 +01:00
|
|
|
var_disk="7"
|
2024-11-21 22:25:59 +01:00
|
|
|
var_os="debian"
|
|
|
|
var_version="12"
|
2024-12-16 12:42:51 +01:00
|
|
|
var_unprivileged="1"
|
|
|
|
|
|
|
|
header_info "$APP"
|
2024-11-21 22:25:59 +01:00
|
|
|
variables
|
|
|
|
color
|
|
|
|
catch_errors
|
|
|
|
|
|
|
|
function update_script() {
|
2025-03-05 18:41:34 +01:00
|
|
|
header_info
|
|
|
|
check_container_storage
|
|
|
|
check_container_resources
|
|
|
|
if [[ ! -d /opt/kimai ]]; then
|
|
|
|
msg_error "No ${APP} Installation Found!"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
RELEASE=$(curl -s 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"
|
|
|
|
|
|
|
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
|
|
|
msg_info "Stopping Apache2"
|
|
|
|
systemctl stop apache2
|
|
|
|
msg_ok "Stopped Apache2"
|
2024-11-21 22:25:59 +01:00
|
|
|
|
2025-03-05 18:41:34 +01:00
|
|
|
msg_info "Backing up Kimai configuration and var directory"
|
|
|
|
mkdir -p "$BACKUP_DIR"
|
|
|
|
[ -d /opt/kimai/var ] && cp -r /opt/kimai/var "$BACKUP_DIR/"
|
|
|
|
[ -f /opt/kimai/.env ] && cp /opt/kimai/.env "$BACKUP_DIR/"
|
|
|
|
[ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml "$BACKUP_DIR/"
|
|
|
|
msg_ok "Backup completed"
|
2024-11-21 22:25:59 +01:00
|
|
|
|
2025-03-05 18:41:34 +01:00
|
|
|
msg_info "Updating ${APP} to ${RELEASE}"
|
|
|
|
rm -rf /opt/kimai
|
|
|
|
wget -q "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip"
|
|
|
|
unzip -q ${RELEASE}.zip
|
|
|
|
mv kimai-${RELEASE} /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/local.yaml" ] && cp "$BACKUP_DIR/local.yaml" /opt/kimai/config/packages/
|
|
|
|
rm -rf "$BACKUP_DIR"
|
|
|
|
cd /opt/kimai
|
|
|
|
$STD composer install --no-dev --optimize-autoloader
|
|
|
|
$STD bin/console kimai:update
|
|
|
|
chown -R :www-data .
|
|
|
|
chmod -R g+r .
|
|
|
|
chmod -R g+rw var/
|
|
|
|
chmod -R 777 /opt/kimai/var/
|
|
|
|
chown -R www-data:www-data /opt/kimai
|
|
|
|
chmod -R 755 /opt/kimai
|
|
|
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
|
|
msg_ok "Updated ${APP} to ${RELEASE}"
|
2024-11-21 22:25:59 +01:00
|
|
|
|
2025-03-05 18:41:34 +01:00
|
|
|
msg_info "Starting Apache2"
|
|
|
|
systemctl start apache2
|
|
|
|
msg_ok "Started Apache2"
|
|
|
|
|
|
|
|
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
|
|
|
|
exit
|
2024-11-21 22:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
start
|
|
|
|
build_container
|
|
|
|
description
|
|
|
|
|
|
|
|
msg_ok "Completed Successfully!\n"
|
2024-12-16 12:42:51 +01:00
|
|
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
|
|
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
2025-02-26 13:16:11 +01:00
|
|
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"
|