1807-WSL-environment-setting

1807-WSL-environment-setting

Overview

  • Windows Subsystem on Linux (WSL)で環境を構築する。

Target

  • python / pip / virtualenv / virtualenvwrapper
  • git / gibo
  • jenkins
  • powershell
  • nginx

Procedure

1. python environment

  • log in
sakai@eX:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"
sakai@eX:~$ pwd
/home/sakai
sakai@eX:~$ ls
nginx_signing.key  workspace
sakai@eX:~$
sakai@eX:~$ python3 --version
Python 3.6.5
sakai@eX:~$ pip --version


Command 'pip' not found, but can be installed with:

sudo apt install python-pip

sakai@eX:~$ sudo apt install python-pip
sakai@eX:~$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
sakai@eX:~$ sudo pip install virtualenv
sakai@eX:~$ virtualenv --version
16.0.0
sakai@eX:~$ sudo pip install virtualenvwrapper
sakai@eX:~$ whereis virtualenvwrapper
virtualenvwrapper: /usr/local/bin/virtualenvwrapper.sh /mnt/g/Users/sakai/AppData/Local/Programs/Python/Python36-32/Scripts/virtualenvwrapper.bat
  • /.bashrc
sakai@eX:~$ vim ~/.bashrc
    source /usr/local/bin/virtualenvwrapper.sh
    export WORKON_HOME=~/.virtualenvs
    export PROJECT_HOME=~/workspace/py
  • operate virtualenvwrapper
sakai@eX:~$ source ./.bashrc
sakai@eX:~/workspace/py$ mkproject sandbox
New python executable in /home/sakai/.virtualenvs/sandbox/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/preactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/postactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/get_env_details
Creating /home/sakai/workspace/py/sandbox
Setting project for sandbox to /home/sakai/workspace/py/sandbox
(sandbox) sakai@eX:~/workspace/py/sandbox$ workon
sandbox
(sandbox) sakai@eX:~/workspace/py/sandbox$ deactivate
sakai@eX:~/workspace/py/sandbox$ ls

2. git environment

  • git
sakai@eX:~/workspace/py/sandbox$ git --version
git version 2.17.0
sakai@eX:~$ curl https://github.com/simonwhitaker/gibo/blob/master/shell-completions/gibo-completion.bash > gibo.sh
sakai@eX:~$ sudo cp gibo.sh /usr/local/bin
sakai@eX:~$ chmod -x /usr/local/bin/gibo.sh
chmod: changing permissions of '/usr/local/bin/gibo.sh': Operation not permitted
sakai@eX:~$ gibo --version
: not founds/sakai/Downloads/gibo/gibo: 5: /mnt/g/Users/sakai/Downloads/gibo/gibo:
: not founds/sakai/Downloads/gibo/gibo: 10: /mnt/g/Users/sakai/Downloads/gibo/gibo:
gibo 1.0.6 by Simon Whitaker <sw@netcetera.org>
https://github.com/simonwhitaker/gibo
  • git sample operation
sakai@eX:~/workspace/py/sandbox$ git init
Initialized empty Git repository in /home/sakai/workspace/py/sandbox/.git/
sakai@eX:~/workspace/py/sandbox$ echo "" > README.md

sakai@eX:~/workspace/py/sandbox$ git add .
sakai@eX:~/workspace/py/sandbox$ git status
sakai@eX:~/workspace/py/sandbox$ git commit -m 'first commit'

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <sakai@eX.localdomain>) not allowed
sakai@eX:~/workspace/py/sandbox$ git config --global user.email "sakai.memoru@gmail.com"
sakai@eX:~/workspace/py/sandbox$ git config --global user.name "memoru"
sakai@eX:~/workspace/py/sandbox$ git config --list
user.email=sakai.memoru@gmail.com
user.name=memoru
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true

sakai@eX:~/workspace/py/sandbox$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   README.md

sakai@eX:~/workspace/py/sandbox$ git commit -m 'first commit'
[master (root-commit) 91f2e58] first commit
 1 file changed, 5 insertions(+)
 create mode 100644 README.md
