diff --git a/ct/koffan.sh b/ct/koffan.sh index 468422fd..fc768b37 100644 --- a/ct/koffan.sh +++ b/ct/koffan.sh @@ -6,13 +6,13 @@ source <(curl -s https://raw.githubusercontent.com/AminGholizad/ProxmoxVED/main/ # 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" +var_tags="${var_tags:-productivity}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-512}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables @@ -34,9 +34,9 @@ function update_script() { systemctl stop koffan msg_ok "Stopped Service" - msg_info "Creating Backup" - tar -czf /opt/koffan_backup_$(date +%F).tar.gz /opt/data/ - msg_ok "Backup Created" + msg_info "Backing up Data" + cp -r /opt/koffan/data /opt/koffan_data_backup 2>/dev/null || true + msg_ok "Backed up Data" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "koffan" "PanSalut/Koffan" @@ -45,6 +45,11 @@ function update_script() { go build -o koffan main.go msg_ok "Rebuild Completed" + msg_info "Restoring Data" + cp -r /opt/koffan_data_backup/. /opt/koffan/data/ 2>/dev/null || true + rm -rf /opt/koffan_data_backup + msg_ok "Restored Data" + msg_info "Starting Service" systemctl start koffan msg_ok "Started Service" diff --git a/install/koffan-install.sh b/install/koffan-install.sh index dcb9493c..80ae33bd 100644 --- a/install/koffan-install.sh +++ b/install/koffan-install.sh @@ -24,23 +24,23 @@ go build -o koffan main.go msg_ok "Building Completed" msg_info "Configuring Koffan" -mkdir /opt/data -cat </opt/data/.env +mkdir /opt/koffan/data +cat </opt/koffan/data/.env APP_ENV=production APP_PASSWORD=shopping123 PORT=3000 -DB_PATH=/opt/data/shopping.db +DB_PATH=/opt/koffan/data/shopping.db EOF msg_ok "Configuration Completed" -msg_info "Creating Service" +msg_info "Creating systemd service" cat </etc/systemd/system/koffan.service [Unit] Description=Koffan Service After=network.target [Service] -EnvironmentFile=/opt/data/.env +EnvironmentFile=/opt/koffan/data/.env WorkingDirectory=/opt/koffan ExecStart=/opt/koffan/koffan Restart=always @@ -48,9 +48,11 @@ Restart=always [Install] WantedBy=multi-user.target EOF -systemctl enable -q --now koffan -msg_ok "Created Service" +msg_ok "Service created" +msg_info "Finalizing Koffan installation" +systemctl enable -q --now koffan motd_ssh customize +msg_ok "Koffan installation complete" cleanup_lxc