From 7edabf89cb65c95579157ed6f9c259d8e1bca99a Mon Sep 17 00:00:00 2001 From: ulmentflam Date: Wed, 26 Jun 2024 10:43:16 -0400 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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}')