Skip to content

Commit 53beca3

Browse files
authored
Refactor (#6376)
1 parent 2701308 commit 53beca3

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

ct/kubo.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26-
if [[ ! -f /usr/local/kubo ]]; then
26+
if [[ ! -f /usr/local/kubo/ipfs ]]; then
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
RELEASE=$(curl -fsSL https://github.com/ipfs/kubo/releases/latest | grep "title>Release" | cut -d " " -f 4)
31-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
32-
msg_info "Updating $APP LXC"
33-
$STD apt-get update
34-
$STD apt-get -y upgrade
35-
curl -fsSL "https://github.com/ipfs/kubo/releases/download/${RELEASE}/kubo_${RELEASE}_linux-amd64.tar.gz" -o $(basename "https://github.com/ipfs/kubo/releases/download/${RELEASE}/kubo_${RELEASE}_linux-amd64.tar.gz")
36-
tar -xzf "kubo_${RELEASE}_linux-amd64.tar.gz" -C /usr/local
37-
systemctl restart ipfs.service
38-
echo "${RELEASE}" >/opt/${APP}_version.txt
39-
rm "kubo_${RELEASE}_linux-amd64.tar.gz"
40-
msg_ok "Updated $APP LXC"
30+
31+
RELEASE=$(curl -fsSL https://api.github.com/repos/ipfs/kubo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat ~/.kubo)" ]] || [[ ! -f ~/.kubo ]]; then
33+
msg_info "Stopping service"
34+
systemctl stop ipfs
35+
msg_ok "Stopped service"
36+
37+
fetch_and_deploy_gh_release "kubo" "ipfs/kubo" "prebuild" "latest" "/usr/local/kubo" "kubo*linux-amd64.tar.gz"
38+
39+
msg_info "Starting service"
40+
systemctl start ipfs
41+
msg_ok "Service started"
42+
43+
msg_ok "Updated successfuly"
4144
else
4245
msg_ok "No update required. ${APP} is already at ${RELEASE}"
4346
fi

install/kubo-install.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@ setting_up_container
1414
network_check
1515
update_os
1616

17-
msg_info "Installing IPFS"
18-
RELEASE=$(curl -fsSL https://github.com/ipfs/kubo/releases/latest | grep "title>Release" | cut -d " " -f 4)
19-
$STD curl -fsSL "https://github.com/ipfs/kubo/releases/download/${RELEASE}/kubo_${RELEASE}_linux-amd64.tar.gz" -o "kubo_${RELEASE}_linux-amd64.tar.gz"
20-
tar -xzf "kubo_${RELEASE}_linux-amd64.tar.gz" -C /usr/local
17+
fetch_and_deploy_gh_release "kubo" "ipfs/kubo" "prebuild" "latest" "/usr/local/kubo" "kubo*linux-amd64.tar.gz"
18+
19+
msg_info "Configuring IPFS"
2120
$STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs
2221
$STD ipfs init
2322
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
2423
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
2524
LXCIP=$(hostname -I | awk '{print $1}')
2625
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://${LXCIP}:5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\", \"http://0.0.0.0:5001\"]"
2726
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
28-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
29-
$STD rm "kubo_${RELEASE}_linux-amd64.tar.gz"
30-
msg_ok "Installed IPFS"
27+
msg_ok "Configured IPFS"
3128

3229
msg_info "Creating Service"
3330
cat <<EOF >/etc/systemd/system/ipfs.service
@@ -43,7 +40,7 @@ Environment=HOME=/root
4340
[Install]
4441
WantedBy=multi-user.target
4542
EOF
46-
systemctl enable --now -q ipfs.service
43+
systemctl enable -q --now ipfs
4744
msg_ok "Created Service"
4845

4946
motd_ssh

0 commit comments

Comments
 (0)