chore: Обновлен скрипт установки.
This commit is contained in:
68
install.ps1
68
install.ps1
@@ -1,78 +1,76 @@
|
|||||||
# ==========================================
|
# ==========================================
|
||||||
# 🚀 VPN PROXY INSTALLER
|
# 🚀 VPN PROXY INSTALLER
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# Этот скрипт автоматически скачивает и устанавливает VPN Proxy
|
# This script automatically downloads and installs VPN Proxy
|
||||||
# Использование:
|
# Usage:
|
||||||
# iwr https://git.dokops.ru/dokril/vpn-proxy/raw/branch/master/install.ps1 | iex
|
# iwr https://git.dokops.ru/dokril/vpn-proxy/raw/branch/master/install.ps1 | iex
|
||||||
|
|
||||||
# Исправляем кодировку (кириллицу)
|
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
# --- 1. Проверка прав администратора ---
|
# --- 1. Check Admin Rights ---
|
||||||
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
|
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
|
||||||
Write-Warning "⚠️ Требуются права администратора!"
|
Write-Warning "⚠️ Administrator rights required!"
|
||||||
Write-Host "🔄 Перезапускаю скрипт с правами администратора..." -ForegroundColor Cyan
|
Write-Host "🔄 Restarting script as Administrator..." -ForegroundColor Cyan
|
||||||
|
|
||||||
# Сохраняем скрипт во временный файл, если он запущен из памяти (iex)
|
# Save script to temp file if running from memory (iex)
|
||||||
if ($MyInvocation.MyCommand.CommandType -eq 'Script') {
|
if ($MyInvocation.MyCommand.CommandType -eq 'Script') {
|
||||||
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`"" -Verb RunAs
|
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`"" -Verb RunAs
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Если запущено через IEX, мы не можем просто перезапустить файл.
|
# If running via IEX, we cannot simple restart the file.
|
||||||
# Поэтому мы просто просим пользователя запустить терминал от админа.
|
# We ask user to run terminal as admin.
|
||||||
Write-Error "Пожалуйста, запустите PowerShell от имени Администратора и попробуйте снова."
|
Write-Error "Please run PowerShell as Administrator and try again."
|
||||||
}
|
}
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 2. Настройки ---
|
# --- 2. Settings ---
|
||||||
$InstallRoot = "C:\Tools"
|
$InstallRoot = "C:\Tools"
|
||||||
$InstallDir = "$InstallRoot\vpn-proxy"
|
$InstallDir = "$InstallRoot\vpn-proxy"
|
||||||
# Точная ссылка предоставленная пользователем
|
# Exact link provided by user
|
||||||
$ZipUrl = "https://git.dokops.ru/dokril/vpn-proxy/archive/master.zip"
|
$ZipUrl = "https://git.dokops.ru/dokril/vpn-proxy/archive/master.zip"
|
||||||
$TempZip = "$env:TEMP\vpn-proxy-install.zip"
|
$TempZip = "$env:TEMP\vpn-proxy-install.zip"
|
||||||
|
|
||||||
Write-Host "🚀 Начинаем установку VPN Proxy..." -ForegroundColor Green
|
Write-Host "🚀 Starting VPN Proxy installation..." -ForegroundColor Green
|
||||||
Write-Host "📂 Путь установки: $InstallDir" -ForegroundColor Gray
|
Write-Host "📂 Install path: $InstallDir" -ForegroundColor Gray
|
||||||
|
|
||||||
# Переходим во временную папку, чтобы не блокировать удаление, если мы уже в C:\Tools\vpn-proxy
|
# Move to temp folder to avoid blocking deletion if we are already in C:\Tools\vpn-proxy
|
||||||
Set-Location $env:TEMP
|
Set-Location $env:TEMP
|
||||||
|
|
||||||
# --- 3. Подготовка папки ---
|
# --- 3. Prepare Directory ---
|
||||||
if (-not (Test-Path $InstallRoot)) {
|
if (-not (Test-Path $InstallRoot)) {
|
||||||
New-Item -ItemType Directory -Path $InstallRoot -Force | Out-Null
|
New-Item -ItemType Directory -Path $InstallRoot -Force | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 4. Скачивание ---
|
# --- 4. Downloading ---
|
||||||
Write-Host "⬇️ Скачивание архива обновления..." -ForegroundColor Cyan
|
Write-Host "⬇️ Downloading update archive..." -ForegroundColor Cyan
|
||||||
try {
|
try {
|
||||||
Invoke-WebRequest -Uri $ZipUrl -OutFile $TempZip
|
Invoke-WebRequest -Uri $ZipUrl -OutFile $TempZip
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "❌ Ошибка скачивания с $ZipUrl`nПроверьте подключение к интернету."
|
Write-Error "❌ Failed to download from $ZipUrl`nCheck your internet connection."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 5. Распаковка ---
|
# --- 5. Extracting ---
|
||||||
Write-Host "📦 Распаковка..." -ForegroundColor Cyan
|
Write-Host "📦 Extracting..." -ForegroundColor Cyan
|
||||||
|
|
||||||
# Если папка уже есть, удаляем старую
|
# If folder exists, delete old one
|
||||||
if (Test-Path $InstallDir) {
|
if (Test-Path $InstallDir) {
|
||||||
try {
|
try {
|
||||||
Remove-Item $InstallDir -Recurse -Force -ErrorAction Stop
|
Remove-Item $InstallDir -Recurse -Force -ErrorAction Stop
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Warning "⚠️ Не удалось удалить старую папку $InstallDir"
|
Write-Warning "⚠️ Failed to delete old folder $InstallDir"
|
||||||
Write-Warning " Ошибка: $($_.Exception.Message)"
|
Write-Warning " Error: $($_.Exception.Message)"
|
||||||
Write-Warning " Убедитесь, что файлы не открыты в других программах и вы не находитесь в этой папке."
|
Write-Warning " Make sure files are not open in other programs and you are not inside this folder."
|
||||||
|
|
||||||
$retry = Read-Host " Нажмите Enter чтобы попробовать снова (или Ctrl+C для отмены)"
|
$retry = Read-Host " Press Enter to try again (or Ctrl+C to cancel)"
|
||||||
try {
|
try {
|
||||||
Remove-Item $InstallDir -Recurse -Force -ErrorAction Stop
|
Remove-Item $InstallDir -Recurse -Force -ErrorAction Stop
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "❌ Так и не удалось удалить папку. Установка прервана."
|
Write-Error "❌ Still failed to delete folder. Installation aborted."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,25 +78,25 @@ if (Test-Path $InstallDir) {
|
|||||||
|
|
||||||
Expand-Archive -Path $TempZip -DestinationPath $InstallRoot -Force
|
Expand-Archive -Path $TempZip -DestinationPath $InstallRoot -Force
|
||||||
|
|
||||||
# Архивы обычно распаковываются в папку vpn-proxy-master или vpn-proxy-main
|
# Archives usually extract to vpn-proxy-master or vpn-proxy-main
|
||||||
# Нам нужно переименовать её в vpn-proxy
|
# We need to rename it to vpn-proxy
|
||||||
$ExtractedFolder = Get-ChildItem -Path $InstallRoot -Directory | Where-Object { $_.Name -match "vpn-proxy-(master|main)" } | Select-Object -First 1
|
$ExtractedFolder = Get-ChildItem -Path $InstallRoot -Directory | Where-Object { $_.Name -match "vpn-proxy-(master|main)" } | Select-Object -First 1
|
||||||
|
|
||||||
if ($ExtractedFolder) {
|
if ($ExtractedFolder) {
|
||||||
Rename-Item -Path $ExtractedFolder.FullName -NewName "vpn-proxy" -Force
|
Rename-Item -Path $ExtractedFolder.FullName -NewName "vpn-proxy" -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# Удаляем временный архив
|
# Remove temp archive
|
||||||
Remove-Item $TempZip -Force
|
Remove-Item $TempZip -Force
|
||||||
|
|
||||||
if (-not (Test-Path "$InstallDir\manage.ps1")) {
|
if (-not (Test-Path "$InstallDir\manage.ps1")) {
|
||||||
Write-Error "❌ Ошибка установки: файл manage.ps1 не найден в $InstallDir"
|
Write-Error "❌ Installation error: manage.ps1 not found in $InstallDir"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 6. Запуск ---
|
# --- 6. Launching ---
|
||||||
Write-Host "✅ Установка завершена!" -ForegroundColor Green
|
Write-Host "✅ Installation complete!" -ForegroundColor Green
|
||||||
Write-Host "🚀 Запускаем меню управления..." -ForegroundColor Cyan
|
Write-Host "🚀 Launching control menu..." -ForegroundColor Cyan
|
||||||
Start-Sleep -Seconds 1
|
Start-Sleep -Seconds 1
|
||||||
|
|
||||||
Set-Location $InstallDir
|
Set-Location $InstallDir
|
||||||
|
|||||||
Reference in New Issue
Block a user