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
 | 
					catch_errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function update_script() {
 | 
					function update_script() {
 | 
				
			||||||
    header_info
 | 
					  header_info
 | 
				
			||||||
    check_container_storage
 | 
					  check_container_storage
 | 
				
			||||||
    check_container_resources
 | 
					  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"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        msg_info "Updating ${APP} to ${RELEASE}"
 | 
					  if [[ ! -d /opt/bytestash ]]; then
 | 
				
			||||||
        temp_file=$(mktemp)
 | 
					    msg_error "No ${APP} Installation Found!"
 | 
				
			||||||
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
 | 
					 | 
				
			||||||
    exit
 | 
					    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
 | 
					start
 | 
				
			||||||
@@ -70,4 +70,4 @@ description
 | 
				
			|||||||
msg_ok "Completed Successfully!\n"
 | 
					msg_ok "Completed Successfully!\n"
 | 
				
			||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
 | 
					echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
 | 
				
			||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
 | 
					echo -e "${INFO}${YW} Access it using the following URL:${CL}"
 | 
				
			||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
 | 
					echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,22 +14,17 @@ network_check
 | 
				
			|||||||
update_os
 | 
					update_os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NODE_VERSION="22" setup_nodejs
 | 
					NODE_VERSION="22" setup_nodejs
 | 
				
			||||||
 | 
					fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Installing ByteStash"
 | 
					msg_info "Installing ByteStash"
 | 
				
			||||||
JWT_SECRET=$(openssl rand -base64 32 | tr -d '/+=')
 | 
					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
 | 
					cd /opt/bytestash/server
 | 
				
			||||||
$STD npm install
 | 
					$STD npm install
 | 
				
			||||||
cd /opt/bytestash/client
 | 
					cd /opt/bytestash/client
 | 
				
			||||||
$STD npm install
 | 
					$STD npm install
 | 
				
			||||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
 | 
					 | 
				
			||||||
msg_ok "Installed ByteStash"
 | 
					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"
 | 
					msg_info "Creating Service"
 | 
				
			||||||
cat <<EOF >/etc/systemd/system/bytestash-backend.service
 | 
					cat <<EOF >/etc/systemd/system/bytestash-backend.service
 | 
				
			||||||
@@ -73,7 +68,6 @@ motd_ssh
 | 
				
			|||||||
customize
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Cleaning up"
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
rm -f $temp_file
 | 
					 | 
				
			||||||
$STD apt-get -y autoremove
 | 
					$STD apt-get -y autoremove
 | 
				
			||||||
$STD apt-get -y autoclean
 | 
					$STD apt-get -y autoclean
 | 
				
			||||||
msg_ok "Cleaned"
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user