Skip to content

Commit

Permalink
feat: auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-AshishRanjan committed Jan 18, 2024
1 parent f69276f commit b131f04
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
31 changes: 30 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"dependencies": {
"electron-settings": "^4.0.2",
"electron-squirrel-startup": "^1.0.0",
"toastify-js": "^1.12.0"
"toastify-js": "^1.12.0",
"update-electron-app": "^3.0.0"
},
"devDependencies": {
"@electron-forge/cli": "^7.2.0",
Expand Down
18 changes: 10 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
} = require("electron");
const path = require("path");
const { exec } = require("child_process");
const { updateElectronApp } = require("update-electron-app");
updateElectronApp();
// const settings = require("electron-settings");

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
Expand Down Expand Up @@ -801,7 +803,7 @@ function unsetSystemEnvironmentVariables() {

async function setLinuxAllProxy(host, port) {
const proxyserver = `http://${host}:${port}`;
const commandsEnv = `$echo ${proxyManagerSudo} | sudo -S tee -a /etc/environment << EOF
const commandsEnv = `echo ${proxyManagerSudo} | sudo -S tee -a /etc/environment << EOF
http_proxy=${proxyserver}
https_proxy=${proxyserver}
ftp_proxy=${proxyserver}
Expand All @@ -811,22 +813,22 @@ async function setLinuxAllProxy(host, port) {
FTP_PROXY=${proxyserver}
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com,127.0.0.0/8,::1"
EOF`;
const commandsApt = `$echo ${proxyManagerSudo} | sudo -S tee /etc/apt/apt.conf.d/proxyManager << EOF
Acquire::http::proxy "http://${host}:${post}/";
Acquire::ftp::proxy "ftp://${host}:${post}/";
Acquire::https::proxy "https://${host}:${post}/";
const commandsApt = `echo ${proxyManagerSudo} | sudo -S tee /etc/apt/apt.conf.d/proxyManager << EOF
Acquire::http::proxy "http://${host}:${port}/";
Acquire::ftp::proxy "ftp://${host}:${port}/";
Acquire::https::proxy "https://${host}:${port}/";
EOF`;
await execPromise(commandsEnv);
await execPromise(commandsApt);
}

async function unsetLinuxAllProxy() {
// const proxyserver = `http://${host}:${port}`;
const commandsEnv = `$echo ${proxyManagerSudo} | sudo -S rm /etc/environment &&
$echo ${proxyManagerSudo} | sudo -S tee /etc/environment << EOF
const commandsEnv = `echo ${proxyManagerSudo} | sudo -S rm /etc/environment &&
echo ${proxyManagerSudo} | sudo -S tee /etc/environment << EOF
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
EOF`;
const commandsApt = `$echo ${proxyManagerSudo} | sudo -S rm /etc/apt/apt.conf.d/proxyManager`;
const commandsApt = `echo ${proxyManagerSudo} | sudo -S rm /etc/apt/apt.conf.d/proxyManager`;
await execPromise(commandsEnv);
await execPromise(commandsApt);
}

0 comments on commit b131f04

Please sign in to comment.