GitHub Actions Hackathon'21 - Samba Compiler
Tags: actionshackathon21, samba
Published: 2021-12-06 20:34:17

### What is Samba ?

We know that when you think of samba, you immediately think of happy Brazilians dancing.

<p align="center"><img src="https://media.giphy.com/media/l0IpWimdziTLydf8Y/giphy-downsized-large.gif"/></p>

But.. We are so sorry because situation here is not quite what you think. (We know that you are trying to hide your bewilderment because we experienced the same at the beginning.)

So it always happens like this...
<p align="center"><img src="https://media.giphy.com/media/l3q2K5jinAlChoCLS/giphy.gif"/></p>

Now let's come to our main topic, what is the real samba we are talking about?

SAMBA is a project developed in 1991 by re-adapting the SMB network protocol as free software with reverse engineering methods.

However, it is also worth mentioning that the difference from the default SMB protocol to which it is implemented progresses in a path and version map.

For example, SAMBA 3 released in 2003, enabled the integration of file and printer services between GNU/Linux systems and Windows systems. 

Of course, it didn't aim to be an MS Active Directory competitor yet in this version. 

But we all knew that one day it would be like this... or not... Well, don't be fooled by how precise I am. Because I was 4 years old then and I didn't even have the slightest idea about samba. I'm talking about the dance.

<p align="center" style="width:100%"><img src="https://media.giphy.com/media/K9MPm9A3CaSkw/giphy.gif"/></p>

Years later, with the Samba4 version, which started in 2009 and was announced in 2012, a Domain Controller role similar to MS Active Directory can be added. 

And Windows, Mac and GNU/Linux systems can access this Domain Controller with the same configuration. Currently, there is version 4.15.2 and a new version is released approximately every 6 months. 

As such, it is a very active free software project.

<p align="center"><img src="https://media.giphy.com/media/sIGM1jNY0z2o/giphy.gif"/></p>

To summarize briefly, nowadays samba can be used as an alternative to MS Active directory with various configurations. **I emphasize certain configurations.**

### :arrow_right_hook: Samba Compiler

As it is known, the latest version of Samba packages in the most popular GNU/Linux  disturbitions repositories does not contain the domain controller role. 

If you want to configure samba as a latest version of domain controller, you have to recompile Samba from the source code with various instructions found in [Samba Wiki](https://wiki.samba.org/).

This causes instructions to be re-executed in each version (every 6 months). In addition, package dependencies that change in each version can cause Samba to not work properly.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f430x0hcsyo7uf9ix18o.png)
 
For these reasons, we designed the Samba Compiler Actions structure.

#### Structural privileges

- Thanks to its generic structure, Samba Compiler Actions can easily adapt to that version whenever a new version is released.

- Since we are aware that Samba can be compiled on many platforms, we have prepared the repository to release each distribution separately, such as centos/debian/ubuntu.
    * Although, it's only available for debian at the moment. *All open source supporters are welcome to support this issue in the future!*

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq02mw15ibw01nibklub.png) 

- If you want, you can also create your own .deb and .rpm packages by using this source code compiled with the necessary configurations. In this way, you can easily create or migrate samba domain in all distributions.
    * *We've already made a development for the .deb package! To browse: [Samba Debian Package Generator](https://github.com/aciklab/samba)*


### Submission Category

The category of these actions is of course 'Maintainer Must-Haves'!

### Yaml File or Link to Code

As an example of our logically easy-to-understand actions structure:

```
- name: Get Samba From Docker
        id: get_samba
        run: |
          docker create -ti --name tar_container generate_tar bash
          docker cp tar_container:/opt/samba.tar.gz ./
          package_name="samba-${{steps.prepare.outputs.os_name}}${{steps.prepare.outputs.os_version}}-${{steps.prepare.outputs.samba_version}}-${{steps.date.outputs.date}}.tar.gz"
          mv samba.tar.gz $package_name
          mkdir samba_directory
          cp $package_name samba_directory
          
          echo ::set-output name=path::$(pwd)/"$package_name"
          echo ::set-output name=filename::"$package_name"
          
      - name: Create Release
        id: create_release
        uses: actions/create-release@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: source-${{steps.prepare.outputs.os_name}}-${{steps.prepare.outputs.os_version}}-${{steps.prepare.outputs.samba_version}}-${{steps.date.outputs.date}}
          release_name: source-${{steps.prepare.outputs.os_name}}-${{steps.prepare.outputs.os_version}}-${{steps.prepare.outputs.samba_version}}-${{steps.date.outputs.date}}
          body: |
            Changes in this Release
              - Will be add.
          draft: false
          prerelease: false
          
      - name: Upload the Samba Source Tar to Release Assets
        id: upload-release-asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ${{ steps.get_samba.outputs.path }}
          asset_name: ${{ steps.get_samba.outputs.filename }}
          asset_content_type: application/tar+gzip
```

If you want to review all the code Samba Source Code generator is here! :arrow_down:

{% github https://github.com/aciklab/samba_source %}


### Additional Resources / Info

Of course we used some resources to develop this actions.

- [Samba Official](https://www.samba.org) 
- [Samba Wiki](https://wiki.samba.org)

#### Our Team
- [Ali Orhun Akkirman](https://dev.to/aliorhun)
- [Zeki Ahmet Bayar](https://dev.to/zekiahmetbayar)
- [Duygu Ölmez](https://dev.to/zduygu)