Compare commits

..

No commits in common. "1b8e170fd91877fc390f87d5fe0b2e016c578e91" and "3606f4bbb90a7f849239df1122caeb0f886013f4" have entirely different histories.

2 changed files with 27 additions and 66 deletions

View File

@ -7,31 +7,31 @@ Bootstrap an OS instance with bare essentials.
To bootstrap a macOS instance: To bootstrap a macOS instance:
```console ```console
$ curl -O https://git.infektor.net/config/bootstrap/raw/main/bootstrap-macOS.sh && chmod +x bootstrap-macOS.sh && ./bootstrap-macOS.sh $ curl -O https://code.infektor.net/config/bootstrap/raw/master/bootstrap-macOS.sh && chmod +x bootstrap-macOS.sh && ./bootstrap-macOS.sh
``` ```
To bootstrap a Debian based Linux instance: To bootstrap a Debian based Linux instance:
```console ```console
$ wget https://git.infektor.net/config/bootstrap/raw/main/bootstrap-Debian.sh && chmod +x bootstrap-Debian.sh && ./bootstrap-Debian.sh $ wget https://code.infektor.net/config/bootstrap/raw/master/bootstrap-Debian.sh && chmod +x bootstrap-Debian.sh && ./bootstrap-Debian.sh
``` ```
To bootstrap a Arch Linux based instance: To bootstrap a Arch Linux based instance:
```console ```console
$ curl -O https://git.infektor.net/config/bootstrap/raw/main/bootstrap-Arch.sh && chmod +x bootstrap-Arch.sh && ./bootstrap-Arch.sh $ curl -O https://code.infektor.net/config/bootstrap/raw/master/bootstrap-Arch.sh && chmod +x bootstrap-Arch.sh && ./bootstrap-Arch.sh
``` ```
To bootstrap a Fedora Linux instance: To bootstrap a Fedora Linux instance:
```console ```console
$ curl -O https://git.infektor.net/config/bootstrap/raw/main/bootstrap-Fedora.sh && chmod +x bootstrap-Fedora.sh && ./bootstrap-Fedora.sh $ curl -O https://code.infektor.net/config/bootstrap/raw/master/bootstrap-Fedora.sh && chmod +x bootstrap-Fedora.sh && ./bootstrap-Fedora.sh
``` ```
To bootstrap a Windows instance: To bootstrap a Windows instance:
```console ```console
$ Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-WebRequest -Uri "https://git.infektor.net/config/bootstrap/raw/main/bootstrap-Windows.ps1" -OutFile "./bootstrap-Windows.ps1"; ./bootstrap-Windows.ps1 $ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://code.infektor.net/config/bootstrap/raw/master/bootstrap-Windows.ps1'))
``` ```
## Package ## Package
@ -40,6 +40,6 @@ Install as a pip package to set SSH keys on any of GitHub, GitLab, BitBucket
Cloud, or Gogs servers: Cloud, or Gogs servers:
```console ```console
$ pip install git+https://git.infektor.net/config/bootstrap.git $ pip install git+https://code.infektor.net/config/bootstrap.git
$ python -c 'import bootstrap; bootstrap.set_ssh_keys()' $ python -c 'import bootstrap; bootstrap.set_ssh_keys()'
``` ```

View File

@ -1,65 +1,26 @@
$IsElevated = [bool]([Security.Principal.WindowsPrincipal] ` [CmdletBinding()]
[Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") Param(
$Choices = '&Yes', '&No' [Parameter(Mandatory=$true)]
[String]$email,
[String]$sshKeyType = "ed25519"
)
if (-Not $IsElevated) { # Install Chocolatey
Write-Host "Not running as Administrator. Performing unprivileged actions." Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install Scoop # Enable Hyper-V and containters
Write-Host "`nInstall Scoop" Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
$ScoopInstaller = "$env:USERPROFILE/Downloads/ScoopInstaller.ps1" Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
Invoke-WebRequest -Uri https://get.scoop.sh -OutFile $ScoopInstaller
&$ScoopInstaller -ScoopDir "$env:LocalAppData/Scoop" -ScoopGlobalDir "$env:ProgramData/Scoop"
$Decision = $Host.UI.PromptForChoice('Relaunch as Administrator', 'Proceed?', $Choices, 0) # Install OpenSSH and start service
if ($Decision -eq 0) { choco install --yes "--package-parameters=/SSHServerFeature" openssh
$Bootstrap = $MyInvocation.MyCommand.Path Start-Service sshd
Start-Process powershell.exe "-ExecutionPolicy ByPass -NoProfile -File $Bootstrap" -Verb RunAs Set-Service -Name sshd -StartupType 'Automatic'
}
} else {
Write-Host "Running as Administrator. Performing privileged actions."
# Install 1Password # generate keys and authorize them
$Decision = $Host.UI.PromptForChoice('Install 1Password', 'Proceed?', $Choices, 0) ssh-keygen -t "$sshKeyType" -C "$email" -f "$env:USERPROFILE/.ssh/$sshKeyType"
if ($Decision -eq 0) { # TODO: authorize public key for admin
$1passwordInstaller = "$env:USERPROFILE/Downloads/1PasswordSetup-latest.exe"
Invoke-WebRequest -Uri "https://downloads.1password.com/win/1PasswordSetup-latest.exe" -OutFile "$1passwordInstaller"
&$1passwordInstaller
Remove-Item $1passwordInstaller
} else {
echo 'Skipping 1Password'
}
# Enable Hyper-V # Install Windows-Terminal and Debian
$Decision = $Host.UI.PromptForChoice('Enable Hyper-V', 'Proceed?', $Choices, 0) choco install --yes microsoft-windows-terminal
if ($Decision -eq 0) { wsl --install --distribution Debia
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
} else {
echo 'Skipping Hyper-V'
}
# Enable Containters
$Decision = $Host.UI.PromptForChoice('Enable Containers', 'Proceed?', $Choices, 0)
if ($Decision -eq 0) {
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
} else {
echo 'Skipping Containers'
}
# Install Chocolatey
Write-Host "`nInstall Chocolatey"
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install SSH Server
$Decision = $Host.UI.PromptForChoice('Install SSH Server', 'Proceed?', $Choices, 0)
if ($Decision -eq 0) {
choco install --yes "--package-parameters=/SSHServerFeature" openssh
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
} else {
echo 'Skipping SSH Server'
}
Write-Host 'Press any key to continue...'
[System.Console]::ReadKey($true)
}