Added auto-updater, started to transfer Skript over, did the feather and freeze.

This commit is contained in:
wolf
2025-06-28 23:36:11 -04:00
parent d9967516b6
commit 0402d95f56
44 changed files with 1024 additions and 231 deletions

18
Uploader/build.gradle.kts Normal file
View File

@@ -0,0 +1,18 @@
plugins {
id("java")
}
group = "me.trouper"
version = "1.0.0"
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.mwiede:jsch:2.27.0")
}
tasks.test {
useJUnitPlatform()
}

View File

@@ -0,0 +1,89 @@
package me.trouper.uploader;
import com.jcraft.jsch.*;
import java.io.File;
import java.io.FileInputStream;
public class Uploader {
public static void main(String[] args) {
String sftpHost = "api.trouper.me";
int sftpPort = 689;
String sftpUser = "root";
String privateKeyPath = "/home/wolf/.ssh/deepfield_id_ed25519";
String localFile = "/run/media/wolf/1TB drive/IJ/IdeaProjects/CloneDupeCore/build/libs/CloneDupeCore-1.0.0-all.jar";
String remoteDir = "/home/cdn/files/plugins/CloneDupe/";
Session session = null;
ChannelSftp channelSftp = null;
try {
JSch jsch = new JSch();
jsch.addIdentity(privateKeyPath);
session = jsch.getSession(sftpUser, sftpHost, sftpPort);
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
File file = new File(localFile);
channelSftp.cd(remoteDir);
System.out.println("Uploading: " + file.getName());
channelSftp.put(
new FileInputStream(file),
file.getName(),
new ProgressMonitor(file.length()),
ChannelSftp.OVERWRITE
);
System.out.println("\nUpload successful!");
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (channelSftp != null) channelSftp.exit();
if (session != null) session.disconnect();
}
}
private static class ProgressMonitor implements SftpProgressMonitor {
private final long totalSize;
private long uploaded = 0;
private int lastPercent = -1;
public ProgressMonitor(long totalSize) {
this.totalSize = totalSize;
}
@Override
public void init(int op, String src, String dest, long max) {
System.out.println("Starting upload...");
}
@Override
public boolean count(long count) {
uploaded += count;
int percent = (int)((uploaded * 100) / totalSize);
if (percent != lastPercent) {
StringBuilder bar = new StringBuilder("\r[");
int progress = percent / 2;
for (int i = 0; i < 50; i++) {
bar.append(i < progress ? "=" : " ");
}
bar.append("] ").append(percent).append("%");
System.out.print(bar);
lastPercent = percent;
}
return true;
}
@Override
public void end() {
System.out.println("\nUpload complete.");
}
}
}