Skip to content

Commit a0e8ee2

Browse files
Refactor: OneDev (#9597)
* Refactor: OneDev * Update onedev.sh --------- Co-authored-by: Tobias <[email protected]>
1 parent e462aba commit a0e8ee2

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

ct/onedev.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,30 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
GITHUB_RELEASE=$(curl -fsSL https://api.github.com/repos/theonedev/onedev/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${GITHUB_RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
30+
31+
if check_for_gh_release "onedev" "theonedev/onedev"; then
32+
JAVA_VERSION="21" setup_java
33+
3234
msg_info "Stopping Service"
3335
systemctl stop onedev
3436
msg_ok "Stopped Service"
3537

36-
msg_info "Updating ${APP} to v${GITHUB_RELEASE}"
38+
msg_info "Updating OneDev"
3739
cd /opt
38-
curl -fsSL "https://code.onedev.io/onedev/server/~site/onedev-latest.tar.gz" -o $(basename "https://code.onedev.io/onedev/server/~site/onedev-latest.tar.gz")
40+
curl -fsSL "https://code.onedev.io/onedev/server/~site/onedev-latest.tar.gz" -o onedev-latest.tar.gz
3941
tar -xzf onedev-latest.tar.gz
4042
$STD /opt/onedev-latest/bin/upgrade.sh /opt/onedev
41-
RELEASE=$(cat /opt/onedev/release.properties | grep "version" | cut -d'=' -f2)
4243
rm -rf /opt/onedev-latest
4344
rm -rf /opt/onedev-latest.tar.gz
44-
echo "${RELEASE}" >"/opt/${APP}_version.txt"
45-
msg_ok "Updated ${APP} to v${RELEASE}"
45+
echo "${CHECK_UPDATE_RELEASE}" >~/.onedev
46+
msg_ok "Updated OneDev"
4647

4748
msg_info "Starting Service"
4849
systemctl start onedev
4950
msg_ok "Started Service"
5051
msg_ok "Updated successfully!"
51-
else
52-
msg_ok "No update required. ${APP} is already at v${RELEASE}."
52+
exit
5353
fi
54-
exit
5554
}
5655

5756
start

install/onedev-install.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@ update_os
1515

1616
msg_info "Installing Dependencies"
1717
$STD apt install -y \
18-
default-jdk \
1918
git \
2019
git-lfs
2120
msg_ok "Installed Dependencies"
2221

22+
JAVA_VERSION="21" setup_java
23+
2324
msg_info "Installing OneDev"
25+
RELEASE=$(curl -fsSL https://api.github.com/repos/theonedev/onedev/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
2426
cd /opt
25-
curl -fsSL "https://code.onedev.io/onedev/server/~site/onedev-latest.tar.gz" -o "/opt/onedev-latest.tar.gz"
27+
curl -fsSL "https://code.onedev.io/onedev/server/~site/onedev-latest.tar.gz" -o onedev-latest.tar.gz
2628
tar -xzf onedev-latest.tar.gz
2729
mv /opt/onedev-latest /opt/onedev
2830
$STD /opt/onedev/bin/server.sh install
2931
systemctl start onedev
30-
RELEASE=$(cat /opt/onedev/release.properties | grep "version" | cut -d'=' -f2)
3132
rm -rf /opt/onedev-latest.tar.gz
32-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
33+
echo "${RELEASE}" >~/.onedev
3334
msg_ok "Installed OneDev"
3435

3536
motd_ssh

0 commit comments

Comments
 (0)