Skip to content

Commit

Permalink
chore: linux automatic updates working
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Feb 22, 2024
1 parent ca03144 commit d3e1065
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/extensionsIntegrated/appUpdater/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ define(function (require, exports, module) {
// as we are a single instance app, and there can be multiple phoenix windows that comes in and goes out,
// the updater lives in its own independent hidden window.
updaterWindow = new window.__TAURI__.window.WebviewWindow(TAURI_UPDATER_WINDOW_LABEL, {
url: "tauri-updater.html",
url: "tauri-updater.html?stage=" + Phoenix.config.environment,
title: "Desktop App Updater",
fullscreen: false,
resizable: false,
Expand Down Expand Up @@ -196,11 +196,11 @@ define(function (require, exports, module) {
}
const updateDetails = await getUpdateDetails();
if(updateFailed) {
(!isAutoUpdate) && Dialogs.showInfoDialog(Strings.UPDATE_FAILED_TITLE, Strings.UPDATE_FAILED_MESSAGE);
Dialogs.showInfoDialog(Strings.UPDATE_FAILED_TITLE, Strings.UPDATE_FAILED_MESSAGE);
return;
}
if(updatePendingRestart || updateDetails.updatePendingRestart){
(!isAutoUpdate) && Dialogs.showInfoDialog(Strings.UPDATE_READY_RESTART_TITLE, Strings.UPDATE_READY_RESTART_MESSAGE);
Dialogs.showInfoDialog(Strings.UPDATE_READY_RESTART_TITLE, Strings.UPDATE_READY_RESTART_MESSAGE);
return;
}
if(!updateDetails.shouldUpdate){
Expand Down Expand Up @@ -314,6 +314,7 @@ define(function (require, exports, module) {
console.log("Skipping update check: last update check was within one day");
return;
}
PreferencesManager.setViewState(KEY_LAST_UPDATE_CHECK_TIME, currentTime);
checkForUpdates(true);
});
});
17 changes: 15 additions & 2 deletions src/tauri-updater.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,23 @@
}
}

function getQueryStringParam(paramName) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
return urlParams.get(paramName);
}

async function updateLinux() {
try {
const command = new __TAURI__.shell.Command('run-update-linux-command',
['-e', 'wget -qO- https://updates.phcode.io/linux/installer.sh | bash -s -- --upgrade'])
const stageValue = getQueryStringParam('stage');
console.log('Stage:', stageValue);
let execCommand = 'wget -qO- https://updates.phcode.io/linux/installer.sh | bash -s -- --upgrade';
let runCommand = 'run-update-linux-command';
if(stageValue === 'dev' || stageValue === 'stage'){
runCommand = 'run-update-linux-command-dev';
execCommand = "wget -qO- https://updates.phcode.io/linux/installer-latest-experimental-build.sh | bash -s -- --upgrade";
}
const command = new __TAURI__.shell.Command(runCommand, ['-e', execCommand])
const result = await command.execute();
if(result.code !== 0){
status = UPDATE_STATUS.FAILED;
Expand Down

0 comments on commit d3e1065

Please sign in to comment.