From 7edabf89cb65c95579157ed6f9c259d8e1bca99a Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 10:43:16 -0400 Subject: [PATCH 01/11] Basic IPFS kubo install --- ct/ipfs.sh | 75 +++++++++++++++++++++++++++++++++++++++++ install/ipfs-install.sh | 55 ++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 ct/ipfs.sh create mode 100644 install/ipfs-install.sh diff --git a/ct/ipfs.sh b/ct/ipfs.sh new file mode 100644 index 00000000..6063309b --- /dev/null +++ b/ct/ipfs.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: ulmentflam +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ________ ___________ + / _/ __ \/ ____/ ___/ + / // /_/ / /_ \__ \ + _/ // ____/ __/ ___/ / +/___/_/ /_/ /____/ +EOF +} +header_info +echo -e "Loading..." +APP="IPFS" +var_disk="4" +var_cpu="2" +var_ram="6144" +var_os="debian" +var_version="12" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /usr/local/kubo ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | grep "linux-amd64.tar.gz" | grep "browser_download_url" | head -n 1 | cut -d\" -f4)" +tar -xzf kubo*linux-amd64.tar.gz -C /usr/local +$STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs +rm -rf kubo*linux-amd64.tar.gz +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:5001/webui ${CL} \n" diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh new file mode 100644 index 00000000..6b3be6e0 --- /dev/null +++ b/install/ipfs-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: ulmentflam +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gpg +msg_ok "Installed Dependencies" + +msg_info "Installing IPFS" +wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | grep "linux-amd64.tar.gz" | grep "browser_download_url" | head -n 1 | cut -d\" -f4)" +tar -xzf kubo*linux-amd64.tar.gz -C /usr/local +$STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs +ipfs init +msg_ok "Installed IPFS" + +msg_info "Creating Service" +cat </etc/systemd/system/ipfs.service +[Unit] +Description=IPFS Daemon +After=syslog.target network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/ipfs daemon +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl -q daemon-reload +systemctl enable --now -q ipfs.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf kubo*linux-amd64.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" From 0072061aa0ee3e1dec238d40071bee76d2e8511b Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 12:15:41 -0400 Subject: [PATCH 02/11] Adding configs to the install script --- install/ipfs-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index 6b3be6e0..204155a7 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -26,6 +26,10 @@ wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | gr tar -xzf kubo*linux-amd64.tar.gz -C /usr/local $STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs ipfs init +ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 +ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 +ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://192.168.68.99: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"]' msg_ok "Installed IPFS" msg_info "Creating Service" From e053d47f6ee237e5addb72d17699d9069adf8068 Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 12:29:30 -0400 Subject: [PATCH 03/11] Updating IP address to not be static --- install/ipfs-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index 204155a7..09d3e2a0 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -28,7 +28,7 @@ $STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs ipfs init ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 -ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://192.168.68.99: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-Origin "[\"http://${IP}: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"]' msg_ok "Installed IPFS" From fd155ce89963a2e2dd58f7168918c128e930972e Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 12:49:50 -0400 Subject: [PATCH 04/11] Switching to pulling ips from the host --- install/ipfs-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index 09d3e2a0..bb377192 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -28,7 +28,7 @@ $STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs ipfs init ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 -ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://${IP}: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-Origin "[\"http:/$(hostname -I | awk '{print $1}'):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"]' msg_ok "Installed IPFS" From 441a96c956e780ecb607dc3b4cc898aa26276a79 Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 12:54:09 -0400 Subject: [PATCH 05/11] Changing host script --- install/ipfs-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index bb377192..205b2598 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -28,7 +28,8 @@ $STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs ipfs init ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 -ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http:/$(hostname -I | awk '{print $1}'):5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\", \"http://0.0.0.0:5001\"]" +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"]' msg_ok "Installed IPFS" From 252061b6275a67bfb48abf21c58d7ea5ddac77bf Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 13:02:27 -0400 Subject: [PATCH 06/11] Don't start IPFS, init startes the daemon --- install/ipfs-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index 205b2598..c79c4bdf 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -47,7 +47,7 @@ Restart=on-failure WantedBy=multi-user.target EOF systemctl -q daemon-reload -systemctl enable --now -q ipfs.service +systemctl enable -q ipfs.service msg_ok "Created Service" motd_ssh From a81c84a83509f3a1ebf140e927db2bc166a875b4 Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 13:19:15 -0400 Subject: [PATCH 07/11] Stupid /, typo --- install/ipfs-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index c79c4bdf..54360e99 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -29,7 +29,7 @@ ipfs init ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 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-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"]' msg_ok "Installed IPFS" @@ -47,7 +47,7 @@ Restart=on-failure WantedBy=multi-user.target EOF systemctl -q daemon-reload -systemctl enable -q ipfs.service +systemctl enable --now -q ipfs.service msg_ok "Created Service" motd_ssh From cb5963973700f9bf90a67275afb2cb7823bd7946 Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 13:32:10 -0400 Subject: [PATCH 08/11] No need to relink on update, just restart --- ct/ipfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/ipfs.sh b/ct/ipfs.sh index 6063309b..7a1270f2 100644 --- a/ct/ipfs.sh +++ b/ct/ipfs.sh @@ -60,8 +60,8 @@ apt-get update &>/dev/null apt-get -y upgrade &>/dev/null wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | grep "linux-amd64.tar.gz" | grep "browser_download_url" | head -n 1 | cut -d\" -f4)" tar -xzf kubo*linux-amd64.tar.gz -C /usr/local -$STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs rm -rf kubo*linux-amd64.tar.gz +systemctl restart ipfs.service msg_ok "Updated $APP LXC" exit } From d5ee52cc40882d817fd0eb0fec7f0b1f6de0821a Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 13:36:33 -0400 Subject: [PATCH 09/11] Piping output to dev null --- install/ipfs-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index 54360e99..b91c49ae 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -25,7 +25,7 @@ msg_info "Installing IPFS" wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | grep "linux-amd64.tar.gz" | grep "browser_download_url" | head -n 1 | cut -d\" -f4)" tar -xzf kubo*linux-amd64.tar.gz -C /usr/local $STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs -ipfs init +ipfs init &>/dev/null ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 LXCIP=$(hostname -I | awk '{print $1}') From b3b97c1b4ff2d20e56b0b203e3cd595e6ef29d6e Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 14:32:52 -0400 Subject: [PATCH 10/11] Resolving Review Comments --- ct/ipfs.sh | 24 +++++++++++++++--------- install/ipfs-install.sh | 11 ++++++----- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ct/ipfs.sh b/ct/ipfs.sh index 7a1270f2..26fe051f 100644 --- a/ct/ipfs.sh +++ b/ct/ipfs.sh @@ -21,7 +21,7 @@ echo -e "Loading..." APP="IPFS" var_disk="4" var_cpu="2" -var_ram="6144" +var_ram="4096" var_os="debian" var_version="12" variables @@ -55,14 +55,20 @@ function default_settings() { function update_script() { header_info if [[ ! -f /usr/local/kubo ]]; then msg_error "No ${APP} Installation Found!"; exit; fi -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | grep "linux-amd64.tar.gz" | grep "browser_download_url" | head -n 1 | cut -d\" -f4)" -tar -xzf kubo*linux-amd64.tar.gz -C /usr/local -rm -rf kubo*linux-amd64.tar.gz -systemctl restart ipfs.service -msg_ok "Updated $APP LXC" +RELEASE=$(wget -q https://github.com/ipfs/kubo/releases/latest -O - | 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" + apt-get update &>/dev/null + apt-get -y upgrade &>/dev/null + wget -q "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" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi exit } diff --git a/install/ipfs-install.sh b/install/ipfs-install.sh index b91c49ae..390674c1 100644 --- a/install/ipfs-install.sh +++ b/install/ipfs-install.sh @@ -22,15 +22,18 @@ $STD apt-get install -y gpg msg_ok "Installed Dependencies" msg_info "Installing IPFS" -wget -q "$(curl -s "https://api.github.com/repos/ipfs/kubo/releases/latest" | grep "linux-amd64.tar.gz" | grep "browser_download_url" | head -n 1 | cut -d\" -f4)" -tar -xzf kubo*linux-amd64.tar.gz -C /usr/local +RELEASE=$(wget -q https://github.com/ipfs/kubo/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +$STD wget -q "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 $STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs -ipfs init &>/dev/null +$STD ipfs init ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 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_info "Creating Service" @@ -46,7 +49,6 @@ Restart=on-failure [Install] WantedBy=multi-user.target EOF -systemctl -q daemon-reload systemctl enable --now -q ipfs.service msg_ok "Created Service" @@ -54,7 +56,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf kubo*linux-amd64.tar.gz $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned" From 536a96b65efb1843841f9035a418ea6b6550874f Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 21:13:02 -0400 Subject: [PATCH 11/11] Changing application name to Kubo --- ct/{ipfs.sh => kubo.sh} | 12 ++++++------ install/{ipfs-install.sh => kubo-install.sh} | 0 2 files changed, 6 insertions(+), 6 deletions(-) rename ct/{ipfs.sh => kubo.sh} (92%) rename install/{ipfs-install.sh => kubo-install.sh} (100%) diff --git a/ct/ipfs.sh b/ct/kubo.sh similarity index 92% rename from ct/ipfs.sh rename to ct/kubo.sh index 26fe051f..e792b791 100644 --- a/ct/ipfs.sh +++ b/ct/kubo.sh @@ -9,16 +9,16 @@ source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build function header_info { clear cat <<"EOF" - ________ ___________ - / _/ __ \/ ____/ ___/ - / // /_/ / /_ \__ \ - _/ // ____/ __/ ___/ / -/___/_/ /_/ /____/ + __ __ __ + / //_/_ __/ /_ ____ + / ,< / / / / __ \/ __ \ + / /| / /_/ / /_/ / /_/ / +/_/ |_\__,_/_.___/\____/ EOF } header_info echo -e "Loading..." -APP="IPFS" +APP="Kubo" var_disk="4" var_cpu="2" var_ram="4096" diff --git a/install/ipfs-install.sh b/install/kubo-install.sh similarity index 100% rename from install/ipfs-install.sh rename to install/kubo-install.sh