Leonardo Da Rosa Silveira João
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Documentação Este documento tem a finalidade de contribuir com os colaboradores da O.S. Systems para o melhor avanço das atividades, auxiliando no dia a dia o desenvolmento das tarefas. Para isto, o manuseio dos recursos disponibilizaddos pelas ferramantes é de grande importância, para que ocorra da melhor maneira possivel sem complicações. Este documento encontra-se em constante atulização... <!-- ## Comandos Utilizados para o Desenvolvimento das Tarefas --> # Git O Git é uma ferramenta para de controle de versão de arquivos. Onde é utilizada para o desenvolvimento de projetos no qual diversos usuários podem contribuir simultaneamente, editando e criando arquivos. Este recurso disponibilizado, torna-se importante para que os usuários trabalhem nos projetos sem o risco de suas alterações serem sobreescritas. :::warning Git é diferente de GitHub, GitBucket, GitLab e etc ::: Os itens citados a cima, GitHub, GitBucket, GitLab, em resumo são um serviço web que fornece suporte para hospedar os projetos. Quando o usuário deseja contribuir com um projeto, o mesmo pode realizar um **fork**. O fork de um projeto permite que realize as alterações sem comprometer o projeto original, e depois é possivel enviar as modificações para o autor do projeto aprovar. Para realizar o fork de um projeto, pode seguir os passos desse link: :::info https://help.github.com/pt/github/getting-started-with-github/fork-a-repo ::: # Git direcionado para o projeto do ShellHub Primeiramente, deve ser realizado um fork do projeto e em seguida o `git clone`. Após essa primeira etapa ser finalizada, é necessário adicionar o endereço do repositório para futuras atualizações. Para isto é necessário realizar o seguinte comando: ```git remote add upstream https://github.com/shellhub-io/shellhub``` Para atualizar todas as ramificações definidas, sem mesclar nenhuma alteração: ```git remote update``` Para aplicar as alterações do upstream/master: ```git rebase -i upstream/master``` > Para facilitar o desenvolvimento em equipe, é interessante adicionar o repositório de ambos colaboradores, para isto, repita o primeiro passo. A seguir pode observar um exemplo: ``` git remote add leonardo https://github.com/leonardojoao/shellhub ``` Para colocar e retirar as modificações na pilha ``` git stash git stash pop ``` Uma exemplo de situação que pode ocorrer. O usuário X está trabalhando na sua tarefa e deseja aplicar as mudanças de outro usuario Y na branch. Vou explicar dois modos: 1 - Não ocorreu o commit das alterações do user X, então é realizado o `git stash` para colocar as modificações na pilha. Após, o proximo passo é colocar as alterações do usuário Y na branch, então pode ser feito o rebase `git rebase leonardo/branch`. Por fim, `git stash pop` para colocar as modificações da tarefa na branch ``` git stash git diff leonardo/branch git log --oneline git rebase leonardo/branch git stash pop ``` 2 - Está trabalhando na branch e foi realizado commit. Primeiro realiza o `git log --oneline` para pegar a hash do commit, pois o objetivo é aplicar este commit sob o do outro usuário. Após, o proximo passo é colocar as alterações, `git rebase leonardo/branch`. Por fim, irá aplicar o commit das modificações da tarefa sob commit do usuário Y. ``` git log --oneline git rebase leonardo/branch git cherry-pick hash_commit ``` :::warning É importante verificar se o repositório encontra-se atualizado. ::: ========================== * `git log -oneline` * `git rebase -i HEAD~3` * `git show` * `git log` * `git checkout master` * `git cherry-pick id_do_commit` * `git log` * `git remote -v` * `git push origin master:branch` ========================== * `git restore file` * `git reset -- file` ========================== <!-- ## Agent --> # Executar agent localmente * Build do agent `go build -ldflags "-X main.AgentVersion=0.3.5"` * Execução `TENANT_ID=<TENANT> SERVER_ADDRESS=<ENDEREÇO_DO_SERVIDOR> PRIVATE_KEY=<PATH_DA_KEY> sudo -E ./agent` <!-- ## Docker --> # Docker - Imagens e Containers * Imagens * Para a ver a lista: `docker images –a` * Para remover uma imagem: `docker image rmi <image_id>` * Para deletar todas as imagens: `docker rmi $(docker images -a -q)` * Containers * Para a ver a lista: `docker container ls` * Para remover um único container: `docker container rm <container ID>` * Para deletar todos os containers: `docker rm $(docker ps -a -q)` ## Docker - Direcionado ao ShellHub Para compilar o projeto temos disponível dois comandos, um que utiliza a cache e outro não. Quando a API sofre muitas modificações é necessário utilizar este comando: ``` bash docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --no-cache ``` Caso contrário pode utilizar esse outro: ``` bash docker-compose -f docker-compose.yml -f docker-compose.dev.yml build ``` Para rodar o serviço: ``` bash docker-compose -f docker-compose.yml -f docker-compose.dev.yml up ``` > Quando o projeto é inicializado pela primeira vez, deve ter cuidado com a porta 22 do ssh. Pois, o projeto utiliza a está porta, para isto você pode mudar a porta interna do ssh do seu dispositivos. Outro ponto importante do projeto é a visualização dos logs, para isto pode ser executados as seguintes linhas de comando: ``` bash docker-compose logs -f api docker-compose logs -f ui docker-compose logs -f ssh ``` Para reinicar o agente: ``` bash docker-compose -f docker-compose.yml -f docker-compose.dev.yml restart agent ``` Acesar o mongo ``` bash docker-compose exec mongo mongo main db.users.find() ``` --- # Rotas do ShellHub ## Criar contar e logar Create account: ``` bash Método: post URL: http://localhost:8081/register Parâmetros: {email="email", username="username", password="password"} ``` Login: ``` bash Método: post URL: http://localhost/api/login Parâmetros: {username="username", password="password"} ``` ## Rotas do device Add device: ``` bash Não é permitido ``` Token device: ``` bash Método: get URL: http://localhost/api/token/new Parâmetros: {} Header: {Authorization: Bearer "your_token_access"} ``` List device: ``` bash Método: get URL: http://localhost/api/devices/uid Parâmetros: {} Header: {Authorization: Bearer "your_token_access"} ``` List devices: ``` bash Método: get URL: http://localhost/api/devices Parâmetros: {} Header: {Authorization: Bearer "your_token_access"} ``` Edit device: ``` bash Método: patch URL: http://localhost/api/devices/uid Parâmetros: {name="name"} Header: {Authorization: Bearer "your_token_access"} ``` Delete device: ``` bash Método: delete URL: http://localhost/api/devices/uid Parâmetros: {} Header: {Authorization: Bearer "your_token_access"} ``` ## Rotas das sessões Add session: ``` bash Não é permitido ``` List session: ``` bash Método: get URL: http://localhost/api/sessions/uid Parâmetros: {Authorization: Bearer "your_token_access"} ``` List session: ``` bash Método: get URL: http://localhost/api/sessions Parâmetros: {Authorization: Bearer "your_token_access"} ``` Edit session: ``` bash Não é permitido ``` Delete session: ``` bash Não é permitido ``` # Uso do HTTPie no ShellHub ## Criar contar e logar Create account: ``` bash http post http://localhost:8081/register email="email" username="username" password="password" ``` Login: ``` bash http post http://localhost/api/login username="username" password="password" ``` ## Device New token: ``` bash http get http://localhost/api/token/new "Authorization: Bearer your_token_access" ``` List device: ``` bash http get http://localhost/api/devices/uid "Authorization: Bearer your_token_access" ``` List devices: ``` bash http get http://localhost/api/devices "Authorization: Bearer your_token_access" ``` Edit devices: ``` bash http patch http://localhost/api/devices/uid name="name" "Authorization: Bearer your_token_access" ``` Delete devices: ``` bash http delete http://localhost/api/devices/uid ``` ## Session List sessions: ``` bash http get http://localhost/api/sessions/uid "Authorization: Bearer your_token_access" ``` List sessions: ``` bash http get http://localhost/api/sessions "Authorization: Bearer your_token_access" ``` # Shellhub Cloud ## Processo de build e execução 1. fazer o build e up do cloud ``` bash docker-compose build && docker-compose up ``` 2. realizar o up do shellhub com a flag ``` bash SHELLHUB_HOSTED=true docker-compose -f docker-compose.yml -f docker-compose.dev.yml up ``` ## Retornar ao shellhub open ``` bash unset SHELLHUB_HOSTED ``` ## Up do cloud com uma branch específica do Shellhub 1. apagar o arquivo go.sum 2. remover do go.mod as referências ao shellhub 3. go get da branch especifica ```bash GOPROXY=direct go get github.com/shellhub-io/shellhub@<branch_name> GOPROXY=direct go get github.com/shellhub-io/shellhub/api@<branch_name> go build ``` 4. seguir com o processo de build

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully