Refactor (#6376)
This commit is contained in:
parent
2701308b45
commit
53beca39e8
27
ct/kubo.sh
27
ct/kubo.sh
@ -23,21 +23,24 @@ function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
if [[ ! -f /usr/local/kubo ]]; then
|
||||
if [[ ! -f /usr/local/kubo/ipfs ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
RELEASE=$(curl -fsSL https://github.com/ipfs/kubo/releases/latest | grep "title>Release" | cut -d " " -f 4)
|
||||
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
||||
msg_info "Updating $APP LXC"
|
||||
$STD apt-get update
|
||||
$STD apt-get -y upgrade
|
||||
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")
|
||||
tar -xzf "kubo_${RELEASE}_linux-amd64.tar.gz" -C /usr/local
|
||||
systemctl restart ipfs.service
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
rm "kubo_${RELEASE}_linux-amd64.tar.gz"
|
||||
msg_ok "Updated $APP LXC"
|
||||
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/ipfs/kubo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
if [[ "${RELEASE}" != "$(cat ~/.kubo)" ]] || [[ ! -f ~/.kubo ]]; then
|
||||
msg_info "Stopping service"
|
||||
systemctl stop ipfs
|
||||
msg_ok "Stopped service"
|
||||
|
||||
fetch_and_deploy_gh_release "kubo" "ipfs/kubo" "prebuild" "latest" "/usr/local/kubo" "kubo*linux-amd64.tar.gz"
|
||||
|
||||
msg_info "Starting service"
|
||||
systemctl start ipfs
|
||||
msg_ok "Service started"
|
||||
|
||||
msg_ok "Updated successfuly"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||
fi
|
||||
|
@ -14,10 +14,9 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing IPFS"
|
||||
RELEASE=$(curl -fsSL https://github.com/ipfs/kubo/releases/latest | grep "title>Release" | cut -d " " -f 4)
|
||||
$STD curl -fsSL "https://github.com/ipfs/kubo/releases/download/${RELEASE}/kubo_${RELEASE}_linux-amd64.tar.gz" -o "kubo_${RELEASE}_linux-amd64.tar.gz"
|
||||
tar -xzf "kubo_${RELEASE}_linux-amd64.tar.gz" -C /usr/local
|
||||
fetch_and_deploy_gh_release "kubo" "ipfs/kubo" "prebuild" "latest" "/usr/local/kubo" "kubo*linux-amd64.tar.gz"
|
||||
|
||||
msg_info "Configuring IPFS"
|
||||
$STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs
|
||||
$STD ipfs init
|
||||
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
|
||||
@ -25,9 +24,7 @@ ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
|
||||
LXCIP=$(hostname -I | awk '{print $1}')
|
||||
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\"]"
|
||||
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
|
||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||
$STD rm "kubo_${RELEASE}_linux-amd64.tar.gz"
|
||||
msg_ok "Installed IPFS"
|
||||
msg_ok "Configured IPFS"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/ipfs.service
|
||||
@ -43,7 +40,7 @@ Environment=HOME=/root
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable --now -q ipfs.service
|
||||
systemctl enable -q --now ipfs
|
||||
msg_ok "Created Service"
|
||||
|
||||
motd_ssh
|
||||
|
Loading…
x
Reference in New Issue
Block a user