From ca46dd6c7703dd1ca374069d87ead72ada36f0ff Mon Sep 17 00:00:00 2001
From: CanbiZ <47820557+MickLesk@users.noreply.github.com>
Date: Fri, 13 Sep 2024 18:54:37 +0200
Subject: [PATCH] Fix install

---
 ct/tianji-install.sh | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/ct/tianji-install.sh b/ct/tianji-install.sh
index 44af3a96..770b2d63 100644
--- a/ct/tianji-install.sh
+++ b/ct/tianji-install.sh
@@ -16,11 +16,10 @@ network_check
 update_os
 
 msg_info "Installing Dependencies (Patience)"
-$STD apt-get install -y --no-install-recommends \
+$STD apt-get install -y \
   postgresql \
   build-essential \
   curl \
-  unzip \
   sudo \
   git \
   make \
@@ -45,16 +44,15 @@ msg_ok "Installed Node.js, pnpm & pm2"
 
 msg_info "Setup Tianji (Patience)"
 cd /opt
-RELEASE=$(wget -q https://github.com/msgbyte/tianji/releases/latest -O - | grep "title>Release" | cut -d " " -f 4)
-wget -q "https://github.com/msgbyte/tianji/archive/refs/tags/${RELEASE}.zip"
-unzip -q ${RELEASE}.zip
-CLEAN_RELEASE=$(echo $RELEASE | sed 's/^v//')
-mv tianji-${CLEAN_RELEASE} /opt/tianji
+RELEASE=$(curl -s https://api.github.com/repos/msgbyte/tianji/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
+wget -q "https://github.com/msgbyte/tianji/archive/refs/tags/v${RELEASE}.zip"
+unzip -q v${RELEASE}.zip
+mv tianji-${RELEASE} /opt/tianji
 cd tianji
 export NODE_OPTIONS=--max_old_space_size=4096
-echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
 $STD pnpm install
 $STD pnpm build
+echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
 msg_ok "Initial Setup complete"
 
 msg_info "Setting up Database"
@@ -99,6 +97,6 @@ customize
 
 msg_info "Cleaning up"
 rm -R /opt/${RELEASE}.zip
-$STD apt-get autoremove
-$STD apt-get autoclean
+$STD apt-get autoremove -y
+$STD apt-get autoclean -y
 msg_ok "Cleaned"