본문 바로가기
Life/open source

ubuntu에 powershell 설치하고 helloworld 찍기

by SpeeDr00t 2016. 8. 19.
반응형

ubuntu에 PowerShell 설치하고 helloworld 찍기


git 설치

mkdir powershell
cd powershell
sudo apt-get install git


powershell 다운로드

git clone --recursive https://github.com/PowerShell/PowerShell.git

cd PowerShell/


설치
cd tools
./download.sh
download.sh
#!/usr/bin/env bash

# Retrieves asset ID and package name of asset ending in argument
# $info looks like: "id": 1698239, "name": "powershell_0.4.0-1_amd64.deb",
get_info() {
    curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep -B 1 "name.*$1"
}

# Get OS specific asset ID and package name
case "$OSTYPE" in
    linux*)
        source /etc/os-release
        echo $ID
        # Install curl and wget to download package
        case "$ID" in
            centos*)
                sudo yum install -y curl wget
                version=rpm
                ;;
            ubuntu)
                sudo apt-get install -y curl wget
                case "$VERSION_ID" in
                    14.04)
                        version=ubuntu1.14.04.1_amd64.deb
                        ;;
                    16.04)
                        version=ubuntu1.16.04.1_amd64.deb
                        ;;
                    *)
                        exit 2 >&2 "Ubuntu $VERSION_ID is not supported!"
                esac
                ;;
            *)
                exit 2 >&2 "$NAME is not supported!"
        esac
        ;;
    darwin*)
        version=pkg
        ;;
    *)
        exit 2 >&2 "$OSTYPE is not supported!"
        ;;
esac

info=$(get_info $version)

# Parses $info for asset ID and package name
read asset package <<< $(echo $info | sed 's/[,"]//g' | awk '{ print $2; print $4 }')

# Downloads asset to file
curl -s -i -H 'Accept: application/octet-stream' https://api.github.com/repos/PowerShell/PowerShell/releases/assets/$asset |
    grep location | sed 's/location: //g' | wget -i - -O $package

# Installs PowerShell package
case "$OSTYPE" in
    linux*)
        source /etc/os-release
        # Install dependencies
        case "$ID" in
            centos)
                sudo yum install -y libicu libunwind
                sudo yum install "./$package"
                ;;
            ubuntu)
                case "$VERSION_ID" in
                    14.04)
                        icupackage=libicu52
                        ;;
                    16.04)
                        icupackage=libicu55
                        ;;
                esac
                sudo apt-get install -y libunwind8 $icupackage
                sudo dpkg -i "./$package"
                ;;
            *)
        esac
        ;;
    darwin*)
        sudo installer -pkg ./$package -target /
        ;;
esac

powershell -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"'

if [[ $? != 0 ]]; then
    echo "ERROR! PowerShell didn't install. Check script output"
    exit 1
fi


1.소스


hello.ps1
Write-Host
Write-Host "Hello world `n"
Write-Host


결과


반응형

'Life > open source' 카테고리의 다른 글

lldb-capstone-arm  (0) 2016.11.24
curl statistics made simple  (0) 2016.11.24
samsung pay exploit  (0) 2016.08.12
pDNS2 is yet another implementation of a passive DNS tool working with Redis as the database  (0) 2016.08.12
DEF CON Media Server  (0) 2016.08.12