Skip to content

Commit b565048

Browse files
authored
Refactor (#5874)
1 parent 24eff9d commit b565048

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

ct/glance.sh

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,19 @@ function update_script() {
2828
msg_error "No ${APP} Installation Found!"
2929
exit
3030
fi
31-
3231
RELEASE=$(curl -fsSL https://api.github.com/repos/glanceapp/glance/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
33-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.glance 2>/dev/null)" ]] || [[ ! -f ~/.glance ]]; then
3433
msg_info "Stopping Service"
3534
systemctl stop glance
3635
msg_ok "Stopped Service"
3736

38-
msg_info "Updating ${APP} to v${RELEASE}"
39-
cd /opt
40-
curl -fsSL "https://github.com/glanceapp/glance/releases/download/v${RELEASE}/glance-linux-amd64.tar.gz" -o $(basename "https://github.com/glanceapp/glance/releases/download/v${RELEASE}/glance-linux-amd64.tar.gz")
41-
rm -rf /opt/glance/glance
42-
tar -xzf glance-linux-amd64.tar.gz -C /opt/glance
43-
echo "${RELEASE}" >"/opt/${APP}_version.txt"
44-
msg_ok "Updated ${APP} to v${RELEASE}"
37+
rm -f /opt/glance/glance
38+
fetch_and_deploy_gh_release "glance" "glanceapp/glance" "prebuild" "latest" "/opt/glance" "glance-linux-amd64.tar.gz"
4539

4640
msg_info "Starting Service"
4741
systemctl start glance
4842
msg_ok "Started Service"
4943

50-
msg_info "Cleaning up"
51-
rm -rf /opt/glance-linux-amd64.tar.gz
52-
msg_ok "Cleaned"
5344
msg_ok "Updated Successfully"
5445
else
5546
msg_ok "No update required. ${APP} is already at v${RELEASE}."

install/glance-install.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Glance"
17-
RELEASE=$(curl -fsSL https://api.github.com/repos/glanceapp/glance/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
18-
cd /opt
19-
curl -fsSL "https://github.com/glanceapp/glance/releases/download/v${RELEASE}/glance-linux-amd64.tar.gz" -o "glance-linux-amd64.tar.gz"
20-
mkdir -p /opt/glance
21-
tar -xzf glance-linux-amd64.tar.gz -C /opt/glance
16+
fetch_and_deploy_gh_release "glance" "glanceapp/glance" "prebuild" "latest" "/opt/glance" "glance-linux-amd64.tar.gz"
17+
18+
msg_info "Configuring Glance"
2219
cat <<EOF >/opt/glance/glance.yml
2320
pages:
2421
- name: Startpage
@@ -39,9 +36,7 @@ pages:
3936
- title: Helper Scripts
4037
url: https://github.com/community-scripts/ProxmoxVE
4138
EOF
42-
43-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
44-
msg_ok "Installed Glance"
39+
msg_ok "Configured Glance"
4540

4641
msg_info "Creating Service"
4742
service_path="/etc/systemd/system/glance.service"
@@ -67,7 +62,6 @@ motd_ssh
6762
customize
6863

6964
msg_info "Cleaning up"
70-
rm -rf /opt/glance-linux-amd64.tar.gz
7165
$STD apt-get -y autoremove
7266
$STD apt-get -y autoclean
7367
msg_ok "Cleaned"

0 commit comments

Comments
 (0)