sakai@eX:~/workspace/py/sandbox$ vim README.md
sakai@eX:~/workspace/py/sandbox$ git diff HEAD
diff --git a/README.md b/README.md
index d1cd81a..33b84de 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
 # {{title}}

+## overview
+- python workspace on sandbox

 // --- end of markdown

sakai@eX:~/workspace/py/sandbox$

3. node environment

sakai@eX:~/workspace/py/sandbox$ sudo apt update
sakai@eX:~/workspace/py/sandbox$ sudo apt install nodejs
sakai@eX:~/workspace/py/sandbox$ sudo apt install npm
sakai@eX:~/workspace/py/sandbox$ nodejs --version
v8.10.0
sakai@eX:~/workspace/py/sandbox$ npm --version
3.5.2
sakai@eX:~/workspace/py/sandbox$

4. java 8 and jenkins installation

sakai@eX:~/workspace/py/sandbox$ sudo apt install openjdk-8-jdk
sakai@eX:~/workspace/py/sandbox$ java -version
openjdk version "1.8.0_171"
sakai@eX:~$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key > jenkins-ci.org.key
sakai@eX:~$ ls
jenkins-ci.org.key  nginx_signing.key  workspace
sakai@eX:~$ sudo apt-key add jenkins-ci.org.key
OK
sakai@eX:~$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sakai@eX:~$ sudo apt-get update
sakai@eX:~$ sudo apt-get install jenkins
sakai@eX:~$ sudo service --status-all | grep jenkins
 [ ? ]  apport
 [ ? ]  cryptdisks
 [ ? ]  cryptdisks-early
 [ ? ]  hwclock.sh
 [ ? ]  jenkins
 [ ? ]  plymouth
 [ ? ]  plymouth-log
sakai@eX:~$ sudo vim /etc/default/jenkins
HTTP_PORT=8083

sakai@eX:~$ cd /etc/init.d
sakai@eX:/etc/init.d$ ls | grep jenkins
jenkins
sakai@eX:/etc/init.d$ sudo service jenkins enabled
Correct java version found
Usage: /etc/init.d/jenkins {start|stop|status|restart|force-reload}
sakai@eX:/etc/init.d$ sudo service jenkins start
Correct java version found
 * Starting Jenkins Automation Server jenkins                                       [ OK ]
sakai@eX:/etc/init.d$ sudo service --status-all | grep jenkins
 [ ? ]  apport
 [ ? ]  cryptdisks
 [ ? ]  cryptdisks-early
 [ ? ]  hwclock.sh
 [ + ]  jenkins
 [ ? ]  plymouth
 [ ? ]  plymouth-log
sakai@eX:/etc/init.d$
sakai@eX:/etc/init.d$ curl http://127.0.0.1:8083
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body style='background-color:white; color:white;'>


Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Administer

-->

</body></html>       
sakai@eX:/etc/init.d$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
357c7bf2fb4b42bab09975f0c6a5ecd7
sakai@eX:/etc/init.d$

5. powershell

sakai@eX:~$ wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu57_57.1-6ubuntu0.3_amd64.deb
sakai@eX:~$ wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.2/powershell_6.0.2-1.ubuntu.18.04_amd64.deb
sakai@eX:~$ dpkg-deb --raw-extract powershell_6.0.2-1.ubuntu.17.04_amd64.deb pwsh-patched
sakai@eX:~$ sed --in-place 's/curl13/curl14/g' pwsh-patched/DEBIAN/control
sakai@eX:~$ dpkg-deb --build pwsh-patched powershell-patched_6.0.2-1.ubuntu.18.04_amd64.deb

sakai@eX:~$ sudo apt install -f ./libicu57_57.1-6ubuntu0.3_amd64.deb
sakai@eX:~$ sudo apt install -f ./powershell-patched_6.0.2-1.ubuntu.18.04_amd64.deb
sakai@eX:~$ pwsh
PowerShell v6.0.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/sakai> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.2
PSEdition                      Core
GitCommitId                    v6.0.2
OS                             Linux 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22...
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

// --- end of markdown