From 9b954462115c6aaf82ebd407c4046267cee709fa Mon Sep 17 00:00:00 2001 From: amin Date: Wed, 20 May 2026 12:28:29 +0200 Subject: [PATCH] feat: add koffan --- ct/headers/koffan | 5 +++ ct/koffan.sh | 74 +++++++++++++++++++++++++++++++++++++++ install/koffan-install.sh | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 ct/headers/koffan create mode 100644 ct/koffan.sh create mode 100644 install/koffan-install.sh diff --git a/ct/headers/koffan b/ct/headers/koffan new file mode 100644 index 00000000..72cc1138 --- /dev/null +++ b/ct/headers/koffan @@ -0,0 +1,5 @@ + __ __ ________ + / //_/___ / __/ __/___ _____ + / ,< / __ \/ /_/ /_/ __ `/ __ \ + / /| / /_/ / __/ __/ /_/ / / / / +/_/ |_\____/_/ /_/ \__,_/_/ /_/ diff --git a/ct/koffan.sh b/ct/koffan.sh new file mode 100644 index 00000000..d94875c8 --- /dev/null +++ b/ct/koffan.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/AminGholizad/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Amin Gholizad +# License: MIT | https://github.com/AminGholizad/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/PanSalut/Koffan + +APP="Koffan" +var_tags="productivity" +var_cpu="1" +var_ram="512" +var_disk="4" +var_os="debian" +var_version="13" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/koffan/koffan ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -s https://api.github.com/repos/PanSalut/Koffan/releases/latest | grep "tag_name" | sed -E 's/[^0-9.]//g') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping $APP" + systemctl stop koffan.service + msg_ok "Stopped $APP" + + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/koffan/ + msg_ok "Backup Created" + + msg_info "Updating $APP to ${RELEASE}" + curl -fsSL "https://github.com/PanSalut/Koffan/archive/refs/tags/v${RELEASE}.tar.gz" | tar -xz + mv ${APP}-${RELEASE}/ /opt/koffan + cd /opt/koffan + go build -o $APP main.go + + msg_ok "Updated $APP to v${RELEASE}" + + msg_info "Starting $APP" + systemctl start $APP.service + msg_ok "Started $APP" + + msg_info "Cleaning Up" + # nothing to clean + msg_ok "Cleanup Completed" + + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + exit +} + +start +build_container +description + +msg_ok "Completed successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${INFO}${YW} The default password is: shopping123${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/koffan-install.sh b/install/koffan-install.sh new file mode 100644 index 00000000..cdf4fed8 --- /dev/null +++ b/install/koffan-install.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Amin Gholizad +# License: MIT | https://github.com/AminGholizad/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/PanSalut/Koffan + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + sudo \ + mc \ + golang-go +msg_ok "Installed Dependencies" + +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -s https://api.github.com/repos/PanSalut/Koffan/releases/latest | grep "tag_name" | sed -E 's/[^0-9.]//g') +curl -fsSL "https://github.com/PanSalut/Koffan/archive/refs/tags/v${RELEASE}.tar.gz" | tar -xz +mv ${APPLICATION}-${RELEASE}/ /opt/koffan +cd /opt/koffan +go build -o koffan main.go +cat </opt/.env +APP_ENV=production +APP_PASSWORD=shopping123 +PORT=3000 +EOF +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Setup ${APPLICATION}" + +msg_info "Creating Service" +cat </etc/systemd/system/${APPLICATION}.service +[Unit] +Description=${APPLICATION} Service +After=network.target + +[Service] +EnvironmentFile=/opt/.env +WorkingDirectory=/opt/koffan +ExecStart=/opt/koffan/koffan +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now ${APPLICATION}.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"