|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: Slaviša Arežina (tremor021) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/jordan-dalby/ByteStash |
| 7 | + |
| 8 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 9 | +color |
| 10 | +verb_ip6 |
| 11 | +catch_errors |
| 12 | +setting_up_container |
| 13 | +network_check |
| 14 | +update_os |
| 15 | + |
| 16 | +msg_info "Installing Dependencies" |
| 17 | +$STD apt-get install -y \ |
| 18 | + sudo \ |
| 19 | + curl \ |
| 20 | + mc \ |
| 21 | + gnupg |
| 22 | +msg_ok "Installed Dependencies" |
| 23 | + |
| 24 | +msg_info "Setting up Node.js Repository" |
| 25 | +mkdir -p /etc/apt/keyrings |
| 26 | +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 27 | +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list |
| 28 | +msg_ok "Set up Node.js Repository" |
| 29 | + |
| 30 | +msg_info "Installing Node.js" |
| 31 | +$STD apt-get update |
| 32 | +$STD apt-get install -y nodejs |
| 33 | +msg_ok "Installed Node.js" |
| 34 | + |
| 35 | +msg_info "Installing ByteStash" |
| 36 | +temp_file=$(mktemp) |
| 37 | +RELEASE=$(curl -s https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 38 | +wget -q "https://github.com/jordan-dalby/ByteStash/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file |
| 39 | +tar zxf $temp_file |
| 40 | +mv ByteStash-${RELEASE} /opt/bytestash |
| 41 | +cd /opt/bytestash/server |
| 42 | +$STD npm install |
| 43 | +cd /opt/bytestash/client |
| 44 | +$STD npm install |
| 45 | +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" |
| 46 | +msg_ok "Installed ByteStash" |
| 47 | + |
| 48 | +msg_info "Creating Service" |
| 49 | +cat <<EOF >/etc/systemd/system/bytestash-backend.service |
| 50 | +[Unit] |
| 51 | +Description=ByteStash Backend Service |
| 52 | +After=network.target |
| 53 | +
|
| 54 | +[Service] |
| 55 | +WorkingDirectory=/opt/bytestash/server |
| 56 | +ExecStart=/usr/bin/node src/app.js |
| 57 | +Restart=always |
| 58 | +
|
| 59 | +[Install] |
| 60 | +WantedBy=multi-user.target |
| 61 | +EOF |
| 62 | +cat <<EOF >/etc/systemd/system/bytestash-frontend.service |
| 63 | +[Unit] |
| 64 | +Description=ByteStash Frontend Service |
| 65 | +After=network.target bytestash-backend.service |
| 66 | +
|
| 67 | +[Service] |
| 68 | +WorkingDirectory=/opt/bytestash/client |
| 69 | +ExecStart=/usr/bin/npx vite --host |
| 70 | +Restart=always |
| 71 | +
|
| 72 | +[Install] |
| 73 | +WantedBy=multi-user.target |
| 74 | +EOF |
| 75 | +systemctl enable -q --now bytestash-backend |
| 76 | +systemctl enable -q --now bytestash-frontend |
| 77 | +msg_ok "Created Service" |
| 78 | + |
| 79 | +motd_ssh |
| 80 | +customize |
| 81 | + |
| 82 | +msg_info "Cleaning up" |
| 83 | +rm -f $temp_file |
| 84 | +$STD apt-get -y autoremove |
| 85 | +$STD apt-get -y autoclean |
| 86 | +msg_ok "Cleaned" |
0 commit comments