mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	Refactor (#5725)
This commit is contained in:
		@@ -20,47 +20,47 @@ color
 | 
			
		||||
catch_errors
 | 
			
		||||
 | 
			
		||||
function update_script() {
 | 
			
		||||
    header_info
 | 
			
		||||
    check_container_storage
 | 
			
		||||
    check_container_resources
 | 
			
		||||
    if [[ ! -d /opt/bytestash ]]; then
 | 
			
		||||
        msg_error "No ${APP} Installation Found!"
 | 
			
		||||
        exit
 | 
			
		||||
    fi
 | 
			
		||||
    RELEASE=$(curl -fsSL https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
			
		||||
    if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
 | 
			
		||||
        msg_info "Stopping Services"
 | 
			
		||||
        systemctl stop bytestash-backend
 | 
			
		||||
        systemctl stop bytestash-frontend
 | 
			
		||||
        msg_ok "Services Stopped"
 | 
			
		||||
  header_info
 | 
			
		||||
  check_container_storage
 | 
			
		||||
  check_container_resources
 | 
			
		||||
 | 
			
		||||
        msg_info "Updating ${APP} to ${RELEASE}"
 | 
			
		||||
        temp_file=$(mktemp)
 | 
			
		||||
curl -fsSL "https://github.com/jordan-dalby/ByteStash/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
 | 
			
		||||
        tar zxf $temp_file
 | 
			
		||||
        rm -rf /opt/bytestash/server/node_modules
 | 
			
		||||
        rm -rf /opt/bytestash/client/node_modules
 | 
			
		||||
        cp -rf ByteStash-${RELEASE}/* /opt/bytestash
 | 
			
		||||
        cd /opt/bytestash/server
 | 
			
		||||
        $STD npm install
 | 
			
		||||
        cd /opt/bytestash/client
 | 
			
		||||
        $STD npm install
 | 
			
		||||
        echo "${RELEASE}" >/opt/${APP}_version.txt
 | 
			
		||||
        msg_ok "Updated ${APP}"
 | 
			
		||||
 | 
			
		||||
        msg_info "Starting Services"
 | 
			
		||||
        systemctl start bytestash-backend
 | 
			
		||||
        systemctl start bytestash-frontend
 | 
			
		||||
        msg_ok "Started Services"
 | 
			
		||||
 | 
			
		||||
        msg_info "Cleaning Up"
 | 
			
		||||
        rm -f $temp_file
 | 
			
		||||
        msg_ok "Cleaned"
 | 
			
		||||
        msg_ok "Updated Successfully"
 | 
			
		||||
    else
 | 
			
		||||
        msg_ok "No update required. ${APP} is already at ${RELEASE}"
 | 
			
		||||
    fi
 | 
			
		||||
  if [[ ! -d /opt/bytestash ]]; then
 | 
			
		||||
    msg_error "No ${APP} Installation Found!"
 | 
			
		||||
    exit
 | 
			
		||||
  fi
 | 
			
		||||
  RELEASE=$(curl -fsSL https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
			
		||||
  if [[ "${RELEASE}" != "$(cat ~/.bytestash 2>/dev/null)" ]] || [[ ! -f ~/.bytestash ]]; then
 | 
			
		||||
 | 
			
		||||
    read -rp "${TAB3}Did you make a backup via application WebUI? (y/n): " backuped
 | 
			
		||||
    if [[ "$backuped" =~ ^[Yy]$ ]]; then
 | 
			
		||||
      msg_info "Stopping Services"
 | 
			
		||||
      systemctl stop bytestash-backend
 | 
			
		||||
      systemctl stop bytestash-frontend
 | 
			
		||||
      msg_ok "Services Stopped"
 | 
			
		||||
 | 
			
		||||
      rm -rf /opt/bytestash
 | 
			
		||||
      fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash"
 | 
			
		||||
 | 
			
		||||
      msg_info "Configuring ByteStash"
 | 
			
		||||
      cd /opt/bytestash/server
 | 
			
		||||
      $STD npm install
 | 
			
		||||
      cd /opt/bytestash/client
 | 
			
		||||
      $STD npm install
 | 
			
		||||
      msg_ok "Updated ${APP}"
 | 
			
		||||
 | 
			
		||||
      msg_info "Starting Services"
 | 
			
		||||
      systemctl start bytestash-backend
 | 
			
		||||
      systemctl start bytestash-frontend
 | 
			
		||||
      msg_ok "Started Services"
 | 
			
		||||
    else
 | 
			
		||||
      msg_error "PLEASE MAKE A BACKUP FIRST!"
 | 
			
		||||
      exit
 | 
			
		||||
    fi
 | 
			
		||||
    msg_ok "Updated Successfully"
 | 
			
		||||
  else
 | 
			
		||||
    msg_ok "No update required. ${APP} is already at ${RELEASE}"
 | 
			
		||||
  fi
 | 
			
		||||
  exit
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
start
 | 
			
		||||
 
 | 
			
		||||
@@ -14,22 +14,17 @@ network_check
 | 
			
		||||
update_os
 | 
			
		||||
 | 
			
		||||
NODE_VERSION="22" setup_nodejs
 | 
			
		||||
fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash"
 | 
			
		||||
 | 
			
		||||
msg_info "Installing ByteStash"
 | 
			
		||||
JWT_SECRET=$(openssl rand -base64 32 | tr -d '/+=')
 | 
			
		||||
temp_file=$(mktemp)
 | 
			
		||||
RELEASE=$(curl -fsSL https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
			
		||||
curl -fsSL "https://github.com/jordan-dalby/ByteStash/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
 | 
			
		||||
tar zxf $temp_file
 | 
			
		||||
mv ByteStash-${RELEASE} /opt/bytestash
 | 
			
		||||
cd /opt/bytestash/server
 | 
			
		||||
$STD npm install
 | 
			
		||||
cd /opt/bytestash/client
 | 
			
		||||
$STD npm install
 | 
			
		||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
 | 
			
		||||
msg_ok "Installed ByteStash"
 | 
			
		||||
 | 
			
		||||
read -p "${TAB3}Do you want to allow registration of multiple accounts? [y/n]: " allowreg
 | 
			
		||||
read -rp "${TAB3}Do you want to allow registration of multiple accounts? [y/n]: " allowreg
 | 
			
		||||
 | 
			
		||||
msg_info "Creating Service"
 | 
			
		||||
cat <<EOF >/etc/systemd/system/bytestash-backend.service
 | 
			
		||||
@@ -73,7 +68,6 @@ motd_ssh
 | 
			
		||||
customize
 | 
			
		||||
 | 
			
		||||
msg_info "Cleaning up"
 | 
			
		||||
rm -f $temp_file
 | 
			
		||||
$STD apt-get -y autoremove
 | 
			
		||||
$STD apt-get -y autoclean
 | 
			
		||||
msg_ok "Cleaned"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user