Skip to content

Commit db6ee1d

Browse files
committed
feat: supports mirror usage and add the README back
1 parent 8ecc35c commit db6ee1d

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# filebrowser/get
2+
3+
https://filebrowser.org/installation
4+
5+
```sh
6+
# Windows
7+
iwr -useb https://raw.githubusercontent.com/filebrowser/get/master/get.ps1 | iex
8+
filebrowser -r /path/to/your/files
9+
10+
# Unix
11+
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
12+
filebrowser -r /path/to/your/files
13+
14+
# If you are in trouble with networking issues,
15+
# here is an example to work with mirrors:
16+
export RELEASE_MIRROR='https://gh.api.99988866.xyz/https://github.com'
17+
curl -fsSL https://raw.gitmirror.com/filebrowser/get/master/get.sh | bash
18+
filebrowser -r /path/to/your/files
19+
```

get.ps1

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Requires -RunAsAdministrator
1+
#Requires -RunAsAdministrator
22
#
3-
# File Browser Installer Script
3+
# File Browser Installer Script
44
#
55
# GitHub: https://github.com/filebrowser/filebrowser
66
# Issues: https://github.com/filebrowser/filebrowser/issues
@@ -9,7 +9,7 @@
99
#
1010
# iwr -useb https://raw.githubusercontent.com/filebrowser/get/master/get.ps1 | iex
1111
#
12-
# You should run it as administrator so it can add filemanager to
12+
# You should run it as administrator so it can add filemanager to
1313
# the PATH.
1414
#
1515
function Install-FileManager {
@@ -24,14 +24,21 @@ function Install-FileManager {
2424
}
2525

2626
$file = "windows-$arch-filebrowser.zip"
27-
$url = "https://github.com/filebrowser/filebrowser/releases/download/$tag/$file"
27+
28+
# Support env.RELEASE_MIRROR such as `https://gh.api.99988866.xyz/https://github.com`
29+
$release_base = "https://github.com"
30+
if ($env:RELEASE_MIRROR) {
31+
$release_base = $env:RELEASE_MIRROR
32+
}
33+
$url = "$release_base/filebrowser/filebrowser/releases/download/$tag/$file"
34+
2835
$temp = New-TemporaryFile
2936
$folder = "${env:ProgramFiles}\filebrowser"
3037

3138
Write-Host "Downloading" $url
32-
$WebClient = New-Object System.Net.WebClient
33-
$WebClient.DownloadFile( $url, $temp )
34-
39+
$WebClient = New-Object System.Net.WebClient
40+
$WebClient.DownloadFile( $url, $temp )
41+
3542
Write-Host "Extracting $temp.zip"
3643
Move-Item $temp "$temp.zip"
3744
Expand-Archive "$temp.zip" -DestinationPath $temp
@@ -51,13 +58,13 @@ function Install-FileManager {
5158
Remove-Item -Force -Recurse "$temp"
5259

5360
Write-Host "Adding filemanager to the PATH"
54-
if ((Get-Command "pandoc.exe" -ErrorAction SilentlyContinue) -eq $null) {
61+
if ((Get-Command "pandoc.exe" -ErrorAction SilentlyContinue) -eq $null) {
5562
$path = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
5663
$path = $path + ";$folder"
5764
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value "$path"
5865
}
5966

60-
Write-Host "filemanager successfully installed!" -ForegroundColor Green
67+
Write-Host "filemanager successfully installed!" -ForegroundColor Green
6168
}
6269

6370
Install-FileManager

get.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ install_filemanager()
105105
echo "Aborted, could not find curl or wget"
106106
return 7
107107
fi
108-
108+
109109
filemanager_file="${filemanager_os}-$filemanager_arch-filebrowser$filemanager_dl_ext"
110110
filemanager_tag="$(${net_getter} https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g')"
111-
filemanager_url="https://github.com/filebrowser/filebrowser/releases/download/$filemanager_tag/$filemanager_file"
111+
112+
# Support env.RELEASE_MIRROR such as `https://gh.api.99988866.xyz/https://github.com`
113+
filemanager_url="${RELEASE_MIRROR:-https://github.com}/filebrowser/filebrowser/releases/download/$filemanager_tag/$filemanager_file"
112114
echo "$filemanager_url"
113115

114116
# Use $PREFIX for compatibility with Termux on Android

0 commit comments

Comments
 (0)