Skip to content

Commit

Permalink
add env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
duzyn committed Oct 29, 2024
1 parent 6d84ca1 commit 9509c52
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,38 @@
# 将 Scoop 的仓库源替换为代理的
scoop config scoop_repo https://mirror.ghproxy.com/https://github.com/ScoopInstaller/Scoop

# 目前没有安装 Git,所以先下载几个必需的软件的 JSON,组成一个临时的应用仓库
New-Item -ItemType "directory" -Path "$env:USERPROFILE\scoop\buckets\scoop-cn\bucket"
New-Item -ItemType "directory" -Path "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\7-zip"
New-Item -ItemType "directory" -Path "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\git"

Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/7zip.json -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\bucket\7zip.json"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/install-context.reg -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\7-zip\install-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/uninstall-context.reg -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\7-zip\uninstall-context.reg"

Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/git.json -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\bucket\git.json"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-context.reg -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\git\install-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-context.reg -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\git\uninstall-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-file-associations.reg -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\git\install-file-associations.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-file-associations.reg -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\scripts\git\uninstall-file-associations.reg"
# 如果有设环境变量,就按环境变量来
$SCOOP_DIR = $ScoopDir, $env:SCOOP, "$env:USERPROFILE\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1

# Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/aria2.json -OutFile "$env:USERPROFILE\scoop\buckets\scoop-cn\bucket\aria2.json"

# 安装时注意顺序是 7-Zip, Git, Aria2
# 目前没有安装 Git,所以先下载几个必需的软件的 JSON,组成一个临时的应用仓库
New-Item -ItemType "directory" -Path "$SCOOP_DIR\buckets\scoop-cn\bucket"
New-Item -ItemType "directory" -Path "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip"
New-Item -ItemType "directory" -Path "$SCOOP_DIR\buckets\scoop-cn\scripts\git"

Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/7zip.json -OutFile "$SCOOP_DIR\buckets\scoop-cn\bucket\7zip.json"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/install-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip\install-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/uninstall-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip\uninstall-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/git.json -OutFile "$SCOOP_DIR\buckets\scoop-cn\bucket\git.json"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\install-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\uninstall-context.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-file-associations.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\install-file-associations.reg"
Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-file-associations.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\uninstall-file-associations.reg"

# 安装时注意顺序是 7-Zip, Git
scoop install scoop-cn/7zip
scoop install scoop-cn/git
# scoop install scoop-cn/aria2

# 将 Scoop 的 main 仓库源替换为代理的
if (Test-Path -Path "$env:USERPROFILE\scoop\buckets\main") {
scoop bucket rm main
}
if (Test-Path -Path "$SCOOP_DIR\buckets\main") { scoop bucket rm main }
Write-Host "Adding main bucket..."
scoop bucket add main https://mirror.ghproxy.com/https://github.com/ScoopInstaller/Main

# scoop-cn 库还不是 Git 仓库,删掉后,重新添加 Git 仓库
if (Test-Path -Path "$env:USERPROFILE\scoop\buckets\scoop-cn") {
scoop bucket rm scoop-cn
}
if (Test-Path -Path "$SCOOP_DIR\buckets\scoop-cn") { scoop bucket rm scoop-cn }
Write-Host "Adding scoop-cn bucket..."
scoop bucket add scoop-cn https://mirror.ghproxy.com/https://github.com/duzyn/scoop-cn

# Set-Location "$env:USERPROFILE\scoop\buckets\scoop-cn"
# Set-Location "$SCOOP_DIR\buckets\scoop-cn"
# git config pull.rebase true

Write-Host "scoop and scoop-cn was installed successfully!"

0 comments on commit 9509c52

Please sign in to comment.