mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 12:41:45 +00:00
initialize easy install script for application
This commit is contained in:
parent
4527f12972
commit
47541d9405
30
README.md
30
README.md
@ -17,14 +17,29 @@ save configurations, or exit the application.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone the repository:
|
||||
- Simply run the following command in a Windows PowerShell:
|
||||
|
||||
```powershell
|
||||
# Using 'Invoke-RestMethod' and 'Invoke-Expression'
|
||||
irm 'https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/install.ps1'
|
||||
| iex
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Generally, the [Installation](#installation) step will install both the program,
|
||||
its assets, and a shortcut for the Windows Startmenu for your current userprofile.
|
||||
You *could* go into the program directory (`C:\Users\[Username]\AppData\Local\Programs\ProxySwitcher\`)
|
||||
manually and run the program from your CLI in there, but it is recommended to simply
|
||||
use the program in system tray or directly via code. This latter option will be explained
|
||||
next:
|
||||
|
||||
- Clone the repository:
|
||||
|
||||
```powersell
|
||||
git clone https://github.com/Baipyrus/ProxySwitcher.git
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### CLI Commands
|
||||
|
||||
- **set**: Enable all saved proxies including system proxy.
|
||||
@ -45,6 +60,15 @@ save configurations, or exit the application.
|
||||
go run . save
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
1. Clone the repository as seen above in [Usage](#usage)
|
||||
2. Run the following command:
|
||||
|
||||
```powershell
|
||||
GOOS=windows GOARCH=amd64 go build -o build/ -v ./...
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
The programs for which the proxy settings should be managed are stored in a `configs.json`
|
||||
|
65
install.ps1
Normal file
65
install.ps1
Normal file
@ -0,0 +1,65 @@
|
||||
$startupDir = (Get-Location).Path
|
||||
$destinationDir = "$env:LOCALAPPDATA\Programs"
|
||||
$startmenuDir = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs"
|
||||
$powershellPath = "$PSHOME\powershell.exe"
|
||||
|
||||
# Create program directory and relocate
|
||||
Write-Host "Creating program directory in Userprofile..." -ForegroundColor Cyan
|
||||
$programDir = "ProxySwitcher"
|
||||
if ($startupDir -ne $destinationDir)
|
||||
{
|
||||
Set-Location $destinationDir
|
||||
if (-not (Test-Path $programDir))
|
||||
{ New-Item -ItemType Directory -Path $programDir | Out-Null
|
||||
}
|
||||
}
|
||||
Set-Location $programDir
|
||||
$programPath = "$destinationDir\$programDir"
|
||||
|
||||
# Download functional files from github as-is
|
||||
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
||||
function DownloadFile
|
||||
{
|
||||
param (
|
||||
[string]$url
|
||||
)
|
||||
|
||||
$fileName = $url.Split("/")[-1]
|
||||
Invoke-RestMethod $url -OutFile $fileName
|
||||
}
|
||||
DownloadFile -url https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.exe
|
||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/configs.json
|
||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/run.ps1
|
||||
|
||||
# Create assets directory and relocate
|
||||
Write-Host "Downloading assets into local directory..." -ForegroundColor Cyan
|
||||
$assetsDir = "assets"
|
||||
if (-not (Test-Path $assetsDir))
|
||||
{ New-Item -ItemType Directory -Path $assetsDir | Out-Null
|
||||
}
|
||||
Set-Location $assetsDir
|
||||
$assetPath = "$programPath\assets\ICON_Enabled.ico"
|
||||
|
||||
# Download asset files from github
|
||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/assets/ICON_Disabled.ico
|
||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/assets/ICON_Enabled.ico
|
||||
|
||||
# Create Startmenu Shortcut
|
||||
Write-Host "Creating shortcuts for easy access..." -ForegroundColor Cyan
|
||||
$assetsDir = "assets"
|
||||
$shell = New-Object -comObject WScript.Shell
|
||||
$shortcutPath = "$startmenuDir\Proxy Switcher.lnk"
|
||||
$shortcut = $shell.CreateShortcut($shortcutPath)
|
||||
$shortcut.TargetPath = $powershellPath
|
||||
$shortcut.WorkingDirectory = $programPath
|
||||
$shortcut.Arguments = "-ExecutionPolicy Bypass -NonInteractive -NoProfile -WindowStyle Hidden -File ""$programPath\run.ps1"""
|
||||
$shortcut.IconLocation = $assetPath
|
||||
$shortcut.WindowStyle = 7
|
||||
$shortcut.Save()
|
||||
|
||||
# Copy shortcut to autostart
|
||||
Copy-Item -Path $shortcutPath -Destination "$startmenuDir\Startup\" -Force
|
||||
|
||||
# Navigate back to starting position
|
||||
Set-Location $startupDir
|
||||
Write-Host "Windows setup complete!" -ForegroundColor Green
|
Loading…
Reference in New Issue
Block a user