Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save queses/f6ac37772b7420c8c643030c3c1772d0 to your computer and use it in GitHub Desktop.
Save queses/f6ac37772b7420c8c643030c3c1772d0 to your computer and use it in GitHub Desktop.
Скрипты для удаленного выполнения в оболочках (Bash, PowerShell и др.)

Скрипты удаленного выполнения

В гистах могут содержаться скрипты для удаленного выполнения в оболочках, таких как Bash и PowerShell.

Пример выполнения в PowerShell:

iex (new-object net.webclient).downloadstring('https://gist.github.com/queses/6546858/raw/script.ps1')

Пример выполнения в SH:

sh -c "$(curl -fsSL https://gist.github.com/queses/6546858/raw/script.sh)"
write-host "checking..."
# check for apache
$apache = scoop which httpd
if($lastexitcode -ne 0) { 'Apache isn''t installed. run ''scoop install apache'''; return }
# check for php
$php = scoop which php
if($lastexitcode -ne 0) { 'PHP isn''t installed. run ''scoop install php'''; return }
$conf = "$(split-path $apache)/../conf/httpd.conf"
'enabling PHP handler...'
$phpmodule = "$(split-path $php -resolve)\php7apache2_4.dll"
if(test-path $phpmodule) {
$lines = gc $conf
$phpmodule = $phpmodule -replace '\\', '/'
"
# php setup
LoadModule php7_module '$phpmodule'
AddHandler application/x-httpd-php .php
PHPIniDir `"$(split-path $phpmodule)`"
" | out-file $conf -append -encoding utf8
} else {
"error: couldn't find $phpmodule"; return
}
"done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment