Skip to content

Commit dc5fcb8

Browse files
authored
Refactor (#6548)
1 parent db86049 commit dc5fcb8

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

ct/nocodb.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,24 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
msg_info "Updating ${APP}"
31-
systemctl stop nocodb.service
32-
cd /opt/nocodb
33-
rm -rf nocodb
34-
curl -fsSL http://get.nocodb.com/linux-x64 -o nocodb -L
35-
chmod +x nocodb
36-
systemctl start nocodb.service
30+
31+
RELEASE=$(curl -fsSL https://api.github.com/repos/nocodb/nocodb/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
32+
if [[ ! -f ~/.nocodb ]] || [[ "${RELEASE}" != "$(cat ~/.nocodb)" ]]; then
33+
msg_info "Stopping Service"
34+
systemctl stop nocodb
35+
msg_ok "Stopped Service"
36+
37+
fetch_and_deploy_gh_release "nocodb" "nocodb/nocodb" "singlefile" "latest" "/opt/nocodb/" "Noco-linux-x64"
38+
39+
msg_info "Starting Service"
40+
systemctl start nocodb
41+
msg_ok "Started Service"
42+
3743
msg_ok "Updated Successfully"
38-
exit
44+
else
45+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
46+
fi
47+
exit
3948
}
4049

4150
start
@@ -45,4 +54,4 @@ description
4554
msg_ok "Completed Successfully!\n"
4655
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
4756
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
48-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/dashboard${CL}"
57+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/dashboard${CL}"

install/nocodb-install.sh

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

16-
msg_info "Installing NocoDB"
17-
mkdir -p /opt/nocodb
18-
cd /opt/nocodb
19-
curl -fsSL http://get.nocodb.com/linux-x64 -o nocodb -L
20-
chmod +x nocodb
21-
msg_ok "Installed NocoDB"
16+
fetch_and_deploy_gh_release "nocodb" "nocodb/nocodb" "singlefile" "latest" "/opt/nocodb/" "Noco-linux-x64"
2217

2318
msg_info "Creating Service"
24-
service_path="/etc/systemd/system/nocodb.service"
19+
cat <<EOF >/etc/systemd/system/nocodb.service
2520
echo "[Unit]
2621
Description=nocodb
2722
@@ -33,7 +28,8 @@ WorkingDirectory=/opt/nocodb
3328
ExecStart=/opt/nocodb/./nocodb
3429
3530
[Install]
36-
WantedBy=multi-user.target" >$service_path
31+
WantedBy=multi-user.target
32+
EOF
3733
systemctl enable -q --now nocodb
3834
msg_ok "Created Service"
3935

0 commit comments

Comments
 (0)