remote: update to release feature
This commit is contained in:
parent
aecaa4d908
commit
441880453d
|
@ -26,12 +26,18 @@ public class Autoupdate {
|
|||
private static final String COM_RUSEFI_LAUNCHER = "com.rusefi.Launcher";
|
||||
|
||||
public static void main(String[] args) {
|
||||
String bundleFullName = readBundleFullName();
|
||||
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("release")) {
|
||||
handleBundle(bundleFullName, UpdateMode.ALWAYS, ConnectionAndMeta.BASE_URL_RELEASE);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateMode mode = getMode();
|
||||
if (mode != UpdateMode.NEVER) {
|
||||
String bundleFullName = readBundleFullName();
|
||||
if (bundleFullName != null) {
|
||||
System.out.println("Handling " + bundleFullName);
|
||||
handleBundle(bundleFullName, mode);
|
||||
handleBundle(bundleFullName, mode, ConnectionAndMeta.BASE_URL_LATEST);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Update mode: NEVER");
|
||||
|
@ -63,10 +69,10 @@ public class Autoupdate {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleBundle(String bundleFullName, UpdateMode mode) {
|
||||
private static void handleBundle(String bundleFullName, UpdateMode mode, String baseUrl) {
|
||||
try {
|
||||
String zipFileName = bundleFullName + "_autoupdate" + ".zip";
|
||||
ConnectionAndMeta connectionAndMeta = new ConnectionAndMeta(zipFileName).invoke();
|
||||
ConnectionAndMeta connectionAndMeta = new ConnectionAndMeta(zipFileName).invoke(baseUrl);
|
||||
System.out.println("Server has " + connectionAndMeta.getCompleteFileSize() + " from " + new Date(connectionAndMeta.getLastModified()));
|
||||
|
||||
if (AutoupdateUtil.hasExistingFile(zipFileName, connectionAndMeta.getCompleteFileSize(), connectionAndMeta.getLastModified())) {
|
||||
|
|
|
@ -10,9 +10,14 @@ do
|
|||
echo Exit code: ${exit_status}
|
||||
# in java code that's UPDATE_SBC_EXIT_CODE magic number
|
||||
if [ $exit_status -eq 15 ]; then
|
||||
echo Connector software update was requested
|
||||
echo Connector software update to latest was requested
|
||||
bin/update_bundle.sh
|
||||
fi
|
||||
# in java code that's UPDATE_RELEASE_SBC_EXIT_CODE magic number
|
||||
if [ $exit_status -eq 17 ]; then
|
||||
echo Connector software update to latest was requested
|
||||
bin/update_bundle_latest.sh
|
||||
fi
|
||||
# in java code that's UPDATE_FIRMWARE_EXIT_CODE magic number
|
||||
if [ $exit_status -eq 16 ]; then
|
||||
echo Firmware update was requested
|
||||
|
@ -20,4 +25,11 @@ do
|
|||
# todo: we need to start validating that SBC software matches board type, maybe update bundle type based on existing controller?
|
||||
bin/dfu_switch_and_program.sh
|
||||
fi
|
||||
# in java code that's UPDATE_RELEASE_FIRMWARE_EXIT_CODE magic number
|
||||
if [ $exit_status -eq 18 ]; then
|
||||
echo Firmware update was requested
|
||||
bin/update_bundle_latest.sh
|
||||
# todo: we need to start validating that SBC software matches board type, maybe update bundle type based on existing controller?
|
||||
bin/dfu_switch_and_program.sh
|
||||
fi
|
||||
done
|
|
@ -10,8 +10,9 @@ import static com.devexperts.logging.Logging.getLogging;
|
|||
public class NetworkConnectorContext {
|
||||
private static final Logging log = getLogging(NetworkConnectorContext.class);
|
||||
private static final int UPDATE_LATEST_SBC_EXIT_CODE = 15;
|
||||
public static final int UPDATE_FIRMWARE_EXIT_CODE = 16;
|
||||
public static final int UPDATE_LATEST_FIRMWARE_EXIT_CODE = 16;
|
||||
private static final int UPDATE_RELEASE_SBC_EXIT_CODE = 17;
|
||||
public static final int UPDATE_RELEASE_FIRMWARE_EXIT_CODE = 18;
|
||||
|
||||
public int reconnectDelay() {
|
||||
return 15; // this one is seconds
|
||||
|
@ -46,6 +47,6 @@ public class NetworkConnectorContext {
|
|||
|
||||
public void onFirmwareUpdateRequest() {
|
||||
log.info("onFirmwareUpdateRequest");
|
||||
System.exit(UPDATE_FIRMWARE_EXIT_CODE);
|
||||
System.exit(UPDATE_LATEST_FIRMWARE_EXIT_CODE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ import java.security.cert.X509Certificate;
|
|||
import java.util.Objects;
|
||||
|
||||
public class ConnectionAndMeta {
|
||||
public static final String BASE_URL_RELEASE = "https://github.com/rusefi/rusefi/releases/latest/download/";
|
||||
public static final String BASE_URL_LATEST = "https://rusefi.com/build_server/autoupdate/";
|
||||
|
||||
private static final int BUFFER_SIZE = 32 * 1024;
|
||||
public static final int STEPS = 1000;
|
||||
private String zipFileName;
|
||||
|
@ -68,12 +71,12 @@ public class ConnectionAndMeta {
|
|||
return lastModified;
|
||||
}
|
||||
|
||||
public ConnectionAndMeta invoke() throws IOException, NoSuchAlgorithmException, KeyManagementException {
|
||||
public ConnectionAndMeta invoke(String baseUrl) throws IOException, NoSuchAlgorithmException, KeyManagementException {
|
||||
// user can have java with expired certificates or funny proxy, we shall accept any certificate :(
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
ctx.init(new KeyManager[0], new TrustManager[]{new AcceptAnyCertificateTrustManager()}, new SecureRandom());
|
||||
|
||||
URL url = new URL("https://rusefi.com/build_server/autoupdate/" + zipFileName);
|
||||
URL url = new URL(baseUrl + zipFileName);
|
||||
httpConnection = (HttpsURLConnection) url.openConnection();
|
||||
httpConnection.setSSLSocketFactory(ctx.getSocketFactory());
|
||||
completeFileSize = httpConnection.getContentLength();
|
||||
|
|
Loading…
Reference in New Issue